React native wheel picker for both iOS and android. (Support DatePicker)
This is not original but inspire by react-native-wheel-datepicker
npm install react-native-wheel-pick
react-native link react-native-wheel-pick
import { Platform } from 'react-native';
import { Picker, DatePicker } from 'react-native-wheel-pick';
const isIos = Platform.OS === 'ios'
// use Picker
<Picker
style={{ backgroundColor: 'white', width: 300, height: 215 }}
selectedValue='item4'
pickerData={['item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7']}
onValueChange={value => { }}
itemSpace={30} // this only support in android
/>
// use DatePicker
<DatePicker
style={{ backgroundColor: 'white', height: 215, width: isIos ? 300 : undefined }}
// android not support width
onDateChange={date => { }}
/>
- For iOS use default PickerIOS / DatePickerIOS of React Native.
- For Android use WheelPicker of WheelPicker
- Line color is white in android. (Support Line style in future. Pull request welcome)
- Line color is grey in IOS but it has bug line not show in Picker (iOS 11.4 not sure other version).
// DatePicker set default choose date
<DatePicker
style={{ height: 215, width: isIos ? 300 : undefined }}
date={new Date('2018-06-27')} // Optional prop - default is Today
onDateChange={date => { }}
/>
// DatePicker set min/max Date
<DatePicker
style={{ height: 215, width: isIos ? 300 : undefined }}
minimumDate={new Date('2000-01-01')}
maximumDate={new Date('2050-12-31')}
onDateChange={date => { }}
/>
- Edit broken url.
- Use react-native.config.js instead of rnpm section. @darkbluesun
[Android]
- Add safeExtGet to get sdk version from root project.@darkbluesun
[IOS]
- Fix bug props date of DatePicker is not work right.
- Support props for date picker (date / minimumDate / maximumDate)
[IOS]
- Fix bug cannot read property 'getTime' of null
[Android]
- Fix bug android value wrong from array
- Fix Lifecycle for support React 16 (Remove componentWillMount / componentWillReceiveProps)
[Android]
- Fix bug onValueChange occur first time without change
[Android]
- Support compileSDKVersion 26