| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,38 +29,29 @@ export class DatePicker extends DatePickerBase { | |||
| 29 | 29 | return this.nativeView.date.getFullYear(); | |
| 30 | 30 | } | |
| 31 | 31 | [yearProperty.setNative](value: number) { | |
| 32 | - let picker = this.nativeView; | ||
| 33 | - let comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.date); | ||
| 34 | - comps.year = value; | ||
| 35 | - this.date = new Date(comps.year, comps.month - 1, comps.day); | ||
| 32 | + this.date = new Date(value, this.month, this.day); | ||
| 36 | 33 | } | |
| 37 | 34 | ||
| 38 | 35 | [monthProperty.getDefault](): number { | |
| 39 | 36 | return this.nativeView.date.getMonth(); | |
| 40 | 37 | } | |
| 41 | 38 | [monthProperty.setNative](value: number) { | |
| 42 | - let picker = this.nativeView; | ||
| 43 | - let comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.date); | ||
| 44 | - comps.month = value; | ||
| 45 | - this.date = new Date(comps.year, comps.month - 1, comps.day); | ||
| 39 | + this.date = new Date(this.year, value, this.day); | ||
| 46 | 40 | } | |
| 47 | 41 | ||
| 48 | 42 | [dayProperty.getDefault](): number { | |
| 49 | 43 | return this.nativeView.date.getDay(); | |
| 50 | 44 | } | |
| 51 | 45 | [dayProperty.setNative](value: number) { | |
| 52 | - let picker = this.nativeView; | ||
| 53 | - let comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.date); | ||
| 54 | - comps.day = value; | ||
| 55 | - this.date = new Date(comps.year, comps.month - 1, comps.day); | ||
| 46 | + this.date = new Date(this.year, this.month, value); | ||
| 56 | 47 | } | |
| 57 | 48 | ||
| 58 | 49 | [dateProperty.getDefault](): Date { | |
| 59 | 50 | return this.nativeView.date; | |
| 60 | 51 | } | |
| 61 | 52 | [dateProperty.setNative](value: Date) { | |
| 62 | - let picker = this.nativeView; | ||
| 63 | - let comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.date); | ||
| 53 | + const picker = this.nativeView; | ||
| 54 | + const comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.date); | ||
| 64 | 55 | comps.year = value.getFullYear(); | |
| 65 | 56 | comps.month = value.getMonth() + 1; | |
| 66 | 57 | comps.day = value.getDate(); | |
@@ -71,25 +62,25 @@ export class DatePicker extends DatePickerBase { | |||
| 71 | 62 | return this.nativeView.maximumDate; | |
| 72 | 63 | } | |
| 73 | 64 | [maxDateProperty.setNative](value: Date) { | |
| 74 | - let picker = this.nativeView; | ||
| 75 | - let nsDate = NSDate.dateWithTimeIntervalSince1970(value.getTime() / 1000); | ||
| 65 | + const picker = this.nativeView; | ||
| 66 | + const nsDate = NSDate.dateWithTimeIntervalSince1970(value.getTime() / 1000); | ||
| 76 | 67 | picker.maximumDate = <any>nsDate; | |
| 77 | 68 | } | |
| 78 | 69 | ||
| 79 | 70 | [minDateProperty.getDefault](): Date { | |
| 80 | 71 | return this.nativeView.minimumDate; | |
| 81 | 72 | } | |
| 82 | 73 | [minDateProperty.setNative](value: Date) { | |
| 83 | - let picker = this.nativeView; | ||
| 84 | - let nsDate = NSDate.dateWithTimeIntervalSince1970(value.getTime() / 1000); | ||
| 74 | + const picker = this.nativeView; | ||
| 75 | + const nsDate = NSDate.dateWithTimeIntervalSince1970(value.getTime() / 1000); | ||
| 85 | 76 | picker.minimumDate = <any>nsDate; | |
| 86 | 77 | } | |
| 87 | 78 | ||
| 88 | 79 | [colorProperty.getDefault](): UIColor { | |
| 89 | 80 | return this.nativeView.valueForKey("textColor"); | |
| 90 | 81 | } | |
| 91 | 82 | [colorProperty.setNative](value: Color | UIColor) { | |
| 92 | - let picker = this.nativeView; | ||
| 83 | + const picker = this.nativeView; | ||
| 93 | 84 | picker.setValueForKey(value instanceof Color ? value.ios : value, "textColor"); | |
| 94 | 85 | } | |
| 95 | 86 | } | |
@@ -98,15 +89,15 @@ class UIDatePickerChangeHandlerImpl extends NSObject { | |||
| 98 | 89 | private _owner: WeakRef<DatePicker>; | |
| 99 | 90 | ||
| 100 | 91 | public static initWithOwner(owner: WeakRef<DatePicker>): UIDatePickerChangeHandlerImpl { | |
| 101 | - let impl = <UIDatePickerChangeHandlerImpl>UIDatePickerChangeHandlerImpl.new(); | ||
| 92 | + const impl = <UIDatePickerChangeHandlerImpl>UIDatePickerChangeHandlerImpl.new(); | ||
| 102 | 93 | impl._owner = owner; | |
| 103 | 94 | return impl; | |
| 104 | 95 | } | |
| 105 | 96 | ||
| 106 | 97 | public valueChanged(sender: UIDatePicker) { | |
| 107 | - let comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, sender.date); | ||
| 98 | + const comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, sender.date); | ||
| 108 | 99 | ||
| 109 | - let owner = this._owner.get(); | ||
| 100 | + const owner = this._owner.get(); | ||
| 110 | 101 | if (!owner) { | |
| 111 | 102 | return; | |
| 112 | 103 | } | |
@@ -117,8 +108,9 @@ class UIDatePickerChangeHandlerImpl extends NSObject { | |||
| 117 | 108 | dateChanged = true; | |
| 118 | 109 | } | |
| 119 | 110 | ||
| 120 | - if (comps.month !== owner.month) { | ||
| 121 | - monthProperty.nativeValueChange(owner, comps.month); | ||
| 111 | + const jsMonth = comps.month - 1; | ||
| 112 | + if (jsMonth !== owner.month) { | ||
| 113 | + monthProperty.nativeValueChange(owner, jsMonth); | ||
| 122 | 114 | dateChanged = true; | |
| 123 | 115 | } | |
| 124 | 116 | ||
@@ -128,7 +120,7 @@ class UIDatePickerChangeHandlerImpl extends NSObject { | |||
| 128 | 120 | } | |
| 129 | 121 | ||
| 130 | 122 | if (dateChanged) { | |
| 131 | - dateProperty.nativeValueChange(owner, new Date(comps.year, comps.month - 1, comps.day)); | ||
| 123 | + dateProperty.nativeValueChange(owner, new Date(comps.year, jsMonth, comps.day)); | ||
| 132 | 124 | } | |
| 133 | 125 | } | |
| 134 | 126 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments