@momo-kits/calendar 0.0.55-beta.1 → 0.0.55-beta.3
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 +2 -2
- package/src/Calendar.js +29 -31
- package/src/CalendarPro.js +8 -1
- 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 } 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
|
};
|
|
@@ -485,36 +484,35 @@ Calendar.defaultProps = {
|
|
|
485
484
|
|
|
486
485
|
const styles = StyleSheet.create({
|
|
487
486
|
viewPanel_2: {
|
|
488
|
-
height: 46,
|
|
489
487
|
paddingVertical: 10,
|
|
490
|
-
|
|
491
|
-
alignItems: 'center',
|
|
488
|
+
alignItems: 'flex-start',
|
|
492
489
|
backgroundColor: 'white',
|
|
493
490
|
borderRadius: 8,
|
|
491
|
+
paddingHorizontal: Spacing.M,
|
|
494
492
|
},
|
|
495
493
|
viewPanel: {
|
|
496
494
|
height: 50,
|
|
497
495
|
marginHorizontal: 12,
|
|
498
496
|
marginTop: 6,
|
|
499
|
-
marginBottom: 25,
|
|
500
|
-
padding: 2,
|
|
501
497
|
flexDirection: 'row',
|
|
502
|
-
backgroundColor: '#eeeeef',
|
|
503
|
-
justifyContent: 'space-around',
|
|
504
|
-
borderRadius: 8,
|
|
505
498
|
},
|
|
506
499
|
textSwitch: {
|
|
507
|
-
|
|
508
|
-
fontWeight: 'bold',
|
|
509
|
-
color: '#222222',
|
|
500
|
+
color: Colors.black_15,
|
|
510
501
|
},
|
|
511
502
|
viewSwitch: {
|
|
512
503
|
flexDirection: 'row',
|
|
513
504
|
justifyContent: 'space-between',
|
|
514
|
-
paddingHorizontal: 12,
|
|
515
505
|
alignItems: 'center',
|
|
516
|
-
backgroundColor:
|
|
517
|
-
paddingVertical: 9,
|
|
506
|
+
backgroundColor: Colors.white,
|
|
518
507
|
height: 42,
|
|
519
508
|
},
|
|
509
|
+
seperator: {
|
|
510
|
+
height: 1,
|
|
511
|
+
width: '100%',
|
|
512
|
+
backgroundColor: Colors.black_04,
|
|
513
|
+
},
|
|
514
|
+
headerContainer: {
|
|
515
|
+
paddingHorizontal: 12,
|
|
516
|
+
paddingVertical: 8,
|
|
517
|
+
},
|
|
520
518
|
});
|
package/src/CalendarPro.js
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
Colors,
|
|
18
18
|
Image,
|
|
19
19
|
IconSource,
|
|
20
|
+
Spacing,
|
|
20
21
|
} from '@momo-kits/core';
|
|
21
22
|
import MonthList from './MonthList';
|
|
22
23
|
import HeaderControl from './HeaderControl';
|
|
@@ -248,6 +249,7 @@ export default class CalendarPro extends Component {
|
|
|
248
249
|
onPressBackArrow={this.onPressBackArrow}
|
|
249
250
|
onPressNextArrow={this.onPressNextArrow}
|
|
250
251
|
/>
|
|
252
|
+
<View style={styles.blueSeperator} />
|
|
251
253
|
<View style={styles.viewDay}>
|
|
252
254
|
{[1, 2, 3, 4, 5, 6, 7].map((item) => (
|
|
253
255
|
<Text
|
|
@@ -418,9 +420,14 @@ const styles = StyleSheet.create({
|
|
|
418
420
|
viewDay: {
|
|
419
421
|
flexDirection: 'row',
|
|
420
422
|
justifyContent: 'space-between',
|
|
421
|
-
paddingHorizontal:
|
|
423
|
+
paddingHorizontal: Spacing.S,
|
|
422
424
|
paddingTop: 15,
|
|
423
425
|
paddingBottom: 10,
|
|
424
426
|
},
|
|
425
427
|
container: { flex: 1, backgroundColor: 'white', marginTop: 20 },
|
|
428
|
+
blueSeperator: {
|
|
429
|
+
height: 1,
|
|
430
|
+
width: '100%',
|
|
431
|
+
backgroundColor: Colors.blue_05,
|
|
432
|
+
},
|
|
426
433
|
});
|
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>
|