Fixed Switch

This commit is contained in:
Rossen Hristov
2016-12-22 16:50:45 +02:00
parent a276db4c38
commit f303a74570
3 changed files with 23 additions and 19 deletions

View File

@ -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);

View File

@ -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;
@ -68,7 +69,4 @@ export class Switch extends View implements SwitchDefinition {
set [backgroundInternalProperty.native](value: any) { set [backgroundInternalProperty.native](value: any) {
// //
} }
} }
export const checkedProperty = new Property<Switch, boolean>({ name: "checked", defaultValue: false, valueConverter: booleanConverter });
checkedProperty.register(Switch);

View File

@ -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;
} }
@ -81,7 +80,4 @@ export class Switch extends View implements SwitchDefinition {
set [backgroundInternalProperty.native](value: any) { set [backgroundInternalProperty.native](value: any) {
// //
} }
} }
export const checkedProperty = new Property<Switch, boolean>({ name: "checked", defaultValue: false, valueConverter: booleanConverter });
checkedProperty.register(Switch);