1.6.0 • Published 5 years ago
react-native-scrollable-datetime-picker v1.6.0
react-native-scrollable-datetime-picker
This is my first npm package, inspired by "react-native-range-datepicker".
Install
$ npm i react-native-scrollable-datetime-picker --save
How to use
import DatePicker from "react-native-scrollable-datetime-picker"
<DatePicker
isSingleDateSelection = {true} //For date range selection,make it false
onPressReset ={()=>this.onPressReset()}
onPressDone ={(startMillies,endMillies)=>this.onPressDone(startMillies,endMillies)}
onPressCancel ={()=>this.onPressCancel()}
startDate= '20181212'
untilDate= '20181215'
selectedBackgroundColor = "red"
hideTimePicker = {true}
/>
onPressReset(){
alert("Reset clicked");
}
onPressDone(startMillies,endMillies){
let result = "";
if(startMillies){
result += new Date(startMillies);
}
if(endMillies){
result += ("\n to \n" + new Date(endMillies));
}
alert(result);
}
onPressCancel(){
alert("Cancel clicked");
}
Proptypes
static propTypes = {
startDate: PropTypes.string,
untilDate: PropTypes.string,
onPressReset: PropTypes.func,
onPressDone: PropTypes.func,
onPressCancel: PropTypes.func,
selectedBackgroundColor: PropTypes.string,
isSingleDateSelection : PropTypes.boolean
hideTimePicker : PropTypes.boolean
}
Default props
static defaultProps = {
startDate: '',
untilDate: '',
onPressReset: () => {},
onPressDone: () => {},
onPressCancel: () => {},
selectedBackgroundColor: '',
isSingleDateSelection : false,
hideTimePicker : false
};
Ok, that's all.
Sorry, if this README is so simple and miss something out.
Feel free to use this package and contributors are welcome. Thank you.