@@ -76,7 +76,7 @@ export class CheckBox extends Button implements CheckBoxInterface {
76
76
_tintColor : string ;
77
77
_onFillColor : string ;
78
78
_fillColor : string ;
79
- nativeViewProtected : BEMCheckBox ;
79
+ _iosCheckbox : BEMCheckBox ;
80
80
private _delegate : BEMCheckBoxDelegateImpl ;
81
81
private _lineWidth : number = 1 ;
82
82
private _hideBox : boolean ;
@@ -87,44 +87,47 @@ export class CheckBox extends Button implements CheckBoxInterface {
87
87
private _offAnimationType : number ;
88
88
89
89
createNativeView ( ) {
90
- return BEMCheckBox . alloc ( ) . initWithFrame (
90
+ const view = super . createNativeView ( ) as UIButton ;
91
+ this . _iosCheckbox = BEMCheckBox . alloc ( ) . initWithFrame (
91
92
CGRectMake ( 0 , 0 , 80 , 80 )
92
93
) as BEMCheckBox ;
94
+ view . addSubview ( this . _iosCheckbox ) ;
95
+ return view ;
93
96
}
94
97
95
98
set fillColor ( color : string ) {
96
99
this . _fillColor = color ;
97
- this . nativeViewProtected . onFillColor = new Color ( color ) . ios ;
100
+ this . _iosCheckbox . onFillColor = new Color ( color ) . ios ;
98
101
}
99
102
100
103
set onFillColor ( color : string ) {
101
104
this . _onFillColor = color ;
102
- this . nativeViewProtected . onFillColor = new Color ( color ) . ios ;
105
+ this . _iosCheckbox . onFillColor = new Color ( color ) . ios ;
103
106
}
104
107
105
108
set tintColor ( color : string ) {
106
109
this . _tintColor = color ;
107
- this . nativeViewProtected . tintColor = new Color ( color ) . ios ;
110
+ this . _iosCheckbox . tintColor = new Color ( color ) . ios ;
108
111
}
109
112
110
113
set onTintColor ( color : string ) {
111
114
this . _onTintColor = color ;
112
- this . nativeViewProtected . onTintColor = new Color ( color ) . ios ;
115
+ this . _iosCheckbox . onTintColor = new Color ( color ) . ios ;
113
116
}
114
117
115
118
set checkBoxBackgroundColor ( color : any ) {
116
119
this . _checkBoxBackgroundColor = color ;
117
- this . nativeViewProtected . offFillColor = new Color ( color ) . ios ;
120
+ this . _iosCheckbox . offFillColor = new Color ( color ) . ios ;
118
121
}
119
122
120
123
set onCheckColor ( color : string ) {
121
124
this . _onCheckColor = color ;
122
- this . nativeViewProtected . onCheckColor = new Color ( color ) . ios ;
125
+ this . _iosCheckbox . onCheckColor = new Color ( color ) . ios ;
123
126
}
124
127
125
128
[ boxTypeProperty . setNative ] ( value : any ) {
126
129
if ( this . nativeViewProtected ) {
127
- this . nativeViewProtected . boxType = value ;
130
+ this . _iosCheckbox . boxType = value ;
128
131
}
129
132
}
130
133
@@ -133,45 +136,45 @@ export class CheckBox extends Button implements CheckBoxInterface {
133
136
}
134
137
135
138
[ checkedProperty . setNative ] ( value : boolean ) {
136
- this . nativeViewProtected . setOnAnimated ( value , true ) ;
139
+ this . _iosCheckbox . setOnAnimated ( value , true ) ;
137
140
}
138
141
139
142
set checkedAnimated ( value : boolean ) {
140
- this . nativeViewProtected . setOnAnimated ( value , true ) ;
143
+ this . _iosCheckbox . setOnAnimated ( value , true ) ;
141
144
}
142
145
143
146
set lineWidth ( value : number ) {
144
- this . nativeViewProtected . lineWidth = value ;
147
+ this . _iosCheckbox . lineWidth = value ;
145
148
this . _lineWidth = value ;
146
149
}
147
150
148
151
set hideBox ( value : boolean ) {
149
- this . nativeViewProtected . hideBox = value ;
152
+ this . _iosCheckbox . hideBox = value ;
150
153
this . _hideBox = value ;
151
154
}
152
155
153
156
set animationDuration ( value : number ) {
154
- this . nativeViewProtected . animationDuration = value ;
157
+ this . _iosCheckbox . animationDuration = value ;
155
158
this . _animationDuration = value ;
156
159
}
157
160
158
161
set onAnimationType ( value : number ) {
159
- if ( this . nativeViewProtected )
160
- this . nativeViewProtected . onAnimationType = this . _getAnimationType ( value ) ;
162
+ if ( this . _iosCheckbox )
163
+ this . _iosCheckbox . onAnimationType = this . _getAnimationType ( value ) ;
161
164
else this . _onAnimationType = value ;
162
165
}
163
166
164
167
set offAnimationType ( value : number ) {
165
- this . nativeViewProtected . offAnimationType = this . _getAnimationType ( value ) ;
168
+ this . _iosCheckbox . offAnimationType = this . _getAnimationType ( value ) ;
166
169
this . _offAnimationType = value ;
167
170
}
168
171
169
172
get nativeiOSCheckBox ( ) {
170
- return this . nativeViewProtected ;
173
+ return this . _iosCheckbox ;
171
174
}
172
175
173
176
reload ( value : boolean ) {
174
- this . nativeViewProtected . reload ( ) ;
177
+ this . _iosCheckbox . reload ( ) ;
175
178
}
176
179
tapTimeout
177
180
initNativeView ( ) {
@@ -197,37 +200,36 @@ export class CheckBox extends Button implements CheckBoxInterface {
197
200
fontSize = this . style . fontSize ;
198
201
}
199
202
200
- this . nativeViewProtected . delegate = this . _delegate ;
203
+ this . _iosCheckbox . delegate = this . _delegate ;
201
204
// positioning
202
- this . nativeViewProtected . frame = CGRectMake ( 0 , 0 , fontSize , fontSize ) ;
203
- this . nativeViewProtected . center = CGPointMake (
204
- this . nativeViewProtected . center . x ,
205
+ this . _iosCheckbox . frame = CGRectMake ( 0 , 0 , fontSize , fontSize ) ;
206
+ this . _iosCheckbox . center = CGPointMake (
207
+ this . _iosCheckbox . center . x ,
205
208
fontSize / 2 + 3
206
209
) ;
207
210
this . style . paddingLeft = fontSize + ( fontSize > 20 ? 10 : 5 ) ;
208
211
this . style . textAlignment = 'left' ;
209
212
210
213
if ( this . _onCheckColor ) {
211
- this . nativeViewProtected . onCheckColor = new Color ( this . _onCheckColor ) . ios ;
214
+ this . _iosCheckbox . onCheckColor = new Color ( this . _onCheckColor ) . ios ;
212
215
}
213
216
214
217
if ( this . _onFillColor ) {
215
- this . nativeViewProtected . onFillColor = new Color ( this . _onFillColor ) . ios ;
218
+ this . _iosCheckbox . onFillColor = new Color ( this . _onFillColor ) . ios ;
216
219
}
217
220
218
221
if ( this . _onTintColor ) {
219
- this . nativeViewProtected . onTintColor = new Color ( this . _onTintColor ) . ios ;
222
+ this . _iosCheckbox . onTintColor = new Color ( this . _onTintColor ) . ios ;
220
223
}
221
224
222
225
if ( this . _fillColor ) {
223
- this . nativeViewProtected . onFillColor = new Color ( this . _fillColor ) . ios ;
226
+ this . _iosCheckbox . onFillColor = new Color ( this . _fillColor ) . ios ;
224
227
}
225
228
226
229
if ( this . _tintColor ) {
227
- this . nativeViewProtected . tintColor = new Color ( this . _tintColor ) . ios ;
230
+ this . _iosCheckbox . tintColor = new Color ( this . _tintColor ) . ios ;
228
231
}
229
232
230
- this . nativeView . addSubview ( this . nativeViewProtected ) ;
231
233
232
234
if ( typeof this . _lineWidth !== 'undefined' ) {
233
235
this . lineWidth = this . _lineWidth ;
@@ -250,7 +252,8 @@ export class CheckBox extends Button implements CheckBoxInterface {
250
252
}
251
253
252
254
disposeNativeView ( ) {
253
- this . nativeViewProtected . delegate = null ;
255
+ this . _iosCheckbox . delegate = null ;
256
+ this . _iosCheckbox = null ;
254
257
this . removeEventListener ( 'tap' ) ;
255
258
}
256
259
@@ -278,7 +281,7 @@ export class CheckBox extends Button implements CheckBoxInterface {
278
281
}
279
282
280
283
_onCheckedPropertyChanged ( checkbox : CheckBox , oldValue , newValue ) {
281
- if ( ! this . nativeView ) {
284
+ if ( ! this . _iosCheckbox ) {
282
285
return ;
283
286
}
284
287
checkedProperty . nativeValueChange ( this , newValue ) ;
0 commit comments