1
1
import { Color } from '@nativescript/core' ;
2
- import { AnimatedCircleCommon } from './common' ;
2
+ import { AnimatedCircleCommon , barColorProperty , rimColorProperty , spinBarColorProperty } from './common' ;
3
3
4
4
declare const at ;
5
5
@@ -10,16 +10,16 @@ export class AnimatedCircle extends AnimatedCircleCommon {
10
10
private _animationDuration = 1000 ;
11
11
private _animated : boolean ;
12
12
private _maxValue = 100 ;
13
- private _rimColor = '#FF5722' ;
14
- private _rimWidth = 5 ;
15
- private _spinBarColor : any ;
13
+ private _barColor = new Color ( '#3D8FF4' ) ;
16
14
private _barWidth : number ;
15
+ private _rimColor = new Color ( '#FF5722' ) ;
16
+ private _rimWidth = 5 ;
17
+ private _spinBarColor = new Color ( 'green' ) ;
17
18
private _startAngle : number ;
18
19
private _text = '' ;
19
20
private _textColor = new Color ( 'orange' ) ;
20
21
private _textSize = 8 ;
21
22
clockwise = true ;
22
- barColor = '#3D8FF4' ;
23
23
fillColor : any ;
24
24
25
25
constructor ( ) {
@@ -32,13 +32,34 @@ export class AnimatedCircle extends AnimatedCircleCommon {
32
32
33
33
initNativeView ( ) {
34
34
this . android . setAutoTextSize ( false ) ;
35
+ this . android . setBarStrokeCap ( android . graphics . Paint . Cap . ROUND ) ;
35
36
this . android . setTextMode ( at . grabner . circleprogress . TextMode . TEXT ) ;
36
- this . android . setTextScale ( 1 ) ;
37
- this . android . setTextSize ( 60 ) ;
37
+ this . android . setShowTextWhileSpinning ( true ) ;
38
+ this . android . setTextScale ( 1.1 ) ;
39
+ this . android . setTextSize ( 300 ) ;
38
40
this . android . setUnitVisible ( false ) ;
41
+ this . android . setOuterContourSize ( 0 ) ;
42
+ this . android . setInnerContourSize ( 0 ) ;
39
43
this . updateAnimatedCircle ( ) ;
40
44
}
41
45
46
+ // @ts -ignore
47
+ get android ( ) {
48
+ return this . nativeView ;
49
+ }
50
+
51
+ spin ( ) {
52
+ this . android . spin ( ) ;
53
+ }
54
+
55
+ stopSpinning ( ) {
56
+ this . android . stopSpinning ( ) ;
57
+ }
58
+
59
+ disposeNativeView ( ) {
60
+ super . disposeNativeView ( ) ;
61
+ }
62
+
42
63
set progress ( value : number ) {
43
64
this . _progress = Number ( value ) ;
44
65
this . updateAnimatedCircle ( ) ;
@@ -93,6 +114,14 @@ export class AnimatedCircle extends AnimatedCircleCommon {
93
114
return this . _rimColor ;
94
115
}
95
116
117
+ get barColor ( ) : Color {
118
+ return this . _barColor ;
119
+ }
120
+ set barColor ( value : Color ) {
121
+ this . _barColor = value ;
122
+ this . updateAnimatedCircle ( ) ;
123
+ }
124
+
96
125
set rimWidth ( value : number ) {
97
126
this . _rimWidth = Number ( value ) ;
98
127
this . updateAnimatedCircle ( ) ;
@@ -111,6 +140,33 @@ export class AnimatedCircle extends AnimatedCircleCommon {
111
140
return this . _spinBarColor ;
112
141
}
113
142
143
+ [ rimColorProperty . setNative ] ( value : any ) {
144
+ this . _rimColor = value ;
145
+ this . updateAnimatedCircle ( ) ;
146
+ }
147
+
148
+ [ rimColorProperty . getDefault ] ( ) {
149
+ return this . _rimColor ;
150
+ }
151
+
152
+ [ barColorProperty . setNative ] ( value : any ) {
153
+ this . _barColor = value ;
154
+ this . updateAnimatedCircle ( ) ;
155
+ }
156
+
157
+ [ barColorProperty . getDefault ] ( ) {
158
+ return this . _barColor ;
159
+ }
160
+
161
+ [ spinBarColorProperty . setNative ] ( value : any ) {
162
+ this . _spinBarColor = value ;
163
+ this . updateAnimatedCircle ( ) ;
164
+ }
165
+
166
+ [ spinBarColorProperty . getDefault ] ( ) {
167
+ return this . _spinBarColor ;
168
+ }
169
+
114
170
set startAngle ( value : number ) {
115
171
this . _startAngle = Number ( value ) ;
116
172
this . updateAnimatedCircle ( ) ;
@@ -192,13 +248,13 @@ export class AnimatedCircle extends AnimatedCircleCommon {
192
248
this . android . setRimWidth ( this . rimWidth ) ;
193
249
}
194
250
if ( this . barColor ) {
195
- this . android . setBarColor ( [ new Color ( this . barColor ) . argb ] ) ;
251
+ this . android . setBarColor ( [ this . barColor . argb ] ) ;
196
252
}
197
253
if ( this . fillColor ) {
198
254
this . android . setFillCircleColor ( new Color ( this . fillColor ) . argb ) ;
199
255
}
200
256
201
- this . android . setDirection ( at . grabner . circleprogress . Direction . CW ) ;
257
+ this . android . setDirection ( this . clockwise ? at . grabner . circleprogress . Direction . CW : at . grabner . circleprogress . Direction . CCW ) ;
202
258
}
203
259
}
204
260
}
0 commit comments