chore: format

This commit is contained in:
Nathan Walker
2020-07-05 14:57:06 -07:00
parent 8f2900ad0b
commit da3c0b973d
379 changed files with 71587 additions and 54582 deletions

View File

@@ -1,128 +1,155 @@
import {
DatePickerBase, yearProperty, monthProperty, dayProperty,
dateProperty, maxDateProperty, minDateProperty
DatePickerBase,
yearProperty,
monthProperty,
dayProperty,
dateProperty,
maxDateProperty,
minDateProperty,
} from "./date-picker-common";
export * from "./date-picker-common";
interface DateChangedListener {
new(owner: DatePicker): android.widget.DatePicker.OnDateChangedListener;
new (owner: DatePicker): android.widget.DatePicker.OnDateChangedListener;
}
let DateChangedListener: DateChangedListener;
function initializeDateChangedListener(): void {
if (DateChangedListener) {
return;
}
if (DateChangedListener) {
return;
}
@Interfaces([android.widget.DatePicker.OnDateChangedListener])
class DateChangedListenerImpl extends java.lang.Object implements android.widget.DatePicker.OnDateChangedListener {
constructor(public owner: DatePicker) {
super();
@Interfaces([android.widget.DatePicker.OnDateChangedListener])
class DateChangedListenerImpl extends java.lang.Object
implements android.widget.DatePicker.OnDateChangedListener {
constructor(public owner: DatePicker) {
super();
return global.__native(this);
}
return global.__native(this);
}
onDateChanged(picker: android.widget.DatePicker, year: number, month: number, day: number) {
const owner = this.owner;
let dateChanged = false;
if (year !== owner.year) {
yearProperty.nativeValueChange(owner, year);
dateChanged = true;
}
onDateChanged(
picker: android.widget.DatePicker,
year: number,
month: number,
day: number
) {
const owner = this.owner;
let dateChanged = false;
if (year !== owner.year) {
yearProperty.nativeValueChange(owner, year);
dateChanged = true;
}
if (month !== (owner.month - 1)) {
monthProperty.nativeValueChange(owner, month + 1);
dateChanged = true;
}
if (month !== owner.month - 1) {
monthProperty.nativeValueChange(owner, month + 1);
dateChanged = true;
}
if (day !== owner.day) {
dayProperty.nativeValueChange(owner, day);
dateChanged = true;
}
if (day !== owner.day) {
dayProperty.nativeValueChange(owner, day);
dateChanged = true;
}
if (dateChanged) {
dateProperty.nativeValueChange(owner, new Date(year, month, day));
}
}
}
if (dateChanged) {
dateProperty.nativeValueChange(
owner,
new Date(year, month, day)
);
}
}
}
DateChangedListener = DateChangedListenerImpl;
DateChangedListener = DateChangedListenerImpl;
}
export class DatePicker extends DatePickerBase {
nativeViewProtected: android.widget.DatePicker;
nativeViewProtected: android.widget.DatePicker;
public createNativeView() {
const picker = new android.widget.DatePicker(this._context);
picker.setCalendarViewShown(false);
public createNativeView() {
const picker = new android.widget.DatePicker(this._context);
picker.setCalendarViewShown(false);
return picker;
}
return picker;
}
public initNativeView(): void {
super.initNativeView();
initializeDateChangedListener();
const nativeView = this.nativeViewProtected;
const listener = new DateChangedListener(this);
nativeView.init(this.year, this.month - 1, this.day, listener);
(<any>nativeView).listener = listener;
}
public initNativeView(): void {
super.initNativeView();
initializeDateChangedListener();
const nativeView = this.nativeViewProtected;
const listener = new DateChangedListener(this);
nativeView.init(this.year, this.month - 1, this.day, listener);
(<any>nativeView).listener = listener;
}
public disposeNativeView() {
(<any>this.nativeViewProtected).listener.owner = null;
super.disposeNativeView();
}
public disposeNativeView() {
(<any>this.nativeViewProtected).listener.owner = null;
super.disposeNativeView();
}
private updateNativeDate(): void {
const nativeView = this.nativeViewProtected;
const year = typeof this.year === "number" ? this.year : nativeView.getYear();
const month = typeof this.month === "number" ? this.month - 1 : nativeView.getMonth();
const day = typeof this.day === "number" ? this.day : nativeView.getDayOfMonth();
this.date = new Date(year, month, day);
}
private updateNativeDate(): void {
const nativeView = this.nativeViewProtected;
const year =
typeof this.year === "number" ? this.year : nativeView.getYear();
const month =
typeof this.month === "number"
? this.month - 1
: nativeView.getMonth();
const day =
typeof this.day === "number"
? this.day
: nativeView.getDayOfMonth();
this.date = new Date(year, month, day);
}
[yearProperty.setNative](value: number) {
if (this.nativeViewProtected.getYear() !== value) {
this.updateNativeDate();
}
}
[yearProperty.setNative](value: number) {
if (this.nativeViewProtected.getYear() !== value) {
this.updateNativeDate();
}
}
[monthProperty.setNative](value: number) {
if (this.nativeViewProtected.getMonth() !== (value - 1)) {
this.updateNativeDate();
}
}
[monthProperty.setNative](value: number) {
if (this.nativeViewProtected.getMonth() !== value - 1) {
this.updateNativeDate();
}
}
[dayProperty.setNative](value: number) {
if (this.nativeViewProtected.getDayOfMonth() !== value) {
this.updateNativeDate();
}
}
[dayProperty.setNative](value: number) {
if (this.nativeViewProtected.getDayOfMonth() !== value) {
this.updateNativeDate();
}
}
[dateProperty.setNative](value: Date) {
const nativeView = this.nativeViewProtected;
if (nativeView.getDayOfMonth() !== value.getDate()
|| nativeView.getMonth() !== value.getMonth()
|| nativeView.getYear() !== value.getFullYear()) {
nativeView.updateDate(value.getFullYear(), value.getMonth(), value.getDate());
}
}
[dateProperty.setNative](value: Date) {
const nativeView = this.nativeViewProtected;
if (
nativeView.getDayOfMonth() !== value.getDate() ||
nativeView.getMonth() !== value.getMonth() ||
nativeView.getYear() !== value.getFullYear()
) {
nativeView.updateDate(
value.getFullYear(),
value.getMonth(),
value.getDate()
);
}
}
[maxDateProperty.getDefault](): number {
return this.nativeViewProtected.getMaxDate();
}
[maxDateProperty.setNative](value: Date | number) {
const newValue = value instanceof Date ? value.getTime() : value;
this.nativeViewProtected.setMaxDate(newValue);
}
[maxDateProperty.getDefault](): number {
return this.nativeViewProtected.getMaxDate();
}
[maxDateProperty.setNative](value: Date | number) {
const newValue = value instanceof Date ? value.getTime() : value;
this.nativeViewProtected.setMaxDate(newValue);
}
[minDateProperty.getDefault](): number {
return this.nativeViewProtected.getMinDate();
}
[minDateProperty.setNative](value: Date | number) {
const newValue = value instanceof Date ? value.getTime() : value;
this.nativeViewProtected.setMinDate(newValue);
}
[minDateProperty.getDefault](): number {
return this.nativeViewProtected.getMinDate();
}
[minDateProperty.setNative](value: Date | number) {
const newValue = value instanceof Date ? value.getTime() : value;
this.nativeViewProtected.setMinDate(newValue);
}
}