@momo-kits/date-picker 0.0.39-beta → 0.0.44-beta

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