@@ -29,13 +29,15 @@ class DatePicker extends Component {
29
29
this . state = {
30
30
date : this . getDate ( ) ,
31
31
modalVisible : false ,
32
- animatedHeight : new Animated . Value ( 0 )
32
+ animatedHeight : new Animated . Value ( 0 ) ,
33
+ allowPointerEvents : true
33
34
} ;
34
35
35
36
this . datePicked = this . datePicked . bind ( this ) ;
36
37
this . onPressDate = this . onPressDate . bind ( this ) ;
37
38
this . onPressCancel = this . onPressCancel . bind ( this ) ;
38
39
this . onPressConfirm = this . onPressConfirm . bind ( this ) ;
40
+ this . onDateChange = this . onDateChange . bind ( this ) ;
39
41
this . onDatePicked = this . onDatePicked . bind ( this ) ;
40
42
this . onTimePicked = this . onTimePicked . bind ( this ) ;
41
43
this . onDatetimePicked = this . onDatetimePicked . bind ( this ) ;
@@ -165,6 +167,19 @@ class DatePicker extends Component {
165
167
return ( < Text style = { [ Style . dateText , customStyles . dateText ] } > { this . getDateStr ( ) } </ Text > ) ;
166
168
}
167
169
170
+ onDateChange ( date ) {
171
+ this . setState ( {
172
+ allowPointerEvents : false ,
173
+ date : date
174
+ } )
175
+ const timeoutId = setTimeout ( ( ) => {
176
+ this . setState ( {
177
+ allowPointerEvents : true
178
+ } )
179
+ clearTimeout ( timeoutId )
180
+ } , 500 )
181
+ }
182
+
168
183
onDatePicked ( { action, year, month, day} ) {
169
184
if ( action !== DatePickerAndroid . dismissedAction ) {
170
185
this . setState ( {
@@ -317,16 +332,18 @@ class DatePicker extends Component {
317
332
< Animated . View
318
333
style = { [ Style . datePickerCon , { height : this . state . animatedHeight } , customStyles . datePickerCon ] }
319
334
>
320
- < DatePickerIOS
321
- date = { this . state . date }
322
- mode = { mode }
323
- minimumDate = { minDate && this . getDate ( minDate ) }
324
- maximumDate = { maxDate && this . getDate ( maxDate ) }
325
- onDateChange = { ( date ) => this . setState ( { date : date } ) }
326
- minuteInterval = { minuteInterval }
327
- timeZoneOffsetInMinutes = { timeZoneOffsetInMinutes }
328
- style = { [ Style . datePicker , customStyles . datePicker ] }
329
- />
335
+ < View pointerEvents = { this . state . allowPointerEvents ? 'auto' : 'none' } >
336
+ < DatePickerIOS
337
+ date = { this . state . date }
338
+ mode = { mode }
339
+ minimumDate = { minDate && this . getDate ( minDate ) }
340
+ maximumDate = { maxDate && this . getDate ( maxDate ) }
341
+ onDateChange = { this . onDateChange }
342
+ minuteInterval = { minuteInterval }
343
+ timeZoneOffsetInMinutes = { timeZoneOffsetInMinutes }
344
+ style = { [ Style . datePicker , customStyles . datePicker ] }
345
+ />
346
+ </ View >
330
347
< TouchableHighlight
331
348
underlayColor = { 'transparent' }
332
349
onPress = { this . onPressCancel }
0 commit comments