@@ -57,6 +57,13 @@ const checkedProperty = new Property<CheckBox, boolean>({
57
57
valueChanged : onCheckedPropertyChanged
58
58
} ) ;
59
59
60
+ const boxTypeProperty = new Property < CheckBox , number > ( {
61
+ name : "boxType" ,
62
+ valueConverter : v => {
63
+ return parseInt ( v , 10 ) ;
64
+ }
65
+ } ) ;
66
+
60
67
export class CheckBox extends Button implements CheckBoxInterface {
61
68
_onCheckColor : string ;
62
69
_checkBoxBackgroundColor : any ;
@@ -74,7 +81,7 @@ export class CheckBox extends Button implements CheckBoxInterface {
74
81
private _onAnimationType : number ;
75
82
private _offAnimationType : number ;
76
83
public checked : boolean ;
77
-
84
+ public boxType : number ;
78
85
constructor ( ) {
79
86
super ( ) ;
80
87
// 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 {
114
121
this . _iosCheckbox . onCheckColor = new Color ( color ) . ios ;
115
122
}
116
123
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
+
117
136
[ checkedProperty . getDefault ] ( ) : boolean {
118
137
return false ;
119
138
}
@@ -136,15 +155,6 @@ export class CheckBox extends Button implements CheckBoxInterface {
136
155
this . _hideBox = value ;
137
156
}
138
157
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
-
148
158
set animationDuration ( value : number ) {
149
159
this . _iosCheckbox . animationDuration = value ;
150
160
this . _animationDuration = value ;
@@ -306,7 +316,7 @@ class BEMCheckBoxDelegateImpl extends NSObject implements BEMCheckBoxDelegate {
306
316
function onCheckedPropertyChanged ( checkbox : CheckBox , oldValue , newValue ) {
307
317
checkbox . _onCheckedPropertyChanged ( checkbox , oldValue , newValue ) ;
308
318
}
309
-
319
+ boxTypeProperty . register ( CheckBox ) ;
310
320
checkedProperty . register ( CheckBox ) ;
311
321
fillColorProperty . register ( Style ) ;
312
322
onTintColorProperty . register ( Style ) ;
0 commit comments