@@ -29,13 +29,15 @@ class DatePicker extends Component {
2929 this . state = {
3030 date : this . getDate ( ) ,
3131 modalVisible : false ,
32- animatedHeight : new Animated . Value ( 0 )
32+ animatedHeight : new Animated . Value ( 0 ) ,
33+ allowPointerEvents : true
3334 } ;
3435
3536 this . datePicked = this . datePicked . bind ( this ) ;
3637 this . onPressDate = this . onPressDate . bind ( this ) ;
3738 this . onPressCancel = this . onPressCancel . bind ( this ) ;
3839 this . onPressConfirm = this . onPressConfirm . bind ( this ) ;
40+ this . onDateChange = this . onDateChange . bind ( this ) ;
3941 this . onPressMask = this . onPressMask . bind ( this ) ;
4042 this . onDatePicked = this . onDatePicked . bind ( this ) ;
4143 this . onTimePicked = this . onTimePicked . bind ( this ) ;
@@ -174,6 +176,19 @@ class DatePicker extends Component {
174176 return ( < Text style = { [ Style . dateText , customStyles . dateText ] } > { this . getDateStr ( ) } </ Text > ) ;
175177 }
176178
179+ onDateChange ( date ) {
180+ this . setState ( {
181+ allowPointerEvents : false ,
182+ date : date
183+ } )
184+ const timeoutId = setTimeout ( ( ) => {
185+ this . setState ( {
186+ allowPointerEvents : true
187+ } )
188+ clearTimeout ( timeoutId )
189+ } , 500 )
190+ }
191+
177192 onDatePicked ( { action, year, month, day} ) {
178193 if ( action !== DatePickerAndroid . dismissedAction ) {
179194 this . setState ( {
@@ -354,16 +369,18 @@ class DatePicker extends Component {
354369 < Animated . View
355370 style = { [ Style . datePickerCon , { height : this . state . animatedHeight } , customStyles . datePickerCon ] }
356371 >
357- < DatePickerIOS
358- date = { this . state . date }
359- mode = { mode }
360- minimumDate = { minDate && this . getDate ( minDate ) }
361- maximumDate = { maxDate && this . getDate ( maxDate ) }
362- onDateChange = { ( date ) => this . setState ( { date : date } ) }
363- minuteInterval = { minuteInterval }
364- timeZoneOffsetInMinutes = { timeZoneOffsetInMinutes }
365- style = { [ Style . datePicker , customStyles . datePicker ] }
366- />
372+ < View pointerEvents = { this . state . allowPointerEvents ? 'auto' : 'none' } >
373+ < DatePickerIOS
374+ date = { this . state . date }
375+ mode = { mode }
376+ minimumDate = { minDate && this . getDate ( minDate ) }
377+ maximumDate = { maxDate && this . getDate ( maxDate ) }
378+ onDateChange = { this . onDateChange }
379+ minuteInterval = { minuteInterval }
380+ timeZoneOffsetInMinutes = { timeZoneOffsetInMinutes }
381+ style = { [ Style . datePicker , customStyles . datePicker ] }
382+ />
383+ </ View >
367384 < TouchableHighlight
368385 underlayColor = { 'transparent' }
369386 onPress = { this . onPressCancel }
0 commit comments