1-
21'use strict' ;
32import React , { Component } from 'react' ;
3+ import PropTypes from 'prop-types' ;
44import {
55 StyleSheet ,
6- Text ,
76 View ,
87 NativeModules ,
98 requireNativeComponent ,
109} from 'react-native' ;
1110
12- const DatePickerIOS = React . createClass ( {
13- propTypes : {
14- date : React . PropTypes . oneOfType ( [ React . PropTypes . string , React . PropTypes . number ] ) ,
15- onChange : React . PropTypes . func ,
16- maximumDate : React . PropTypes . oneOfType ( [ React . PropTypes . string , React . PropTypes . number ] ) ,
17- minimumDate : React . PropTypes . oneOfType ( [ React . PropTypes . string , React . PropTypes . number ] ) ,
18- mode : React . PropTypes . oneOf ( [ 'date' , 'time' , 'datetime' ] ) ,
19- timeZoneOffsetInMinutes : React . PropTypes . number ,
20- dateFormat : React . PropTypes . string ,
21- calendar : React . PropTypes . string ,
22- } ,
23- getDefaultProps : function ( ) {
24- return {
25- mode : 'datetime' ,
26- date : new Date ( ) . getTime ( ) ,
27- dateFormat : "dd-MM-yyyy" ,
28- calendar : "Gregorian"
29- } ;
30- } ,
31- _onChange ( event ) {
11+ class DatePickerIOS extends Component {
12+ _onChange = ( event ) => {
3213 const timestamp = event . nativeEvent . timestamp ;
3314 const date = event . nativeEvent . date ;
3415 this . props . onChange && this . props . onChange ( { date, timestamp } ) ;
35- } ,
16+ }
3617 render ( ) {
3718 const props = this . props ;
3819 return (
@@ -50,12 +31,28 @@ const DatePickerIOS = React.createClass({
5031 </ View >
5132 ) ;
5233 }
53- } ) ;
34+ } ;
35+ DatePickerIOS . propTypes = {
36+ date : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
37+ onChange : PropTypes . func ,
38+ maximumDate : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
39+ minimumDate : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
40+ mode : PropTypes . oneOf ( [ 'date' , 'time' , 'datetime' ] ) ,
41+ timeZoneOffsetInMinutes : PropTypes . number ,
42+ dateFormat : PropTypes . string ,
43+ calendar : PropTypes . string ,
44+ }
45+ DatePickerIOS . defaultProps = {
46+ mode : 'datetime' ,
47+ date : new Date ( ) . getTime ( ) ,
48+ dateFormat : "dd-MM-yyyy" ,
49+ calendar : "Gregorian"
50+ } ;
5451const styles = StyleSheet . create ( {
5552 datePickerIOS : {
5653 height : 216 ,
5754 } ,
5855} ) ;
5956
6057var RCTDatePickerIos = requireNativeComponent ( "RCTDatePickerIos" , DatePickerIOS ) ;
61- module . exports = DatePickerIOS ;
58+ module . exports = DatePickerIOS ;
0 commit comments