sean-perkins / nativescript-animated-circle

NativeScript plugin for animated progress borders on circles.
Apache License 2.0
13 stars 11 forks source link

Android implementation doesn't handle dynamic values. #1

Closed wolfpaq closed 7 years ago

wolfpaq commented 7 years ago

Great plugin. Exactly what I need for a project I'm working on.

One issue is that the Android implementation doesn't handle dynamic attributes (e.g. progress={{ value }}). It is really easy to fix. You just need to move the code you have in initNativeView() into the setters. For example, to make the progress value handle dynamic values you would do this:

    set progress(value: number) {
        this._progress = Number(value);
        if (this.android) {
            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);
            }
        }
    }

and setting rimWidth would look something like this:

    set rimWidth(value: number) {
        this._rimWidth = Number(value);
        if (this.android) {
                this.android.setRimWidth(this.rimWidth);
        }
    }

That code can then be removed from the initNativeView() function.

I'd be happy to submit a PR to fix this if you'd like. I probably won't get to it until the weekend though.

sean-perkins commented 7 years ago

Thanks for reporting 1.0.3 should have the fix that you need.

3c993bb0e47c0deb4bc7d73e6c3302fe