11import { Color } from "tns-core-modules/color" ;
22import { View , ios as iosView } from "tns-core-modules/ui/core/view" ;
3+ import { device } from "tns-core-modules/platform" ;
34import {
45 DateTimePickerBase , DateTimePickerStyleBase , getCurrentPage ,
56 DatePickerOptions , TimePickerOptions , PickerOptions
@@ -11,6 +12,10 @@ export class DateTimePickerStyle extends DateTimePickerStyleBase {
1112}
1213
1314export class DateTimePicker extends DateTimePickerBase {
15+ private static readonly SUPPORT_DATE_PICKER_STYLE = parseFloat ( device . osVersion ) >= 14.0 ;
16+ private static readonly SUPPORT_TEXT_COLOR = parseFloat ( device . osVersion ) < 14.0 ;
17+ private static readonly DEFAULT_DATE_PICKER_STYLE = 1 ;
18+
1419 public static PICKER_DEFAULT_MESSAGE_HEIGHT = 192 ;
1520 public static PICKER_WIDTH_INSETS = 16 ;
1621 public static PICKER_WIDTH_PAD = 304 ;
@@ -43,6 +48,9 @@ export class DateTimePicker extends DateTimePickerBase {
4348 static _createNativeDatePicker ( options : DatePickerOptions ) : UIDatePicker {
4449 const pickerView = UIDatePicker . alloc ( ) . initWithFrame ( CGRectZero ) ;
4550 pickerView . datePickerMode = UIDatePickerMode . Date ;
51+ if ( this . SUPPORT_DATE_PICKER_STYLE ) {
52+ ( pickerView as any ) . preferredDatePickerStyle = this . DEFAULT_DATE_PICKER_STYLE ;
53+ }
4654 const date = options . date ? options . date : getDateToday ( ) ;
4755 pickerView . date = date ;
4856 if ( options . maxDate ) {
@@ -60,6 +68,9 @@ export class DateTimePicker extends DateTimePickerBase {
6068 static _createNativeTimePicker ( options : TimePickerOptions ) : UIDatePicker {
6169 const pickerView = UIDatePicker . alloc ( ) . initWithFrame ( CGRectZero ) ;
6270 pickerView . datePickerMode = UIDatePickerMode . Time ;
71+ if ( this . SUPPORT_DATE_PICKER_STYLE ) {
72+ ( pickerView as any ) . preferredDatePickerStyle = this . DEFAULT_DATE_PICKER_STYLE ;
73+ }
6374 const time = options . time ? options . time : getDateNow ( ) ;
6475 pickerView . date = time ;
6576 if ( options . locale ) {
@@ -177,7 +188,9 @@ export class DateTimePicker extends DateTimePickerBase {
177188 nativeContainer . backgroundColor = backgroundColor . ios ;
178189 }
179190 if ( color ) {
180- nativePicker . setValueForKey ( color . ios , "textColor" ) ;
191+ if ( this . SUPPORT_TEXT_COLOR ) {
192+ nativePicker . setValueForKey ( color , 'textColor' ) ;
193+ }
181194 nativePicker . setValueForKey ( false , "highlightsToday" ) ;
182195 }
183196 }
@@ -243,4 +256,4 @@ export class DateTimePicker extends DateTimePickerBase {
243256 }
244257 return null ;
245258 }
246- }
259+ }
0 commit comments