forked from wusuopu/react-native-wheel-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
date-picker.ios.js
41 lines (36 loc) · 947 Bytes
/
date-picker.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
import React, { Component } from 'react'
import { DatePickerIOS } from 'react-native'
export default class DatePicker extends Component {
constructor(props) {
super(props)
this.state = { date: this.props.date }
}
static propTypes = {
date: React.PropTypes.instanceOf(Date).isRequired,
maximumDate: React.PropTypes.instanceOf(Date),
minimumDate: React.PropTypes.instanceOf(Date),
mode: React.PropTypes.oneOf(['date', 'time', 'datetime']),
onDateChange: React.PropTypes.func
}
static defaultProps = {
mode: 'date',
date: new Date()
}
render() {
const { onDateChange, ...props } = this.props
return (
<DatePickerIOS
{...props}
onDateChange={(date) => {
this.setState({date})
onDateChange && onDateChange(date)
}}
date={this.state.date}
/>
)
}
getValue() {
return this.state.date
}
}