1
- import { Color , Property , booleanConverter } from '@nativescript/core' ;
1
+ import { Color , Property , booleanConverter , Utils } from '@nativescript/core' ;
2
2
import { AnimatedCircleCommon , barColorProperty , rimColorProperty , spinBarColorProperty } from './common' ;
3
3
4
4
declare const at ;
@@ -26,7 +26,7 @@ export class AnimatedCircle extends AnimatedCircleCommon {
26
26
private _startAngle = 0 ;
27
27
private _text = '' ;
28
28
private _textColor = new Color ( 'orange' ) ;
29
- private _textSize = 8 ;
29
+ private _textSize = 0 ;
30
30
private _fillColor = new Color ( 'transparent' ) ;
31
31
private _clockwise = true ;
32
32
@@ -47,6 +47,10 @@ export class AnimatedCircle extends AnimatedCircleCommon {
47
47
this . android . setOuterContourSize ( 0 ) ;
48
48
this . android . setInnerContourSize ( 0 ) ;
49
49
this . android . setText ( this . text ) ;
50
+ this . android . setTextColor ( this . _textColor . argb ) ;
51
+ if ( this . _textSize !== 0 ) {
52
+ this . android . setTextSize ( this . _textSize ) ;
53
+ }
50
54
if ( this . animated ) {
51
55
this . android . setValueAnimated ( this . progress ) ;
52
56
} else {
@@ -80,7 +84,7 @@ export class AnimatedCircle extends AnimatedCircleCommon {
80
84
}
81
85
82
86
set progress ( value : number ) {
83
- this . _progress = value ;
87
+ this . _progress = this . getNumber ( value ) ;
84
88
if ( this . animated ) {
85
89
this . android ?. setValueAnimated ( this . _progress ) ;
86
90
} else {
@@ -226,8 +230,8 @@ export class AnimatedCircle extends AnimatedCircleCommon {
226
230
}
227
231
228
232
set textSize ( value : number ) {
229
- this . _textSize = value ;
230
- this . android ?. setTextSize ( value ) ;
233
+ this . _textSize = Utils . layout . toDevicePixels ( this . getNumber ( value ) ) ;
234
+ this . android ?. setTextSize ( this . _textSize ) ;
231
235
}
232
236
233
237
get textSize ( ) {
@@ -324,6 +328,10 @@ export class AnimatedCircle extends AnimatedCircleCommon {
324
328
this . android . setDirection ( this . clockwise ? at . grabner . circleprogress . Direction . CW : at . grabner . circleprogress . Direction . CCW ) ;
325
329
}
326
330
}
331
+
332
+ private getNumber ( value : number | string ) {
333
+ return typeof value === 'string' ? parseInt ( value ) : value
334
+ }
327
335
}
328
336
329
337
animatedProperty . register ( AnimatedCircle ) ;
0 commit comments