1- import React , { Component , PropTypes } from 'react' ;
1+ import React , { Component } from 'react' ;
2+ import PropTypes from 'prop-types' ;
23import { DatePickerIOS , Text , TouchableOpacity , View } from 'react-native' ;
34import ReactNativeModal from 'react-native-modal' ;
45
@@ -12,7 +13,7 @@ export default class CustomDatePickerIOS extends Component {
1213 customConfirmButtonIOS : PropTypes . node ,
1314 customConfirmButtonWhileInteractingIOS : PropTypes . node ,
1415 customTitleContainerIOS : PropTypes . node ,
15- datePickerContainerStyleIOS : View . propTypes . style ,
16+ datePickerContainerStyleIOS : PropTypes . any ,
1617 date : PropTypes . instanceOf ( Date ) ,
1718 mode : PropTypes . oneOf ( [ 'date' , 'time' , 'datetime' ] ) ,
1819 onConfirm : PropTypes . func . isRequired ,
@@ -46,9 +47,9 @@ export default class CustomDatePickerIOS extends Component {
4647 _handleConfirm = ( ) => this . props . onConfirm ( this . state . date ) ;
4748
4849 _handleDateChange = date => {
49- this . setState ( {
50- date,
51- userIsInteractingWithPicker : false ,
50+ this . setState ( {
51+ date,
52+ userIsInteractingWithPicker : false ,
5253 } ) ;
5354 } ;
5455
@@ -57,7 +58,7 @@ export default class CustomDatePickerIOS extends Component {
5758 userIsInteractingWithPicker : true ,
5859 } ) ;
5960 return false ;
60- }
61+ } ;
6162
6263 render ( ) {
6364 const {
@@ -82,25 +83,29 @@ export default class CustomDatePickerIOS extends Component {
8283 </ View >
8384 ) ;
8485 let confirmButton ;
85-
86- if ( customConfirmButtonIOS ) { // if we have a custom confirm btn
87- if ( customConfirmButtonWhileInteractingIOS // if we have a custom confirm btn while we're interacting
88- && this . state . userIsInteractingWithPicker ) { // and if we're currently interacting
86+
87+ if ( customConfirmButtonIOS ) {
88+ // if we have a custom confirm btn
89+ if (
90+ customConfirmButtonWhileInteractingIOS && // if we have a custom confirm btn while we're interacting
91+ this . state . userIsInteractingWithPicker
92+ ) {
93+ // and if we're currently interacting
8994 confirmButton = customConfirmButtonWhileInteractingIOS ;
90- } else { // otherwise if we're not interacting etc
91- confirmButton = customConfirmButtonIOS ; // just set our confirm button as the custom confirmation button
95+ } else {
96+ // otherwise if we're not interacting etc
97+ confirmButton = customConfirmButtonIOS ; // just set our confirm button as the custom confirmation button
9298 }
93- } else { // else if we don't even have a custom confirmation button just create a component now
94- confirmButton = < Text style = { styles . confirmText } > { confirmTextIOS } </ Text >
99+ } else {
100+ // else if we don't even have a custom confirmation button just create a component now
101+ confirmButton = < Text style = { styles . confirmText } > { confirmTextIOS } </ Text > ;
95102 }
96103 const cancelButton = < Text style = { styles . cancelText } > { cancelTextIOS } </ Text > ;
97104 return (
98105 < ReactNativeModal isVisible = { isVisible } style = { styles . contentContainer } >
99106 < View style = { [ styles . datepickerContainer , datePickerContainerStyleIOS ] } >
100107 { customTitleContainerIOS || titleContainer }
101- < View
102- onStartShouldSetResponderCapture = { this . _handleUserTouchInit }
103- >
108+ < View onStartShouldSetResponderCapture = { this . _handleUserTouchInit } >
104109 < DatePickerIOS
105110 date = { this . state . date }
106111 mode = { mode }
0 commit comments