Skip to content

Commit 581c9c4

Browse files
authored
fix(animated-circle): android text size and color change (#584)
1 parent 913cb46 commit 581c9c4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

packages/animated-circle/index.android.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Color, Property, booleanConverter } from '@nativescript/core';
1+
import { Color, Property, booleanConverter, Utils } from '@nativescript/core';
22
import { AnimatedCircleCommon, barColorProperty, rimColorProperty, spinBarColorProperty } from './common';
33

44
declare const at;
@@ -26,7 +26,7 @@ export class AnimatedCircle extends AnimatedCircleCommon {
2626
private _startAngle = 0;
2727
private _text = '';
2828
private _textColor = new Color('orange');
29-
private _textSize = 8;
29+
private _textSize = 0;
3030
private _fillColor = new Color('transparent');
3131
private _clockwise = true;
3232

@@ -47,6 +47,10 @@ export class AnimatedCircle extends AnimatedCircleCommon {
4747
this.android.setOuterContourSize(0);
4848
this.android.setInnerContourSize(0);
4949
this.android.setText(this.text);
50+
this.android.setTextColor(this._textColor.argb);
51+
if(this._textSize !== 0){
52+
this.android.setTextSize(this._textSize);
53+
}
5054
if (this.animated) {
5155
this.android.setValueAnimated(this.progress);
5256
} else {
@@ -80,7 +84,7 @@ export class AnimatedCircle extends AnimatedCircleCommon {
8084
}
8185

8286
set progress(value: number) {
83-
this._progress = value;
87+
this._progress = this.getNumber(value);
8488
if (this.animated) {
8589
this.android?.setValueAnimated(this._progress);
8690
} else {
@@ -226,8 +230,8 @@ export class AnimatedCircle extends AnimatedCircleCommon {
226230
}
227231

228232
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);
231235
}
232236

233237
get textSize() {
@@ -324,6 +328,10 @@ export class AnimatedCircle extends AnimatedCircleCommon {
324328
this.android.setDirection(this.clockwise ? at.grabner.circleprogress.Direction.CW : at.grabner.circleprogress.Direction.CCW);
325329
}
326330
}
331+
332+
private getNumber(value: number | string){
333+
return typeof value === 'string' ? parseInt(value) : value
334+
}
327335
}
328336

329337
animatedProperty.register(AnimatedCircle);

0 commit comments

Comments
 (0)