1
1
import { Color } from "tns-core-modules/color" ;
2
2
import { View , ios as iosView } from "tns-core-modules/ui/core/view" ;
3
+ import { device } from "tns-core-modules/platform" ;
3
4
import {
4
5
DateTimePickerBase , DateTimePickerStyleBase , getCurrentPage ,
5
6
DatePickerOptions , TimePickerOptions , PickerOptions
@@ -11,6 +12,10 @@ export class DateTimePickerStyle extends DateTimePickerStyleBase {
11
12
}
12
13
13
14
export 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
+
14
19
public static PICKER_DEFAULT_MESSAGE_HEIGHT = 192 ;
15
20
public static PICKER_WIDTH_INSETS = 16 ;
16
21
public static PICKER_WIDTH_PAD = 304 ;
@@ -43,6 +48,9 @@ export class DateTimePicker extends DateTimePickerBase {
43
48
static _createNativeDatePicker ( options : DatePickerOptions ) : UIDatePicker {
44
49
const pickerView = UIDatePicker . alloc ( ) . initWithFrame ( CGRectZero ) ;
45
50
pickerView . datePickerMode = UIDatePickerMode . Date ;
51
+ if ( this . SUPPORT_DATE_PICKER_STYLE ) {
52
+ ( pickerView as any ) . preferredDatePickerStyle = this . DEFAULT_DATE_PICKER_STYLE ;
53
+ }
46
54
const date = options . date ? options . date : getDateToday ( ) ;
47
55
pickerView . date = date ;
48
56
if ( options . maxDate ) {
@@ -60,6 +68,9 @@ export class DateTimePicker extends DateTimePickerBase {
60
68
static _createNativeTimePicker ( options : TimePickerOptions ) : UIDatePicker {
61
69
const pickerView = UIDatePicker . alloc ( ) . initWithFrame ( CGRectZero ) ;
62
70
pickerView . datePickerMode = UIDatePickerMode . Time ;
71
+ if ( this . SUPPORT_DATE_PICKER_STYLE ) {
72
+ ( pickerView as any ) . preferredDatePickerStyle = this . DEFAULT_DATE_PICKER_STYLE ;
73
+ }
63
74
const time = options . time ? options . time : getDateNow ( ) ;
64
75
pickerView . date = time ;
65
76
if ( options . locale ) {
@@ -177,7 +188,9 @@ export class DateTimePicker extends DateTimePickerBase {
177
188
nativeContainer . backgroundColor = backgroundColor . ios ;
178
189
}
179
190
if ( color ) {
180
- nativePicker . setValueForKey ( color . ios , "textColor" ) ;
191
+ if ( this . SUPPORT_TEXT_COLOR ) {
192
+ nativePicker . setValueForKey ( color , 'textColor' ) ;
193
+ }
181
194
nativePicker . setValueForKey ( false , "highlightsToday" ) ;
182
195
}
183
196
}
@@ -243,4 +256,4 @@ export class DateTimePicker extends DateTimePickerBase {
243
256
}
244
257
return null ;
245
258
}
246
- }
259
+ }
0 commit comments