@momo-kits/calendar 0.0.55-beta.1 → 0.0.55-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Calendar.js +38 -34
- package/src/CalendarPro.js +55 -40
- package/src/HeaderControl.js +50 -46
- package/src/TabHeader.js +47 -34
package/package.json
CHANGED
package/src/Calendar.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
|
-
import { View,
|
|
3
|
+
import { View, ScrollView, Platform, StyleSheet } from 'react-native';
|
|
4
4
|
import moment from 'moment';
|
|
5
|
-
import { Text, SwitchLanguage } from '@momo-kits/core';
|
|
5
|
+
import { Text, SwitchLanguage, Colors, Spacing, Radius } from '@momo-kits/core';
|
|
6
|
+
import Switch from '@momo-kits/switch';
|
|
6
7
|
import CalendarPro from './CalendarPro';
|
|
7
8
|
import TabHeader from './TabHeader';
|
|
8
9
|
|
|
@@ -318,21 +319,19 @@ class Calendar extends Component {
|
|
|
318
319
|
renderSwitchReturnSelection = () => {
|
|
319
320
|
const { isDoubleDateMode } = this.state;
|
|
320
321
|
return (
|
|
321
|
-
<View style={styles.
|
|
322
|
-
<
|
|
323
|
-
{
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
]}
|
|
335
|
-
/>
|
|
322
|
+
<View style={styles.headerContainer}>
|
|
323
|
+
<View style={styles.viewSwitch}>
|
|
324
|
+
<Text.Title weight="medium" style={styles.textSwitch}>
|
|
325
|
+
{SwitchLanguage.chooseRoundtrip}
|
|
326
|
+
</Text.Title>
|
|
327
|
+
<Switch
|
|
328
|
+
value={isDoubleDateMode}
|
|
329
|
+
onChange={this.toggleSelectionDateMode}
|
|
330
|
+
thumbColor={isDoubleDateMode ? '#78ca32' : 'white'}
|
|
331
|
+
trackColor={{ false: '#e5e7ec', true: '#e5e7ec' }}
|
|
332
|
+
/>
|
|
333
|
+
</View>
|
|
334
|
+
<View style={styles.seperator} />
|
|
336
335
|
</View>
|
|
337
336
|
);
|
|
338
337
|
};
|
|
@@ -420,9 +419,15 @@ class Calendar extends Component {
|
|
|
420
419
|
} = this.props;
|
|
421
420
|
const { isDoubleDateMode } = this.state;
|
|
422
421
|
return (
|
|
423
|
-
<ScrollView style={{ flex: 1, backgroundColor: '
|
|
424
|
-
|
|
425
|
-
|
|
422
|
+
<ScrollView style={{ flex: 1, backgroundColor: 'transparent' }}>
|
|
423
|
+
<View
|
|
424
|
+
style={{
|
|
425
|
+
backgroundColor: Colors.black_01,
|
|
426
|
+
borderRadius: Radius.XS,
|
|
427
|
+
}}>
|
|
428
|
+
{!isHiddenSwitch && this.renderSwitchReturnSelection()}
|
|
429
|
+
{!isHideHeaderPanel && this.renderHeaderPanel()}
|
|
430
|
+
</View>
|
|
426
431
|
<CalendarPro
|
|
427
432
|
ref={this.calendarPicker}
|
|
428
433
|
startDate={doubleDate?.first}
|
|
@@ -485,36 +490,35 @@ Calendar.defaultProps = {
|
|
|
485
490
|
|
|
486
491
|
const styles = StyleSheet.create({
|
|
487
492
|
viewPanel_2: {
|
|
488
|
-
height: 46,
|
|
489
493
|
paddingVertical: 10,
|
|
490
|
-
|
|
491
|
-
alignItems: 'center',
|
|
494
|
+
alignItems: 'flex-start',
|
|
492
495
|
backgroundColor: 'white',
|
|
493
496
|
borderRadius: 8,
|
|
497
|
+
paddingHorizontal: Spacing.M,
|
|
494
498
|
},
|
|
495
499
|
viewPanel: {
|
|
496
500
|
height: 50,
|
|
497
501
|
marginHorizontal: 12,
|
|
498
502
|
marginTop: 6,
|
|
499
|
-
marginBottom: 25,
|
|
500
|
-
padding: 2,
|
|
501
503
|
flexDirection: 'row',
|
|
502
|
-
backgroundColor: '#eeeeef',
|
|
503
|
-
justifyContent: 'space-around',
|
|
504
|
-
borderRadius: 8,
|
|
505
504
|
},
|
|
506
505
|
textSwitch: {
|
|
507
|
-
|
|
508
|
-
fontWeight: 'bold',
|
|
509
|
-
color: '#222222',
|
|
506
|
+
color: Colors.black_15,
|
|
510
507
|
},
|
|
511
508
|
viewSwitch: {
|
|
512
509
|
flexDirection: 'row',
|
|
513
510
|
justifyContent: 'space-between',
|
|
514
|
-
paddingHorizontal: 12,
|
|
515
511
|
alignItems: 'center',
|
|
516
|
-
backgroundColor:
|
|
517
|
-
paddingVertical: 9,
|
|
512
|
+
backgroundColor: Colors.white,
|
|
518
513
|
height: 42,
|
|
519
514
|
},
|
|
515
|
+
seperator: {
|
|
516
|
+
height: 1,
|
|
517
|
+
width: '100%',
|
|
518
|
+
backgroundColor: Colors.black_04,
|
|
519
|
+
},
|
|
520
|
+
headerContainer: {
|
|
521
|
+
paddingHorizontal: 12,
|
|
522
|
+
paddingVertical: 8,
|
|
523
|
+
},
|
|
520
524
|
});
|
package/src/CalendarPro.js
CHANGED
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
Colors,
|
|
18
18
|
Image,
|
|
19
19
|
IconSource,
|
|
20
|
+
Spacing,
|
|
21
|
+
Radius,
|
|
20
22
|
} from '@momo-kits/core';
|
|
21
23
|
import MonthList from './MonthList';
|
|
22
24
|
import HeaderControl from './HeaderControl';
|
|
@@ -248,44 +250,47 @@ export default class CalendarPro extends Component {
|
|
|
248
250
|
onPressBackArrow={this.onPressBackArrow}
|
|
249
251
|
onPressNextArrow={this.onPressNextArrow}
|
|
250
252
|
/>
|
|
251
|
-
<View style={styles.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
{
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
253
|
+
<View style={styles.blueSeperator} />
|
|
254
|
+
<View style={{ paddingHorizontal: Spacing.M }}>
|
|
255
|
+
<View style={styles.viewDay}>
|
|
256
|
+
{[1, 2, 3, 4, 5, 6, 7].map((item) => (
|
|
257
|
+
<Text
|
|
258
|
+
style={[
|
|
259
|
+
styles.textDay,
|
|
260
|
+
{
|
|
261
|
+
color:
|
|
262
|
+
item === 6 || item === 7
|
|
263
|
+
? Colors.red_05
|
|
264
|
+
: Colors.black_12,
|
|
265
|
+
},
|
|
266
|
+
]}
|
|
267
|
+
key={item}>
|
|
268
|
+
{Util.mapWeeKDate(item)}
|
|
269
|
+
</Text>
|
|
270
|
+
))}
|
|
271
|
+
</View>
|
|
272
|
+
<MonthList
|
|
273
|
+
ref="MonthList"
|
|
274
|
+
today={this.today}
|
|
275
|
+
minDate={this.minDate}
|
|
276
|
+
maxDate={this.maxDate}
|
|
277
|
+
startDate={startDate}
|
|
278
|
+
endDate={endDate}
|
|
279
|
+
onChoose={this.onChoose}
|
|
280
|
+
i18n={i18n}
|
|
281
|
+
onScrollCalendar={this.onScrollCalendar}
|
|
282
|
+
isShowLunar={!isOffLunar && showLunar}
|
|
283
|
+
isDoubleDateMode={isDoubleDateMode}
|
|
284
|
+
tabSelected={tabSelected}
|
|
285
|
+
lunarConverter={this.converter}
|
|
286
|
+
holidays={holidays}
|
|
287
|
+
selectedDate={this.selectedDate}
|
|
288
|
+
priceList={priceListFormat}
|
|
289
|
+
labelFrom={labelFrom}
|
|
290
|
+
labelTo={labelTo}
|
|
291
|
+
isHideLabel={isHideLabel}
|
|
292
|
+
/>
|
|
267
293
|
</View>
|
|
268
|
-
<MonthList
|
|
269
|
-
ref="MonthList"
|
|
270
|
-
today={this.today}
|
|
271
|
-
minDate={this.minDate}
|
|
272
|
-
maxDate={this.maxDate}
|
|
273
|
-
startDate={startDate}
|
|
274
|
-
endDate={endDate}
|
|
275
|
-
onChoose={this.onChoose}
|
|
276
|
-
i18n={i18n}
|
|
277
|
-
onScrollCalendar={this.onScrollCalendar}
|
|
278
|
-
isShowLunar={!isOffLunar && showLunar}
|
|
279
|
-
isDoubleDateMode={isDoubleDateMode}
|
|
280
|
-
tabSelected={tabSelected}
|
|
281
|
-
lunarConverter={this.converter}
|
|
282
|
-
holidays={holidays}
|
|
283
|
-
selectedDate={this.selectedDate}
|
|
284
|
-
priceList={priceListFormat}
|
|
285
|
-
labelFrom={labelFrom}
|
|
286
|
-
labelTo={labelTo}
|
|
287
|
-
isHideLabel={isHideLabel}
|
|
288
|
-
/>
|
|
289
294
|
</View>
|
|
290
295
|
{!isOffLunar && (
|
|
291
296
|
<View style={styles.viewLunar}>
|
|
@@ -407,7 +412,7 @@ const styles = StyleSheet.create({
|
|
|
407
412
|
borderStyle: 'solid',
|
|
408
413
|
borderColor: '#c7c7cd',
|
|
409
414
|
},
|
|
410
|
-
viewDate: {
|
|
415
|
+
viewDate: {},
|
|
411
416
|
textDay: {
|
|
412
417
|
// fontSize: 14,
|
|
413
418
|
lineHeight: 16,
|
|
@@ -418,9 +423,19 @@ const styles = StyleSheet.create({
|
|
|
418
423
|
viewDay: {
|
|
419
424
|
flexDirection: 'row',
|
|
420
425
|
justifyContent: 'space-between',
|
|
421
|
-
paddingHorizontal:
|
|
426
|
+
paddingHorizontal: Spacing.S,
|
|
422
427
|
paddingTop: 15,
|
|
423
428
|
paddingBottom: 10,
|
|
424
429
|
},
|
|
425
|
-
container: {
|
|
430
|
+
container: {
|
|
431
|
+
flex: 1,
|
|
432
|
+
backgroundColor: 'white',
|
|
433
|
+
marginTop: Spacing.S,
|
|
434
|
+
borderRadius: Radius.XS,
|
|
435
|
+
},
|
|
436
|
+
blueSeperator: {
|
|
437
|
+
height: 1,
|
|
438
|
+
width: '100%',
|
|
439
|
+
backgroundColor: Colors.blue_05,
|
|
440
|
+
},
|
|
426
441
|
});
|
package/src/HeaderControl.js
CHANGED
|
@@ -1,50 +1,54 @@
|
|
|
1
1
|
import React, { useState, forwardRef, useImperativeHandle } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
View, TouchableOpacity, StyleSheet
|
|
4
|
-
} from 'react-native';
|
|
2
|
+
import { View, TouchableOpacity, StyleSheet } from 'react-native';
|
|
5
3
|
import moment from 'moment';
|
|
6
|
-
import {
|
|
7
|
-
Text, Icon, Colors
|
|
8
|
-
} from '@momo-kits/core';
|
|
4
|
+
import { Text, Icon, Colors, Spacing, ScaleSize } from '@momo-kits/core';
|
|
9
5
|
import Util from './Util';
|
|
10
6
|
|
|
11
|
-
const HeaderControl = forwardRef(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const HeaderControl = forwardRef(
|
|
8
|
+
({ onPressBackArrow, onPressNextArrow, selectedDate }, ref) => {
|
|
9
|
+
const [info, setInfo] = useState({
|
|
10
|
+
date: moment(selectedDate || new Date()),
|
|
11
|
+
});
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
useImperativeHandle(ref, () => ({
|
|
14
|
+
onUpdateInfo,
|
|
15
|
+
}));
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
const onUpdateInfo = (date) => {
|
|
18
|
+
setInfo(date);
|
|
19
|
+
};
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
21
|
+
if (info && info.date) {
|
|
22
|
+
const headerFormat = `${Util.mapMonth(
|
|
23
|
+
info.date.month() + 1,
|
|
24
|
+
)}/${info.date.year()}`;
|
|
25
|
+
return (
|
|
26
|
+
<View style={styles.container}>
|
|
27
|
+
<TouchableOpacity
|
|
28
|
+
style={styles.btnLeft}
|
|
29
|
+
onPress={onPressBackArrow}>
|
|
30
|
+
<Icon
|
|
31
|
+
name="24_arrow_chevron_left_small"
|
|
32
|
+
tintColor={Colors.black_17}
|
|
33
|
+
style={styles.icon}
|
|
34
|
+
/>
|
|
35
|
+
</TouchableOpacity>
|
|
36
|
+
<Text.H4 style={styles.txtHeader}>{headerFormat}</Text.H4>
|
|
37
|
+
<TouchableOpacity
|
|
38
|
+
style={styles.btnRight}
|
|
39
|
+
onPress={onPressNextArrow}>
|
|
40
|
+
<Icon
|
|
41
|
+
name="24_arrow_chevron_right_small"
|
|
42
|
+
tintColor={Colors.black_17}
|
|
43
|
+
style={styles.icon}
|
|
44
|
+
/>
|
|
45
|
+
</TouchableOpacity>
|
|
46
|
+
</View>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return <View />;
|
|
50
|
+
},
|
|
51
|
+
);
|
|
48
52
|
|
|
49
53
|
export default HeaderControl;
|
|
50
54
|
const styles = StyleSheet.create({
|
|
@@ -54,26 +58,26 @@ const styles = StyleSheet.create({
|
|
|
54
58
|
lineHeight: 19,
|
|
55
59
|
fontWeight: 'bold',
|
|
56
60
|
textAlign: 'center',
|
|
57
|
-
color: Colors.black_17
|
|
61
|
+
color: Colors.black_17,
|
|
58
62
|
},
|
|
59
63
|
btnRight: {
|
|
60
64
|
width: 36,
|
|
61
65
|
height: 36,
|
|
62
66
|
justifyContent: 'center',
|
|
63
|
-
alignItems: 'center'
|
|
67
|
+
alignItems: 'center',
|
|
64
68
|
},
|
|
65
69
|
btnLeft: {
|
|
66
70
|
width: 36,
|
|
67
71
|
height: 36,
|
|
68
72
|
justifyContent: 'center',
|
|
69
|
-
alignItems: 'center'
|
|
73
|
+
alignItems: 'center',
|
|
70
74
|
},
|
|
71
75
|
container: {
|
|
72
|
-
height:
|
|
76
|
+
height: ScaleSize(44),
|
|
73
77
|
flexDirection: 'row',
|
|
74
78
|
justifyContent: 'space-between',
|
|
75
|
-
backgroundColor:
|
|
79
|
+
backgroundColor: Colors.blue_10,
|
|
76
80
|
alignItems: 'center',
|
|
77
|
-
borderRadius: 4
|
|
81
|
+
borderRadius: 4,
|
|
78
82
|
},
|
|
79
83
|
});
|
package/src/TabHeader.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TouchableWithoutFeedback, View
|
|
2
|
+
import { TouchableWithoutFeedback, View } from 'react-native';
|
|
3
3
|
import Moment from 'moment';
|
|
4
4
|
import Util from './Util';
|
|
5
|
+
import { Colors, Text } from '@momo-kits/core';
|
|
5
6
|
|
|
6
7
|
export default class TabHeader extends React.Component {
|
|
7
8
|
constructor(props) {
|
|
8
9
|
super(props);
|
|
9
10
|
this.state = {
|
|
10
|
-
active: props.activeTab
|
|
11
|
+
active: props.activeTab,
|
|
11
12
|
};
|
|
12
13
|
this.label = props.label;
|
|
13
14
|
this.defaultDate = props.date ? Moment(props.date) : '';
|
|
@@ -23,7 +24,7 @@ export default class TabHeader extends React.Component {
|
|
|
23
24
|
updateView = (date, activeTab) => {
|
|
24
25
|
this.setState({
|
|
25
26
|
date: date ? Moment(date) : '',
|
|
26
|
-
active: activeTab
|
|
27
|
+
active: activeTab,
|
|
27
28
|
});
|
|
28
29
|
};
|
|
29
30
|
|
|
@@ -35,42 +36,54 @@ export default class TabHeader extends React.Component {
|
|
|
35
36
|
const { label, disabled } = this.props;
|
|
36
37
|
const { date, active } = this.state;
|
|
37
38
|
const formattedDateFromState = date ? date.format('DD/MM/YYYY') : '';
|
|
38
|
-
const formattedDateFromDefault = this.defaultDate
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const formattedDateFromDefault = this.defaultDate
|
|
40
|
+
? this.defaultDate.format('DD/MM/YYYY')
|
|
41
|
+
: '';
|
|
42
|
+
const dayOfWeekFromState = date
|
|
43
|
+
? `${Util.WEEKDAYSFROMMOMENT[date.day()]} -`
|
|
44
|
+
: '';
|
|
45
|
+
const dayOfWeekFromDefault = this.defaultDate
|
|
46
|
+
? `${Util.WEEKDAYSFROMMOMENT[this.defaultDate.day()]} -`
|
|
47
|
+
: '';
|
|
41
48
|
|
|
42
49
|
return (
|
|
43
|
-
<TouchableWithoutFeedback
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}}
|
|
58
|
-
>
|
|
50
|
+
<TouchableWithoutFeedback
|
|
51
|
+
disabled={disabled}
|
|
52
|
+
onPress={this.onChangeTab}>
|
|
53
|
+
<View
|
|
54
|
+
style={{
|
|
55
|
+
flex: 1,
|
|
56
|
+
backgroundColor: Colors.white,
|
|
57
|
+
}}>
|
|
58
|
+
<Text
|
|
59
|
+
style={{
|
|
60
|
+
fontSize: 12,
|
|
61
|
+
lineHeight: 16,
|
|
62
|
+
color: Colors.black_09,
|
|
63
|
+
}}>
|
|
59
64
|
{label}
|
|
60
|
-
|
|
61
65
|
</Text>
|
|
62
|
-
<Text
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<Text
|
|
70
|
-
{
|
|
71
|
-
|
|
66
|
+
<Text
|
|
67
|
+
weight={active ? 'semibold' : 'regular'}
|
|
68
|
+
style={{
|
|
69
|
+
marginTop: 3,
|
|
70
|
+
fontSize: 14,
|
|
71
|
+
color: Colors.black_17,
|
|
72
|
+
}}>
|
|
73
|
+
<Text
|
|
74
|
+
weight={active ? 'semibold' : 'regular'}
|
|
75
|
+
style={{
|
|
76
|
+
color: Colors.black_17,
|
|
77
|
+
}}>
|
|
78
|
+
{`${
|
|
79
|
+
dayOfWeekFromState ||
|
|
80
|
+
dayOfWeekFromDefault ||
|
|
81
|
+
'--'
|
|
82
|
+
} `}
|
|
72
83
|
</Text>
|
|
73
|
-
{formattedDateFromState ||
|
|
84
|
+
{formattedDateFromState ||
|
|
85
|
+
formattedDateFromDefault ||
|
|
86
|
+
'--/--/----'}
|
|
74
87
|
</Text>
|
|
75
88
|
</View>
|
|
76
89
|
</TouchableWithoutFeedback>
|