-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathanimated-circle.android.ts
More file actions
217 lines (179 loc) · 5.46 KB
/
animated-circle.android.ts
File metadata and controls
217 lines (179 loc) · 5.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// @ts-nocheck
import { Common } from './animated-circle.common';
import { Color } from '@nativescript/core/color';
declare const at;
export class AnimatedCircle extends Common {
private _android: any;
private _progress: number;
private _animateFrom: number;
private _animationDuration = 1000;
private _animated: boolean;
private _maxValue = 100;
private _rimColor = '#FF5722';
private _rimWidth = 5;
private _spinBarColor: any;
private _barWidth: number;
private _startAngle: number;
private _text = '';
private _textColor = new Color('orange');
private _textSize = 28 * 10;
clockwise = true;
barColor = '#3D8FF4';
fillColor: any;
constructor() {
super();
}
createNativeView() {
return new at.grabner.circleprogress.CircleProgressView(this._context, null);
}
initNativeView() {
this.android.setAutoTextSize(false);
this.android.setTextMode(at.grabner.circleprogress.TextMode.TEXT);
this.android.setTextScale(1.1);
this.android.setTextSize(300);
this.android.setUnitVisible(false);
this.updateAnimatedCircle();
}
get android() {
return this.nativeView;
}
set progress(value: number) {
this._progress = Number(value);
this.updateAnimatedCircle();
}
get progress(): number {
return this._progress;
}
set animateFrom(value: number) {
this._animateFrom = Number(value);
this.updateAnimatedCircle();
}
get animateFrom(): number {
return this._animateFrom;
}
set animationDuration(value: number) {
this._animationDuration = Number(value);
this.updateAnimatedCircle();
}
get animationDuration(): number {
return this._animationDuration;
}
set animated(value: boolean) {
this._animated = Boolean(value);
this.updateAnimatedCircle();
}
get animated(): boolean {
return this._animated;
}
set maxValue(value: number) {
this._maxValue = Number(value);
this.updateAnimatedCircle();
}
get maxValue(): number {
return this._maxValue;
}
set rimColor(value: any) {
this._rimColor = value;
this.updateAnimatedCircle();
}
get rimColor() {
return this._rimColor;
}
set rimWidth(value: number) {
this._rimWidth = Number(value);
this.updateAnimatedCircle();
}
get rimWidth() {
return this._rimWidth;
}
set spinBarColor(value: any) {
this._spinBarColor = value;
this.updateAnimatedCircle();
}
get spinBarColor() {
return this._spinBarColor;
}
set startAngle(value: number) {
this._startAngle = Number(value);
this.updateAnimatedCircle();
}
get startAngle() {
return this._startAngle;
}
set barWidth(value: number) {
this._barWidth = Number(value);
this.updateAnimatedCircle();
}
get barWidth() {
return this._barWidth;
}
set text(value: string) {
this._text = value;
this.updateAnimatedCircle();
}
get text() {
return this.android.getText();
}
set textColor(value: string) {
this._textColor = new Color(value);
this.updateAnimatedCircle();
}
set textSize(value: number) {
this._textSize = value * 10;
this.updateAnimatedCircle();
}
get textSize() {
return this.android.getTextSize();
}
private updateAnimatedCircle(): void {
if (this.android) {
this.android.setText(this._text);
this.android.setTextColor(this._textColor.argb);
this.android.setTextSize(this._textSize);
if (this.animated) {
if (this.animateFrom) {
this.android.setValueAnimated(this.animateFrom, this.progress, this.animationDuration);
}
else {
if (!this._animationDuration) {
this.android.setValueAnimated(this.progress);
}
else {
this.android.setValueAnimated(this.progress, this.animationDuration);
}
}
}
else {
this.android.setValue(this.progress);
}
this.android.setMaxValue(this.maxValue);
if (this.rimColor) {
this.android.setRimColor(new Color(this.rimColor).argb);
}
if (this.spinBarColor) {
this.android.setSpinBarColor(new Color(this.spinBarColor).argb);
}
if (this.startAngle) {
this.android.setStartAngle(this.startAngle);
}
if (this.barWidth) {
this.android.setBarWidth(this.barWidth);
} else {
if (this.rimWidth) {
// set rim width to bar width if no bar width provided
this.android.setBarWidth(this.rimWidth);
}
}
if (this.rimWidth) {
this.android.setRimWidth(this.rimWidth);
}
if (this.barColor) {
this.android.setBarColor([new Color(this.barColor).argb]);
}
if (this.fillColor) {
this.android.setFillCircleColor(new Color(this.fillColor).argb);
}
this.android.setDirection(this.clockwise ? at.grabner.circleprogress.Direction.CW : at.grabner.circleprogress.Direction.CCW);
}
}
}