Skip to content

Commit b358a27

Browse files
committed
Boxtype fix [IOS]
1 parent 6489448 commit b358a27

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

checkbox.ios.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ const checkedProperty = new Property<CheckBox, boolean>({
5757
valueChanged: onCheckedPropertyChanged
5858
});
5959

60+
const boxTypeProperty = new Property<CheckBox, number>({
61+
name: "boxType",
62+
valueConverter: v => {
63+
return parseInt(v, 10);
64+
}
65+
});
66+
6067
export class CheckBox extends Button implements CheckBoxInterface {
6168
_onCheckColor: string;
6269
_checkBoxBackgroundColor: any;
@@ -74,7 +81,7 @@ export class CheckBox extends Button implements CheckBoxInterface {
7481
private _onAnimationType: number;
7582
private _offAnimationType: number;
7683
public checked: boolean;
77-
84+
public boxType: number;
7885
constructor() {
7986
super();
8087
// just create with any width/height as XML view width/height is undefined at this point
@@ -114,6 +121,18 @@ export class CheckBox extends Button implements CheckBoxInterface {
114121
this._iosCheckbox.onCheckColor = new Color(color).ios;
115122
}
116123

124+
[boxTypeProperty.getDefault](): number {
125+
return 1;
126+
}
127+
128+
[boxTypeProperty.setNative](value: number) {
129+
let type = BEMBoxType.Circle;
130+
if (value === 2) {
131+
type = BEMBoxType.Square;
132+
}
133+
this._iosCheckbox.boxType = type;
134+
}
135+
117136
[checkedProperty.getDefault](): boolean {
118137
return false;
119138
}
@@ -136,15 +155,6 @@ export class CheckBox extends Button implements CheckBoxInterface {
136155
this._hideBox = value;
137156
}
138157

139-
set boxType(value: number) {
140-
let type = BEMBoxType.Circle;
141-
if (value === 2) {
142-
type = BEMBoxType.Square;
143-
}
144-
if (this._iosCheckbox) this._iosCheckbox.boxType = type;
145-
else this._boxType = value;
146-
}
147-
148158
set animationDuration(value: number) {
149159
this._iosCheckbox.animationDuration = value;
150160
this._animationDuration = value;
@@ -306,7 +316,7 @@ class BEMCheckBoxDelegateImpl extends NSObject implements BEMCheckBoxDelegate {
306316
function onCheckedPropertyChanged(checkbox: CheckBox, oldValue, newValue) {
307317
checkbox._onCheckedPropertyChanged(checkbox, oldValue, newValue);
308318
}
309-
319+
boxTypeProperty.register(CheckBox);
310320
checkedProperty.register(CheckBox);
311321
fillColorProperty.register(Style);
312322
onTintColorProperty.register(Style);

demo-ng/app/item/items.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<StackLayout *tabItem="{title: 'Checkboxes'}">
88
<StackLayout class="page">
99
<StackLayout orientation="horizontal" class="p-10">
10-
<CheckBox #modelCheck [(ngModel)]="checkTest" class="checkbox" (checkedChange)="checkedChange(modelCheck)"></CheckBox>
10+
<CheckBox #modelCheck [(ngModel)]="checkTest" class="checkbox" boxType="2" (checkedChange)="checkedChange(modelCheck)"></CheckBox>
1111
<Label text="Test NgModel" (tap)="modelCheck.toggle()"></Label>
1212
</StackLayout>
1313
<StackLayout class="form-group" [formGroup]="formGroup" orientation="horizontal" class="p-10">
14-
<CheckBox #reactiveCheck class="checkbox" formControlName="testCheck" class="checkbox"></CheckBox>
14+
<CheckBox #reactiveCheck class="checkbox" formControlName="testCheck" boxType="2" class="checkbox"></CheckBox>
1515
<Label text="Test Reactive FormGroup" (tap)="reactiveCheck.toggle()"></Label>
1616
</StackLayout>
1717

0 commit comments

Comments
 (0)