@@ -79,39 +79,45 @@ export class DatePicker extends DatePickerBase {
79
79
}
80
80
81
81
[ dateProperty . setNative ] ( value : Date ) {
82
- const picker = this . nativeViewProtected ;
83
- const comps = NSCalendar . currentCalendar . componentsFromDate ( NSCalendarUnit . CalendarUnitYear | NSCalendarUnit . CalendarUnitMonth | NSCalendarUnit . CalendarUnitDay | NSCalendarUnit . HourCalendarUnit | NSCalendarUnit . MinuteCalendarUnit | NSCalendarUnit . SecondCalendarUnit , picker . date ) ;
84
- comps . year = value . getFullYear ( ) ;
85
- comps . month = value . getMonth ( ) + 1 ;
86
- comps . day = value . getDate ( ) ;
87
- comps . hour = value . getHours ( ) ;
88
- comps . minute = value . getMinutes ( ) ;
89
- comps . second = value . getSeconds ( ) ;
90
- this . year = comps . year ;
91
- this . month = comps . month ;
92
- this . day = comps . day ;
93
- this . hour = comps . hour ;
94
- this . minute = comps . minute ;
95
- this . second = comps . second ;
96
- picker . setDateAnimated ( NSCalendar . currentCalendar . dateFromComponents ( comps ) , false ) ;
82
+ if ( value ) {
83
+ const comps = NSCalendar . currentCalendar . componentsFromDate ( NSCalendarUnit . CalendarUnitYear | NSCalendarUnit . CalendarUnitMonth | NSCalendarUnit . CalendarUnitDay | NSCalendarUnit . HourCalendarUnit | NSCalendarUnit . MinuteCalendarUnit | NSCalendarUnit . SecondCalendarUnit , this . nativeViewProtected . date ) ;
84
+ comps . year = value . getFullYear ( ) ;
85
+ comps . month = value . getMonth ( ) + 1 ;
86
+ comps . day = value . getDate ( ) ;
87
+ comps . hour = value . getHours ( ) ;
88
+ comps . minute = value . getMinutes ( ) ;
89
+ comps . second = value . getSeconds ( ) ;
90
+ this . year = comps . year ;
91
+ this . month = comps . month ;
92
+ this . day = comps . day ;
93
+ this . hour = comps . hour ;
94
+ this . minute = comps . minute ;
95
+ this . second = comps . second ;
96
+ this . nativeViewProtected . setDateAnimated ( NSCalendar . currentCalendar . dateFromComponents ( comps ) , false ) ;
97
+ }
97
98
}
98
99
99
100
[ maxDateProperty . getDefault ] ( ) : Date {
100
101
return this . nativeViewProtected . maximumDate ;
101
102
}
102
103
[ maxDateProperty . setNative ] ( value : Date ) {
103
- const picker = this . nativeViewProtected ;
104
- const nsDate = NSDate . dateWithTimeIntervalSince1970 ( value . getTime ( ) / 1000 ) ;
105
- picker . maximumDate = < any > nsDate ;
104
+ if ( value ) {
105
+ const nsDate = NSDate . dateWithTimeIntervalSince1970 ( value . getTime ( ) / 1000 ) ;
106
+ this . nativeViewProtected . maximumDate = < any > nsDate ;
107
+ } else {
108
+ this . nativeViewProtected . maximumDate = null ;
109
+ }
106
110
}
107
111
108
112
[ minDateProperty . getDefault ] ( ) : Date {
109
113
return this . nativeViewProtected . minimumDate ;
110
114
}
111
115
[ minDateProperty . setNative ] ( value : Date ) {
112
- const picker = this . nativeViewProtected ;
113
- const nsDate = NSDate . dateWithTimeIntervalSince1970 ( value . getTime ( ) / 1000 ) ;
114
- picker . minimumDate = < any > nsDate ;
116
+ if ( value ) {
117
+ this . nativeViewProtected . minimumDate = NSDate . dateWithTimeIntervalSince1970 ( value . getTime ( ) / 1000 ) as any ;
118
+ } else {
119
+ this . nativeViewProtected . minimumDate = null ;
120
+ }
115
121
}
116
122
117
123
[ colorProperty . getDefault ] ( ) : UIColor {
0 commit comments