@@ -5,22 +5,22 @@ declare const at;
5
5
6
6
export class AnimatedCircle extends AnimatedCircleCommon {
7
7
private _android : any ;
8
- private _progress : number ;
9
- private _animateFrom : number ;
8
+ private _progress = 0 ;
9
+ private _animateFrom = 0 ;
10
10
private _animationDuration = 1000 ;
11
11
private _animated : boolean ;
12
12
private _maxValue = 100 ;
13
13
private _barColor = new Color ( '#3D8FF4' ) ;
14
- private _barWidth : number ;
14
+ private _barWidth ;
15
15
private _rimColor = new Color ( '#FF5722' ) ;
16
- private _rimWidth = 5 ;
16
+ private _rimWidth ;
17
17
private _spinBarColor = new Color ( 'green' ) ;
18
- private _startAngle : number ;
18
+ private _startAngle : number = 0 ;
19
19
private _text = '' ;
20
20
private _textColor = new Color ( 'orange' ) ;
21
21
private _textSize = 8 ;
22
- private _fillColor : Color ;
23
- clockwise = true ;
22
+ private _fillColor = new Color ( 'transparent' ) ;
23
+ private _clockwise = true ;
24
24
25
25
constructor ( ) {
26
26
super ( ) ;
@@ -31,15 +31,22 @@ export class AnimatedCircle extends AnimatedCircleCommon {
31
31
}
32
32
33
33
initNativeView ( ) {
34
- this . android . setAutoTextSize ( false ) ;
34
+ this . android . setAutoTextSize ( true ) ;
35
35
this . android . setBarStrokeCap ( android . graphics . Paint . Cap . ROUND ) ;
36
36
this . android . setTextMode ( at . grabner . circleprogress . TextMode . TEXT ) ;
37
37
this . android . setShowTextWhileSpinning ( true ) ;
38
- this . android . setTextScale ( 1.1 ) ;
39
- this . android . setTextSize ( 300 ) ;
40
38
this . android . setUnitVisible ( false ) ;
41
39
this . android . setOuterContourSize ( 0 ) ;
42
40
this . android . setInnerContourSize ( 0 ) ;
41
+ this . android . setText ( this . text ) ;
42
+ this . android . setValueAnimated ( this . progress ) ;
43
+ this . android . setDirection ( this . clockwise ? at . grabner . circleprogress . Direction . CW : at . grabner . circleprogress . Direction . CCW ) ;
44
+ this . android . setRimWidth ( this . rimWidth ) ;
45
+ this . android . setBarWidth ( this . barWidth ) ;
46
+ if ( this . rimWidth ) {
47
+ // set rim width to bar width if no bar width provided
48
+ this . android . setBarWidth ( this . rimWidth ) ;
49
+ }
43
50
this . updateAnimatedCircle ( ) ;
44
51
}
45
52
@@ -61,8 +68,8 @@ export class AnimatedCircle extends AnimatedCircleCommon {
61
68
}
62
69
63
70
set progress ( value : number ) {
64
- this . _progress = Number ( value ) ;
65
- this . updateAnimatedCircle ( ) ;
71
+ this . _progress = value ;
72
+ this . android ?. setValueAnimated ( this . _progress ) ;
66
73
}
67
74
68
75
get progress ( ) : number {
@@ -97,8 +104,8 @@ export class AnimatedCircle extends AnimatedCircleCommon {
97
104
}
98
105
99
106
set maxValue ( value : number ) {
100
- this . _maxValue = Number ( value ) ;
101
- this . updateAnimatedCircle ( ) ;
107
+ this . _maxValue = value ;
108
+ this . android ?. setMaxValue ( this . maxValue ) ;
102
109
}
103
110
104
111
get maxValue ( ) : number {
@@ -108,9 +115,9 @@ export class AnimatedCircle extends AnimatedCircleCommon {
108
115
set rimColor ( value : any ) {
109
116
this . _rimColor = value ;
110
117
if ( value instanceof Color ) {
111
- this . android . setRimColor ( value . argb ) ;
118
+ this . android ? .setRimColor ( value . argb ) ;
112
119
} else {
113
- this . android . setRimColor ( new Color ( value ) . argb ) ;
120
+ this . android ? .setRimColor ( new Color ( value ) . argb ) ;
114
121
}
115
122
}
116
123
@@ -124,15 +131,15 @@ export class AnimatedCircle extends AnimatedCircleCommon {
124
131
set barColor ( value : Color ) {
125
132
this . _barColor = value ;
126
133
if ( value instanceof Color ) {
127
- this . android . setBarColor ( [ value . argb ] ) ;
134
+ this . android ? .setBarColor ( [ value . argb ] ) ;
128
135
} else {
129
- this . android . setBarColor ( [ new Color ( value ) . argb ] ) ;
136
+ this . android ? .setBarColor ( [ new Color ( value ) . argb ] ) ;
130
137
}
131
138
}
132
139
133
140
set rimWidth ( value : number ) {
134
141
this . _rimWidth = Number ( value ) ;
135
- this . updateAnimatedCircle ( ) ;
142
+ this . android ?. setRimWidth ( this . _rimWidth ) ;
136
143
}
137
144
138
145
get rimWidth ( ) {
@@ -166,17 +173,24 @@ export class AnimatedCircle extends AnimatedCircleCommon {
166
173
}
167
174
168
175
set startAngle ( value : number ) {
169
- this . _startAngle = Number ( value ) ;
170
- this . updateAnimatedCircle ( ) ;
176
+ this . _startAngle = value ;
177
+ this . android ?. setStartAngle ( this . _startAngle ) ;
171
178
}
172
179
173
180
get startAngle ( ) {
174
181
return this . _startAngle ;
175
182
}
176
183
177
184
set barWidth ( value : number ) {
178
- this . _barWidth = Number ( value ) ;
179
- this . updateAnimatedCircle ( ) ;
185
+ this . _barWidth = value ;
186
+ if ( this . _barWidth ) {
187
+ this . android ?. setBarWidth ( this . _barWidth ) ;
188
+ } else {
189
+ if ( this . _rimWidth ) {
190
+ // set rim width to bar width if no bar width provided
191
+ this . android ?. setBarWidth ( this . _rimWidth ) ;
192
+ }
193
+ }
180
194
}
181
195
182
196
get barWidth ( ) {
@@ -185,11 +199,11 @@ export class AnimatedCircle extends AnimatedCircleCommon {
185
199
186
200
set text ( value : string ) {
187
201
this . _text = value ;
188
- this . updateAnimatedCircle ( ) ;
202
+ this . android ?. setText ( this . _text ) ;
189
203
}
190
204
191
205
get text ( ) {
192
- return this . android . getText ( ) ;
206
+ return this . _text ;
193
207
}
194
208
195
209
set textColor ( value : string ) {
@@ -206,6 +220,14 @@ export class AnimatedCircle extends AnimatedCircleCommon {
206
220
return this . android . getTextSize ( ) ;
207
221
}
208
222
223
+ set clockwise ( value : boolean ) {
224
+ this . _clockwise = value ;
225
+ this . android ?. setDirection ( value === true ? at . grabner . circleprogress . Direction . CW : at . grabner . circleprogress . Direction . CCW ) ;
226
+ }
227
+
228
+ get clockwise ( ) {
229
+ return this . _clockwise ;
230
+ }
209
231
// CSS Properties
210
232
211
233
[ rimColorProperty . setNative ] ( value : any ) {
@@ -249,7 +271,6 @@ export class AnimatedCircle extends AnimatedCircleCommon {
249
271
250
272
private updateAnimatedCircle ( ) : void {
251
273
if ( this . android ) {
252
- this . android . setText ( this . _text ) ;
253
274
if ( this . animated ) {
254
275
if ( this . animateFrom ) {
255
276
this . android . setValueAnimated ( this . animateFrom , this . progress , this . animationDuration ) ;
@@ -263,24 +284,6 @@ export class AnimatedCircle extends AnimatedCircleCommon {
263
284
} else {
264
285
this . android . setValue ( this . progress ) ;
265
286
}
266
- this . android . setMaxValue ( this . maxValue ) ;
267
-
268
- if ( this . startAngle ) {
269
- this . android . setStartAngle ( this . startAngle ) ;
270
- }
271
- if ( this . barWidth ) {
272
- this . android . setBarWidth ( this . barWidth ) ;
273
- } else {
274
- if ( this . rimWidth ) {
275
- // set rim width to bar width if no bar width provided
276
- this . android . setBarWidth ( this . rimWidth ) ;
277
- }
278
- }
279
- if ( this . rimWidth ) {
280
- this . android . setRimWidth ( this . rimWidth ) ;
281
- }
282
-
283
- this . android . setDirection ( this . clockwise ? at . grabner . circleprogress . Direction . CW : at . grabner . circleprogress . Direction . CCW ) ;
284
287
}
285
288
}
286
289
}
0 commit comments