react-native-wheel-pick 1.2.3 → 1.2.5
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/README.md +23 -3
- package/package.json +1 -1
- package/src/WheelCurvedPicker.web.js +6 -0
- package/src/date-picker.android.js +5 -3
- package/src/date-picker.web.js +52 -0
- package/src/picker.js +26 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
# [react-native-wheel-pick](https://www.npmjs.com/package/react-native-wheel-pick)
|
|
3
3
|
|
|
4
|
-
React native wheel picker for both iOS and android.
|
|
4
|
+
React native wheel picker for both iOS and android.
|
|
5
5
|
|
|
6
6
|
This is not original but inspired by [react-native-wheel-datepicker](https://github.com/pinguinjkeke/react-native-wheel-datepicker)
|
|
7
7
|
|
|
@@ -79,7 +79,6 @@ onDateChange={(date: Date) => { console.log(date) }}
|
|
|
79
79
|
maximumDate={new Date('2050-12-31')}
|
|
80
80
|
onDateChange={date => { console.log(date) }}
|
|
81
81
|
/>
|
|
82
|
-
|
|
83
82
|
```
|
|
84
83
|
```jsx
|
|
85
84
|
// pickerData also support array of object. (Optional Way)
|
|
@@ -110,7 +109,7 @@ onDateChange={(date: Date) => { console.log(date) }}
|
|
|
110
109
|
```
|
|
111
110
|
```jsx
|
|
112
111
|
// Android Only.
|
|
113
|
-
// These is special props for Android. (iOS not work)
|
|
112
|
+
// These is special props for Android. (iOS and Web not work)
|
|
114
113
|
// You can also use these props for DatePicker, too.
|
|
115
114
|
<Picker
|
|
116
115
|
textSize={20}
|
|
@@ -129,7 +128,18 @@ onDateChange={(date: Date) => { console.log(date) }}
|
|
|
129
128
|
<DatePicker
|
|
130
129
|
order='D-M-Y' // Default is M-D-Y
|
|
131
130
|
/>
|
|
131
|
+
|
|
132
|
+
// Test on Web (Platform.OS === 'Web')
|
|
133
|
+
<Picker style={{ height: 50 }} />
|
|
134
|
+
// DatePicker still not supported on Web.
|
|
132
135
|
```
|
|
136
|
+
## How to change Font Family for Android
|
|
137
|
+
|
|
138
|
+
1. Goto `android/app/src/main/res/values/styles.xml`
|
|
139
|
+
2. Add this code `<item name="wheel_font_path">fonts/[FONT_NAME].ttf</item>`
|
|
140
|
+
|
|
141
|
+
Thanks to [@RMabroukS](https://github.com/TronNatthakorn/react-native-wheel-pick/issues/58)
|
|
142
|
+
|
|
133
143
|
## FYI
|
|
134
144
|
|
|
135
145
|
I rarely check this lib. (6 Months - 3 Years). Up on my life's time.
|
|
@@ -142,6 +152,16 @@ You can sponsor me
|
|
|
142
152
|
OR you can fork this project instead.
|
|
143
153
|
|
|
144
154
|
## Release Note
|
|
155
|
+
|
|
156
|
+
### 1.2.5 (Jun 14 2025)
|
|
157
|
+
[Android]
|
|
158
|
+
- Fix Android DatePicker time mode default selection issue and correct hour range. Thanks to [@harryxu](https://github.com/TronNatthakorn/react-native-wheel-pick/pull/66)
|
|
159
|
+
|
|
160
|
+
### 1.2.4 (Feb 17 2025)
|
|
161
|
+
[Web]
|
|
162
|
+
- Test on `Platform.OS === 'web'`
|
|
163
|
+
- Only `<Picker />` can use on Web. `<DatePicker />` still not supported on Web.
|
|
164
|
+
|
|
145
165
|
### 1.2.3 (Feb 15 2024)
|
|
146
166
|
- Fix state is not updating after onValueChange in Picker Component. Thanks to [@spasma
|
|
147
167
|
](https://github.com/TronNatthakorn/react-native-wheel-pick/issues/52)
|
package/package.json
CHANGED
|
@@ -239,12 +239,14 @@ export default class DatePicker extends PureComponent {
|
|
|
239
239
|
|
|
240
240
|
const [hours, minutes] = [[], []];
|
|
241
241
|
|
|
242
|
-
for (let i = 0; i <=
|
|
243
|
-
hours.push(i);
|
|
242
|
+
for (let i = 0; i <= 23; i += 1) {
|
|
243
|
+
// hours.push(i);
|
|
244
|
+
hours.push({ value: i, label: `${i}` })
|
|
244
245
|
}
|
|
245
246
|
|
|
246
247
|
for (let i = 0; i <= 59; i += 1) {
|
|
247
|
-
minutes.push(i);
|
|
248
|
+
// minutes.push(i);
|
|
249
|
+
minutes.push({ value: i, label: `${i}` })
|
|
248
250
|
}
|
|
249
251
|
|
|
250
252
|
return [
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
// import { DatePickerIOS } from 'react-native';
|
|
3
|
+
import DateTimePicker from '@react-native-community/datetimepicker';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
|
|
6
|
+
export default class DatePicker extends PureComponent {
|
|
7
|
+
static propTypes = {
|
|
8
|
+
date: PropTypes.instanceOf(Date),
|
|
9
|
+
maximumDate: PropTypes.instanceOf(Date),
|
|
10
|
+
minimumDate: PropTypes.instanceOf(Date),
|
|
11
|
+
mode: PropTypes.oneOf(['date', 'time', 'datetime']),
|
|
12
|
+
onDateChange: PropTypes.func.isRequired,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
static defaultProps = {
|
|
16
|
+
mode: 'date',
|
|
17
|
+
date: new Date(),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
state = {
|
|
21
|
+
date: new Date(),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// @react-native-community/datetimepicker
|
|
25
|
+
//2022 use value instead of date
|
|
26
|
+
//2022 use onChange instead of onDateChange (and first param not date anymore)
|
|
27
|
+
render() {
|
|
28
|
+
return (
|
|
29
|
+
<DateTimePicker
|
|
30
|
+
{...this.props}
|
|
31
|
+
onChange={(event, date) => this.onDateChange(date)}
|
|
32
|
+
display='spinner'
|
|
33
|
+
value={this.state.date}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
componentDidMount() {
|
|
39
|
+
this.setState({ date: this.props.date })
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
componentDidUpdate(prevProps) {
|
|
43
|
+
if (this.props.date !== prevProps.date) {
|
|
44
|
+
this.setState({ date: this.props.date })
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
onDateChange = (date) => {
|
|
49
|
+
this.setState({ date });
|
|
50
|
+
this.props.onDateChange(date);
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/picker.js
CHANGED
|
@@ -82,9 +82,33 @@ export default class Picker extends Component {
|
|
|
82
82
|
this.validateDeprecateProps('indicatorSize', 'selectLineSize');
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
const propsForWeb = { ...props }
|
|
86
|
+
|
|
87
|
+
if(Platform.OS === 'web'){
|
|
88
|
+
propsForWeb.textcolor = propsForWeb.textColor
|
|
89
|
+
propsForWeb.textsize = propsForWeb.textSize
|
|
90
|
+
|
|
91
|
+
propsForWeb.selecttextcolor = propsForWeb.selectTextColor
|
|
92
|
+
propsForWeb.isshowselectbackground = propsForWeb.isShowSelectBackground.toString()
|
|
93
|
+
propsForWeb.selectbackgroundcolor = propsForWeb.selectBackgroundColor
|
|
94
|
+
propsForWeb.isshowselectline = propsForWeb.isShowSelectLine.toString()
|
|
95
|
+
propsForWeb.selectlinecolor = propsForWeb.selectLineColor
|
|
96
|
+
propsForWeb.selectlinesize = propsForWeb.selectLineSize
|
|
97
|
+
|
|
98
|
+
delete propsForWeb.textColor
|
|
99
|
+
delete propsForWeb.textSize
|
|
100
|
+
|
|
101
|
+
delete propsForWeb.selectTextColor
|
|
102
|
+
delete propsForWeb.isShowSelectBackground
|
|
103
|
+
delete propsForWeb.selectBackgroundColor
|
|
104
|
+
delete propsForWeb.isShowSelectLine
|
|
105
|
+
delete propsForWeb.selectLineColor
|
|
106
|
+
delete propsForWeb.selectLineSize
|
|
107
|
+
}
|
|
108
|
+
|
|
85
109
|
return (
|
|
86
110
|
<WheelCurvedPicker
|
|
87
|
-
{...props}
|
|
111
|
+
{...(Platform.OS === 'web'? propsForWeb: props)}
|
|
88
112
|
style={[styles.picker, style]}
|
|
89
113
|
selectedValue={this.state.selectedValue}
|
|
90
114
|
onValueChange={this.handleChange}
|
|
@@ -94,7 +118,7 @@ export default class Picker extends Component {
|
|
|
94
118
|
key={index}
|
|
95
119
|
value={typeof data.value !== 'undefined' ? data.value : data.toString()}
|
|
96
120
|
label={typeof data.label !== 'undefined' ? data.label : data.toString()}
|
|
97
|
-
color={props.textColor}
|
|
121
|
+
color={(Platform.OS === 'web'? propsForWeb.textcolor: props.textColor)}
|
|
98
122
|
/>
|
|
99
123
|
))}
|
|
100
124
|
</WheelCurvedPicker>
|