Skip to content

Commit ae2bc4c

Browse files
Change header multiple start date /end date to one selected date, if in singledate true
1 parent 2c58df5 commit ae2bc4c

File tree

1 file changed

+59
-22
lines changed

1 file changed

+59
-22
lines changed

Calendar.js

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export default class Calendar extends Component {
4545
'end': '结 束',
4646
'date': '日 期',
4747
'save': '保 存',
48-
'clear': '清除'
48+
'clear': '清除',
49+
'selected': '选'
4950
},
5051
'date': 'M月D日'
5152
},
@@ -57,7 +58,8 @@ export default class Calendar extends Component {
5758
'end': 'End',
5859
'date': 'Date',
5960
'save': 'Save',
60-
'clear': 'Reset'
61+
'clear': 'Reset',
62+
'selected': 'Selected'
6163
},
6264
'date': 'DD / MM'
6365
},
@@ -69,7 +71,8 @@ export default class Calendar extends Component {
6971
'end': 'エンド',
7072
'date': '時 間',
7173
'save': '確 認',
72-
'clear': 'クリア'
74+
'clear': 'クリア',
75+
'selected': '選択'
7376
},
7477
'date': 'M月D日'
7578
}
@@ -207,6 +210,7 @@ export default class Calendar extends Component {
207210
endWeekdayText: ''
208211
});
209212
}
213+
210214
confirm () {
211215
const {
212216
startDate,
@@ -222,6 +226,57 @@ export default class Calendar extends Component {
222226
});
223227
this.close();
224228
}
229+
_renderReturn(){
230+
const {
231+
startDate,
232+
endDate,
233+
startDateText,
234+
startWeekdayText,
235+
endDateText,
236+
endWeekdayText
237+
} = this.state;
238+
const {
239+
mainColor = '#15aaaa',
240+
subColor = '#fff',
241+
borderColor = 'rgba(255, 255, 255, 0.50)'
242+
} = this.props.color;
243+
let color = {mainColor, subColor, borderColor};
244+
let subFontColor = {color: subColor};
245+
let subBack = {backgroundColor: subColor};
246+
if(this.props.singleDate==true){
247+
return ( <View style={styles.result}>
248+
249+
<View style={styles.resultPart}>
250+
<Text style={[styles.resultText, styles.endText, subFontColor]}>
251+
{endDateText || this._i18n('selected', 'text')}
252+
</Text>
253+
<Text style={[styles.resultText, styles.endText, subFontColor]}>
254+
{endWeekdayText || this._i18n('date', 'text')}
255+
</Text>
256+
</View>
257+
</View>)
258+
}else{
259+
return ( <View style={styles.result}>
260+
<View style={styles.resultPart}>
261+
<Text style={[styles.resultText, styles.startText, subFontColor]}>
262+
{startDateText || this._i18n('start', 'text')}
263+
</Text>
264+
<Text style={[styles.resultText, styles.startText, subFontColor]}>
265+
{startWeekdayText || this._i18n('date', 'text')}
266+
</Text>
267+
</View>
268+
<View style={[styles.resultSlash, subBack]}/>
269+
<View style={styles.resultPart}>
270+
<Text style={[styles.resultText, styles.endText, subFontColor]}>
271+
{endDateText || this._i18n('end', 'text')}
272+
</Text>
273+
<Text style={[styles.resultText, styles.endText, subFontColor]}>
274+
{endWeekdayText || this._i18n('date', 'text')}
275+
</Text>
276+
</View>
277+
</View>)
278+
}
279+
}
225280
render () {
226281
const {
227282
startDate,
@@ -266,25 +321,7 @@ export default class Calendar extends Component {
266321
<Text style={[styles.clearText, subFontColor]}>{this._i18n('clear', 'text')}</Text>
267322
</TouchableHighlight>}
268323
</View>
269-
<View style={styles.result}>
270-
<View style={styles.resultPart}>
271-
<Text style={[styles.resultText, styles.startText, subFontColor]}>
272-
{startDateText || this._i18n('start', 'text')}
273-
</Text>
274-
<Text style={[styles.resultText, styles.startText, subFontColor]}>
275-
{startWeekdayText || this._i18n('date', 'text')}
276-
</Text>
277-
</View>
278-
<View style={[styles.resultSlash, subBack]}/>
279-
<View style={styles.resultPart}>
280-
<Text style={[styles.resultText, styles.endText, subFontColor]}>
281-
{endDateText || this._i18n('end', 'text')}
282-
</Text>
283-
<Text style={[styles.resultText, styles.endText, subFontColor]}>
284-
{endWeekdayText || this._i18n('date', 'text')}
285-
</Text>
286-
</View>
287-
</View>
324+
{this._renderReturn()}
288325
<View style={styles.week}>
289326
{[7, 1, 2, 3, 4, 5, 6].map(item =>
290327
<Text style={[styles.weekText, subFontColor]} key={item}>{this._i18n(item, 'w')}</Text>

0 commit comments

Comments
 (0)