@momo-kits/date-picker 0.0.65-beta.23 → 0.0.65-beta.25
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/datePicker/DatePicker.js +8 -13
- package/datePicker/DatePickerInput.js +117 -120
- package/datePicker/ListPicker.js +185 -174
- package/datePicker/WheelPicker.js +286 -305
- package/datePicker/helper/DatePickerHelper.js +58 -22
- package/package.json +15 -15
package/datePicker/ListPicker.js
CHANGED
|
@@ -1,197 +1,208 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
1
|
+
import React, {Component} from 'react';
|
|
2
|
+
import {Dimensions, StyleSheet, View} from 'react-native';
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from '@momo-kits/core';
|
|
4
|
+
Button,
|
|
5
|
+
IconSource,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
Text,
|
|
8
|
+
Colors,
|
|
9
|
+
Image,
|
|
10
|
+
DeviceUtils,
|
|
11
|
+
SwitchLanguage,
|
|
12
|
+
} from '@momo-kits/core-v2';
|
|
13
13
|
import WheelPicker from './WheelPicker';
|
|
14
14
|
|
|
15
|
-
const {
|
|
15
|
+
const {isIphoneX} = DeviceUtils;
|
|
16
16
|
|
|
17
17
|
const widthScreen = Dimensions.get('window').width;
|
|
18
18
|
|
|
19
19
|
export default class ListPicker extends Component {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
constructor(props) {
|
|
21
|
+
super(props);
|
|
22
|
+
this.data = 0;
|
|
23
|
+
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
});
|
|
25
|
+
hide = () => {
|
|
26
|
+
const {onClose, requestClose} = this.props;
|
|
27
|
+
if (requestClose && typeof requestClose === 'function') {
|
|
28
|
+
requestClose(() => {
|
|
29
|
+
if (onClose && typeof onClose === 'function') {
|
|
30
|
+
onClose();
|
|
33
31
|
}
|
|
34
|
-
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
onBeginDrag = () => {
|
|
37
|
+
if (this.refs.picker) {
|
|
38
|
+
this.refs.picker.setScrollEnabled(false);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
onEndDrag = () => {
|
|
43
|
+
if (this.refs.picker) {
|
|
44
|
+
this.refs.picker.setScrollEnabled(true);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
onChangeValue = value => {
|
|
49
|
+
const {callback} = this.props;
|
|
50
|
+
if (typeof callback === 'function') {
|
|
51
|
+
callback(value);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
onPressClear = () => {
|
|
56
|
+
this.hide();
|
|
57
|
+
};
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
onPressChoose = () => {
|
|
60
|
+
this.onChangeValue(this.data);
|
|
61
|
+
this.hide();
|
|
62
|
+
};
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
renderRight = () => (
|
|
65
|
+
<TouchableOpacity onPress={this.onPressChoose}>
|
|
66
|
+
<Text.Paragraph
|
|
67
|
+
style={{
|
|
68
|
+
fontWeight: 'bold',
|
|
69
|
+
color: Colors.pink_05,
|
|
70
|
+
}}>
|
|
71
|
+
{SwitchLanguage.save}
|
|
72
|
+
</Text.Paragraph>
|
|
73
|
+
</TouchableOpacity>
|
|
74
|
+
);
|
|
71
75
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
renderLeftIcon = () => (
|
|
77
|
+
<TouchableOpacity onPress={() => this.hide()}>
|
|
78
|
+
<Image
|
|
79
|
+
source={IconSource.ic_close_x_24}
|
|
80
|
+
style={{
|
|
81
|
+
width: 25,
|
|
82
|
+
height: 25,
|
|
83
|
+
tintColor: Colors.black_17,
|
|
84
|
+
}}
|
|
85
|
+
/>
|
|
86
|
+
</TouchableOpacity>
|
|
87
|
+
);
|
|
80
88
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
renderHeader() {
|
|
90
|
+
const {title = ''} = this.props;
|
|
91
|
+
return (
|
|
92
|
+
<View style={styles.header}>
|
|
93
|
+
{this.renderLeftIcon()}
|
|
94
|
+
<Text style={styles.title}>{title}</Text>
|
|
95
|
+
{this.props.typeStyle === 'aboveAction' ? (
|
|
96
|
+
this.renderRight()
|
|
97
|
+
) : (
|
|
98
|
+
<View style={{width: 25}} />
|
|
99
|
+
)}
|
|
100
|
+
</View>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
95
103
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
104
|
+
renderContent() {
|
|
105
|
+
const {arrData = [], stylePicker, initValue} = this.props;
|
|
106
|
+
return (
|
|
107
|
+
<View style={styles.contentStyle}>
|
|
108
|
+
<WheelPicker
|
|
109
|
+
stylePicker={stylePicker}
|
|
110
|
+
bottomOffset={1}
|
|
111
|
+
value={initValue}
|
|
112
|
+
key="picker"
|
|
113
|
+
ref="picker"
|
|
114
|
+
arrayValue={arrData}
|
|
115
|
+
onBeginDrag={this.onBeginDrag}
|
|
116
|
+
onEndDrag={this.onEndDrag}
|
|
117
|
+
onValueChange={value => {
|
|
118
|
+
this.data = value;
|
|
119
|
+
}}
|
|
120
|
+
/>
|
|
121
|
+
</View>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
116
124
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
125
|
+
render() {
|
|
126
|
+
return (
|
|
127
|
+
<View style={styles.view}>
|
|
128
|
+
{this.renderHeader()}
|
|
129
|
+
{this.renderContent()}
|
|
130
|
+
{this.props.typeStyle === 'aboveAction' ? null : (
|
|
131
|
+
<View style={styles.btnView}>
|
|
132
|
+
<Button
|
|
133
|
+
style={{flex: 1}}
|
|
134
|
+
title={SwitchLanguage.cancel}
|
|
135
|
+
buttonStyle={{
|
|
136
|
+
backgroundColor: Colors.second_text_color,
|
|
137
|
+
}}
|
|
138
|
+
onPress={this.onPressClear}
|
|
139
|
+
/>
|
|
140
|
+
<Button
|
|
141
|
+
style={{
|
|
142
|
+
flex: 1,
|
|
143
|
+
marginLeft: 15,
|
|
144
|
+
}}
|
|
145
|
+
title={SwitchLanguage.choose}
|
|
146
|
+
type="primary"
|
|
147
|
+
onPress={this.onPressChoose}
|
|
148
|
+
/>
|
|
149
|
+
</View>
|
|
150
|
+
)}
|
|
151
|
+
</View>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
143
154
|
}
|
|
144
155
|
|
|
145
156
|
const styles = StyleSheet.create({
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
157
|
+
container: {
|
|
158
|
+
flexDirection: 'row',
|
|
159
|
+
width: widthScreen,
|
|
160
|
+
alignItems: 'center',
|
|
161
|
+
justifyContent: 'center',
|
|
162
|
+
},
|
|
163
|
+
contentStyle: {
|
|
164
|
+
height: 230,
|
|
165
|
+
},
|
|
166
|
+
column: {
|
|
167
|
+
borderWidth: 2,
|
|
168
|
+
borderColor: 'red',
|
|
169
|
+
},
|
|
170
|
+
header: {
|
|
171
|
+
flexDirection: 'row',
|
|
172
|
+
height: 50,
|
|
173
|
+
width: widthScreen,
|
|
174
|
+
paddingHorizontal: 16,
|
|
175
|
+
alignItems: 'center',
|
|
176
|
+
justifyContent: 'space-between',
|
|
177
|
+
backgroundColor: '#fff',
|
|
178
|
+
borderBottomWidth: 1,
|
|
179
|
+
borderColor: '#DADADA',
|
|
180
|
+
},
|
|
181
|
+
view: {
|
|
182
|
+
backgroundColor: 'white',
|
|
183
|
+
paddingBottom: 10 + (isIphoneX() ? 10 : 0),
|
|
184
|
+
},
|
|
185
|
+
title: {
|
|
186
|
+
fontWeight: 'bold',
|
|
187
|
+
color: Colors.black_17,
|
|
188
|
+
flex: 1,
|
|
189
|
+
fontSize: 16,
|
|
190
|
+
textAlign: 'center',
|
|
191
|
+
},
|
|
192
|
+
titleCancel: {
|
|
193
|
+
fontSize: 17,
|
|
194
|
+
color: '#4A90E2',
|
|
195
|
+
},
|
|
196
|
+
titleConfirm: {
|
|
197
|
+
fontSize: 17,
|
|
198
|
+
color: '#4A90E2',
|
|
199
|
+
textAlign: 'right',
|
|
200
|
+
},
|
|
201
|
+
btnView: {
|
|
202
|
+
flexDirection: 'row',
|
|
203
|
+
justifyContent: 'space-between',
|
|
204
|
+
marginHorizontal: 15,
|
|
205
|
+
height: 60,
|
|
206
|
+
alignItems: 'center',
|
|
207
|
+
},
|
|
197
208
|
});
|