Skip to content

Commit 46a561c

Browse files
committed
WIP
1 parent e14114a commit 46a561c

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

packages/animated-circle/common.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import { Color, ContentView, InheritedCssProperty, Style } from '@nativescript/core';
22

3+
export const rimWidthProperty = new InheritedCssProperty<Style, Number>({
4+
name: 'rimWidth',
5+
cssName: 'rim-width',
6+
});
7+
8+
export const barWidthProperty = new InheritedCssProperty<Style, Number>({
9+
name: 'barWidth',
10+
cssName: 'bar-width',
11+
});
12+
313
export const spinBarColorProperty = new InheritedCssProperty<Style, Color>({
414
name: 'spinBarColor',
515
cssName: 'spin-bar-color',
@@ -30,6 +40,8 @@ export class AnimatedCircleCommon extends ContentView {
3040
// register after class definition or we'll get an exception according to
3141
// https://docs.nativescript.org/core-concepts/properties#registering-the-property
3242

43+
rimWidthProperty.register(Style);
44+
barWidthProperty.register(Style);
3345
// defines 'spinBarColor' property on Style class
3446
spinBarColorProperty.register(Style);
3547
// defines 'rimColor' property on Style class

packages/animated-circle/index.android.ts

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Color } from '@nativescript/core';
2-
import { AnimatedCircleCommon, barColorProperty, rimColorProperty, spinBarColorProperty } from './common';
2+
import { AnimatedCircleCommon, barColorProperty, barWidthProperty, rimColorProperty, rimWidthProperty, spinBarColorProperty } from './common';
33

44
declare const at;
55

@@ -68,8 +68,8 @@ export class AnimatedCircle extends AnimatedCircleCommon {
6868
}
6969

7070
set progress(value: number) {
71-
this._progress = value;
72-
this.android?.setValueAnimated(this._progress);
71+
this._progress = Number(value);
72+
this.updateAnimatedCircle();
7373
}
7474

7575
get progress(): number {
@@ -104,8 +104,8 @@ export class AnimatedCircle extends AnimatedCircleCommon {
104104
}
105105

106106
set maxValue(value: number) {
107-
this._maxValue = value;
108-
this.android?.setMaxValue(this.maxValue);
107+
this._maxValue = Number(value);
108+
this.updateAnimatedCircle();
109109
}
110110

111111
get maxValue(): number {
@@ -114,11 +114,7 @@ export class AnimatedCircle extends AnimatedCircleCommon {
114114

115115
set rimColor(value: any) {
116116
this._rimColor = value;
117-
if (value instanceof Color) {
118-
this.android?.setRimColor(value.argb);
119-
} else {
120-
this.android?.setRimColor(new Color(value).argb);
121-
}
117+
this.updateAnimatedCircle();
122118
}
123119

124120
get rimColor() {
@@ -146,7 +142,7 @@ export class AnimatedCircle extends AnimatedCircleCommon {
146142

147143
set rimWidth(value: number) {
148144
this._rimWidth = Number(value);
149-
this.android?.setRimWidth(this._rimWidth);
145+
this.updateAnimatedCircle();
150146
}
151147

152148
get rimWidth() {
@@ -155,11 +151,7 @@ export class AnimatedCircle extends AnimatedCircleCommon {
155151

156152
set spinBarColor(value: any) {
157153
this._spinBarColor = value;
158-
if (value instanceof Color) {
159-
this.android?.setSpinBarColor(value.argb);
160-
} else {
161-
this.android?.setSpinBarColor(new Color(this.spinBarColor).argb);
162-
}
154+
this.updateAnimatedCircle();
163155
}
164156

165157
get spinBarColor() {
@@ -180,24 +172,17 @@ export class AnimatedCircle extends AnimatedCircleCommon {
180172
}
181173

182174
set startAngle(value: number) {
183-
this._startAngle = value;
184-
this.android?.setStartAngle(this._startAngle);
175+
this._startAngle = Number(value);
176+
this.updateAnimatedCircle();
185177
}
186178

187179
get startAngle() {
188180
return this._startAngle;
189181
}
190182

191183
set barWidth(value: number) {
192-
this._barWidth = value;
193-
if (this._barWidth) {
194-
this.android?.setBarWidth(this._barWidth);
195-
} else {
196-
if (this._rimWidth) {
197-
// set rim width to bar width if no bar width provided
198-
this.android?.setBarWidth(this._rimWidth);
199-
}
200-
}
184+
this._barWidth = Number(value);
185+
this.updateAnimatedCircle();
201186
}
202187

203188
get barWidth() {
@@ -206,7 +191,7 @@ export class AnimatedCircle extends AnimatedCircleCommon {
206191

207192
set text(value: string) {
208193
this._text = value;
209-
this.android?.setText(this._text);
194+
this.updateAnimatedCircle();
210195
}
211196

212197
get text() {
@@ -215,12 +200,12 @@ export class AnimatedCircle extends AnimatedCircleCommon {
215200

216201
set textColor(value: string) {
217202
this._textColor = new Color(value);
218-
this.android?.setTextColor(this._textColor.argb);
203+
this.updateAnimatedCircle();
219204
}
220205

221206
set textSize(value: number) {
222207
this._textSize = value;
223-
this.android?.setTextSize(value);
208+
this.updateAnimatedCircle();
224209
}
225210

226211
get textSize() {
@@ -237,6 +222,16 @@ export class AnimatedCircle extends AnimatedCircleCommon {
237222
}
238223
// CSS Properties
239224

225+
[barWidthProperty.setNative](value: any) {
226+
this._barWidth = value;
227+
this.android?.setBarWidth(value);
228+
}
229+
230+
[rimWidthProperty.setNative](value: any) {
231+
this._rimWidth = value;
232+
this.android?.setRimWidth(value);
233+
}
234+
240235
[rimColorProperty.setNative](value: any) {
241236
this._rimColor = value;
242237
if (value instanceof Color) {

packages/animated-circle/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/animated-circle",
3-
"version": "1.1.7",
3+
"version": "1.1.8-alpha",
44
"description": "Animated circle progress in your NativeScript applications.",
55
"main": "index",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)