mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +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 { View, Color, Property, colorProperty, backgroundColorProperty, backgroundInternalProperty, booleanConverter } from "ui/core/view";
|
||||
import {
|
||||
SwitchBase, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, checkedProperty
|
||||
} from "./switch-common";
|
||||
|
||||
export * from "ui/core/view";
|
||||
export * from "./switch-common";
|
||||
|
||||
@Interfaces([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 listener: android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
public checked: boolean;
|
||||
@ -68,7 +69,4 @@ export class Switch extends View implements SwitchDefinition {
|
||||
set [backgroundInternalProperty.native](value: any) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
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 { View, layout, Color, Property, colorProperty, backgroundColorProperty, backgroundInternalProperty, booleanConverter } from "ui/core/view";
|
||||
import {
|
||||
SwitchBase, layout, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, checkedProperty
|
||||
} from "./switch-common";
|
||||
|
||||
export * from "ui/core/view";
|
||||
export * from "./switch-common";
|
||||
|
||||
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 _handler: NSObject;
|
||||
|
||||
@ -37,8 +38,6 @@ export class Switch extends View implements SwitchDefinition {
|
||||
this._ios.addTargetActionForControlEvents(this._handler, "valueChanged", UIControlEvents.ValueChanged);
|
||||
}
|
||||
|
||||
public checked: boolean;
|
||||
|
||||
get ios(): UISwitch {
|
||||
return this._ios;
|
||||
}
|
||||
@ -81,7 +80,4 @@ export class Switch extends View implements SwitchDefinition {
|
||||
set [backgroundInternalProperty.native](value: any) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
export const checkedProperty = new Property<Switch, boolean>({ name: "checked", defaultValue: false, valueConverter: booleanConverter });
|
||||
checkedProperty.register(Switch);
|
||||
}
|
Reference in New Issue
Block a user