@@ -4,78 +4,78 @@ import {
4
4
Color ,
5
5
CssProperty ,
6
6
Property ,
7
- Style ,
7
+ Style
8
8
} from '@nativescript/core' ;
9
9
import { BoxType } from './checkbox-common' ;
10
10
import { CheckBoxInterface } from './index' ;
11
11
12
12
const checkBoxBackgroundColorProperty = new CssProperty < Style , string > ( {
13
13
name : 'checkBoxBackgroundColor' ,
14
14
cssName : 'checkbox-background-color' ,
15
- valueConverter : ( v ) => {
15
+ valueConverter : v => {
16
16
return String ( v ) ;
17
- } ,
17
+ }
18
18
} ) ;
19
19
20
20
const onCheckColorProperty = new CssProperty < Style , string > ( {
21
21
name : 'onCheckColor' ,
22
22
cssName : 'on-check-color' ,
23
23
defaultValue : '#ffffff' ,
24
- valueConverter : ( v ) => {
24
+ valueConverter : v => {
25
25
return String ( v ) ;
26
- } ,
26
+ }
27
27
} ) ;
28
28
29
29
const tintColorProperty = new CssProperty < Style , string > ( {
30
30
name : 'tintColor' ,
31
31
cssName : 'tint-color' ,
32
32
// defaultValue: "#0075ff",
33
- valueConverter : ( v ) => {
33
+ valueConverter : v => {
34
34
return String ( v ) ;
35
- } ,
35
+ }
36
36
} ) ;
37
37
38
38
const onTintColorProperty = new CssProperty < Style , string > ( {
39
39
name : 'onTintColor' ,
40
40
cssName : 'on-tint-color' ,
41
- valueConverter : ( v ) => {
41
+ valueConverter : v => {
42
42
return String ( v ) ;
43
- } ,
43
+ }
44
44
} ) ;
45
45
46
46
const fillColorProperty = new CssProperty < Style , string > ( {
47
47
name : 'fillColor' ,
48
48
cssName : 'fill-color' ,
49
- valueConverter : ( v ) => {
49
+ valueConverter : v => {
50
50
return String ( v ) ;
51
- } ,
51
+ }
52
52
} ) ;
53
53
54
54
const checkedProperty = new Property < CheckBox , boolean > ( {
55
55
name : 'checked' ,
56
56
defaultValue : false ,
57
57
valueConverter : booleanConverter ,
58
- valueChanged : onCheckedPropertyChanged ,
58
+ valueChanged : onCheckedPropertyChanged
59
59
} ) ;
60
60
61
61
const boxTypeProperty = new Property < CheckBox , BEMBoxType > ( {
62
62
name : 'boxType' ,
63
- valueConverter : ( v ) => {
63
+ valueConverter : v => {
64
64
return BoxType [ v ] === BoxType . circle
65
65
? BEMBoxType . Circle
66
66
: BEMBoxType . Square ;
67
- } ,
67
+ }
68
68
} ) ;
69
69
70
70
export class CheckBox extends Button implements CheckBoxInterface {
71
- public checked : boolean ;
72
- public boxType : number ;
73
- public _onCheckColor : string ;
74
- public _checkBoxBackgroundColor : any ;
75
- public _onTintColor : string ;
76
- public _tintColor : string ;
77
- public _onFillColor : string ;
78
- public _fillColor : string ;
71
+ checked : boolean ;
72
+ boxType : number ;
73
+ _onCheckColor : string ;
74
+ _checkBoxBackgroundColor : any ;
75
+ _onTintColor : string ;
76
+ _tintColor : string ;
77
+ _onFillColor : string ;
78
+ _fillColor : string ;
79
79
private _iosCheckbox : BEMCheckBox ;
80
80
private _delegate : BEMCheckBoxDelegateImpl ;
81
81
private _lineWidth : number = 1 ;
@@ -125,17 +125,17 @@ export class CheckBox extends Button implements CheckBoxInterface {
125
125
this . _iosCheckbox . onCheckColor = new Color ( color ) . ios ;
126
126
}
127
127
128
- public [ boxTypeProperty . setNative ] ( value : any ) {
128
+ [ boxTypeProperty . setNative ] ( value : any ) {
129
129
if ( this . _iosCheckbox ) {
130
130
this . _iosCheckbox . boxType = value ;
131
131
}
132
132
}
133
133
134
- public [ checkedProperty . getDefault ] ( ) : boolean {
134
+ [ checkedProperty . getDefault ] ( ) : boolean {
135
135
return false ;
136
136
}
137
137
138
- public [ checkedProperty . setNative ] ( value : boolean ) {
138
+ [ checkedProperty . setNative ] ( value : boolean ) {
139
139
this . _iosCheckbox . setOnAnimated ( value , true ) ;
140
140
}
141
141
@@ -173,13 +173,13 @@ export class CheckBox extends Button implements CheckBoxInterface {
173
173
return this . _iosCheckbox ;
174
174
}
175
175
176
- public reload ( value : boolean ) {
176
+ reload ( value : boolean ) {
177
177
this . _iosCheckbox . reload ( ) ;
178
178
}
179
179
180
- public initNativeView ( ) {
180
+ initNativeView ( ) {
181
181
// allow label click to change the textbox
182
- this . addEventListener ( 'tap' , ( args ) => {
182
+ this . addEventListener ( 'tap' , args => {
183
183
const checkbox = args . object as CheckBox ;
184
184
checkbox . checked = ! checkbox . checked ;
185
185
} ) ;
@@ -248,12 +248,12 @@ export class CheckBox extends Button implements CheckBoxInterface {
248
248
}
249
249
}
250
250
251
- public disposeNativeView ( ) {
251
+ disposeNativeView ( ) {
252
252
this . _iosCheckbox . delegate = null ;
253
253
this . removeEventListener ( 'tap' ) ;
254
254
}
255
255
256
- public toggle ( ) {
256
+ toggle ( ) {
257
257
this . checked = ! this . checked ;
258
258
}
259
259
@@ -276,35 +276,35 @@ export class CheckBox extends Button implements CheckBoxInterface {
276
276
}
277
277
}
278
278
279
- public _onCheckedPropertyChanged ( checkbox : CheckBox , oldValue , newValue ) {
279
+ _onCheckedPropertyChanged ( checkbox : CheckBox , oldValue , newValue ) {
280
280
if ( ! this . nativeView ) {
281
281
return ;
282
282
}
283
283
checkedProperty . nativeValueChange ( this , newValue ) ;
284
284
}
285
285
}
286
286
287
+ @NativeClass ( )
287
288
class BEMCheckBoxDelegateImpl extends NSObject implements BEMCheckBoxDelegate {
288
- public static ObjCProtocols = [ BEMCheckBoxDelegate ] ;
289
- /*public static ObjCExposedMethods = {
290
- "didTapCheckBox": { returns: interop.types.void, params: [NSObject] }
291
- };*/
289
+ static ObjCProtocols = [ BEMCheckBoxDelegate ] ;
292
290
293
291
private _owner : WeakRef < CheckBox > ;
294
292
295
- public static initWithOwner (
296
- owner : WeakRef < CheckBox >
297
- ) : BEMCheckBoxDelegateImpl {
293
+ /* static ObjCExposedMethods = {
294
+ "didTapCheckBox": { returns: interop.types.void, params: [NSObject] }
295
+ };*/
296
+
297
+ static initWithOwner ( owner : WeakRef < CheckBox > ) : BEMCheckBoxDelegateImpl {
298
298
const delegate = < BEMCheckBoxDelegateImpl > BEMCheckBoxDelegateImpl . new ( ) ;
299
299
delegate . _owner = owner ;
300
300
return delegate ;
301
301
}
302
302
303
- public animationDidStopForCheckBox ( checkBox : BEMCheckBox ) : void {
303
+ animationDidStopForCheckBox ( checkBox : BEMCheckBox ) : void {
304
304
// TODO: Maybe trigger event later?
305
305
}
306
306
307
- public didTapCheckBox ( checkBox : BEMCheckBox ) : void {
307
+ didTapCheckBox ( checkBox : BEMCheckBox ) : void {
308
308
const owner = this . _owner . get ( ) ;
309
309
if ( owner ) {
310
310
checkedProperty . nativeValueChange ( owner , checkBox . on ) ;
0 commit comments