mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
Fixed Switch
This commit is contained in:
@ -1 +1,11 @@
|
|||||||
|
import { Switch as SwitchDefinition } from "ui/switch";
|
||||||
|
import { View, Property, booleanConverter } from "ui/core/view";
|
||||||
|
|
||||||
|
export * from "ui/core/view";
|
||||||
|
|
||||||
|
export class SwitchBase extends View implements SwitchDefinition {
|
||||||
|
public checked: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const checkedProperty = new Property<SwitchBase, boolean>({ name: "checked", defaultValue: false, valueConverter: booleanConverter });
|
||||||
|
checkedProperty.register(SwitchBase);
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { Switch as SwitchDefinition } from "ui/switch";
|
import {
|
||||||
import { View, Color, Property, colorProperty, backgroundColorProperty, backgroundInternalProperty, booleanConverter } from "ui/core/view";
|
SwitchBase, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, checkedProperty
|
||||||
|
} from "./switch-common";
|
||||||
|
|
||||||
export * from "ui/core/view";
|
export * from "./switch-common";
|
||||||
|
|
||||||
@Interfaces([android.widget.CompoundButton.OnCheckedChangeListener])
|
@Interfaces([android.widget.CompoundButton.OnCheckedChangeListener])
|
||||||
class CheckedChangeListener extends java.lang.Object implements android.widget.CompoundButton.OnCheckedChangeListener {
|
class CheckedChangeListener extends java.lang.Object implements android.widget.CompoundButton.OnCheckedChangeListener {
|
||||||
@ -18,7 +19,7 @@ class CheckedChangeListener extends java.lang.Object implements android.widget.C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Switch extends View implements SwitchDefinition {
|
export class Switch extends SwitchBase {
|
||||||
private _android: android.widget.Switch;
|
private _android: android.widget.Switch;
|
||||||
private listener: android.widget.CompoundButton.OnCheckedChangeListener;
|
private listener: android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
public checked: boolean;
|
public checked: boolean;
|
||||||
@ -69,6 +70,3 @@ export class Switch extends View implements SwitchDefinition {
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const checkedProperty = new Property<Switch, boolean>({ name: "checked", defaultValue: false, valueConverter: booleanConverter });
|
|
||||||
checkedProperty.register(Switch);
|
|
@ -1,7 +1,8 @@
|
|||||||
import { Switch as SwitchDefinition } from "ui/switch";
|
import {
|
||||||
import { View, layout, Color, Property, colorProperty, backgroundColorProperty, backgroundInternalProperty, booleanConverter } from "ui/core/view";
|
SwitchBase, layout, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, checkedProperty
|
||||||
|
} from "./switch-common";
|
||||||
|
|
||||||
export * from "ui/core/view";
|
export * from "./switch-common";
|
||||||
|
|
||||||
class SwitchChangeHandlerImpl extends NSObject {
|
class SwitchChangeHandlerImpl extends NSObject {
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ class SwitchChangeHandlerImpl extends NSObject {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Switch extends View implements SwitchDefinition {
|
export class Switch extends SwitchBase {
|
||||||
private _ios: UISwitch;
|
private _ios: UISwitch;
|
||||||
private _handler: NSObject;
|
private _handler: NSObject;
|
||||||
|
|
||||||
@ -37,8 +38,6 @@ export class Switch extends View implements SwitchDefinition {
|
|||||||
this._ios.addTargetActionForControlEvents(this._handler, "valueChanged", UIControlEvents.ValueChanged);
|
this._ios.addTargetActionForControlEvents(this._handler, "valueChanged", UIControlEvents.ValueChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
public checked: boolean;
|
|
||||||
|
|
||||||
get ios(): UISwitch {
|
get ios(): UISwitch {
|
||||||
return this._ios;
|
return this._ios;
|
||||||
}
|
}
|
||||||
@ -82,6 +81,3 @@ export class Switch extends View implements SwitchDefinition {
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const checkedProperty = new Property<Switch, boolean>({ name: "checked", defaultValue: false, valueConverter: booleanConverter });
|
|
||||||
checkedProperty.register(Switch);
|
|
Reference in New Issue
Block a user