Skip to content

Commit 86a9596

Browse files
author
farfromrefug
committed
fix(progress): fix for changing busy/indeterminate rendering the view invisible
1 parent 69f1a2f commit 86a9596

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

src/progress/progress.android.ts

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Color, Length, PercentLength, backgroundColorProperty, backgroundInternalProperty, colorProperty, heightProperty } from '@nativescript/core';
1+
import { Color, Length, PercentLength, backgroundColorProperty, backgroundInternalProperty, colorProperty, heightProperty, visibilityProperty } from '@nativescript/core';
22
import { ProgressBase, busyProperty, indeterminateProperty, progressBackgroundColorProperty, progressColorProperty, trackCornerRadiusProperty } from './progress-common';
33
import { getRippleColor } from '@nativescript-community/ui-material-core';
44
import { inflateLayout } from '@nativescript-community/ui-material-core/android/utils';
@@ -17,38 +17,18 @@ export class Progress extends ProgressBase {
1717
this.nativeViewProtected.setProgressBackgroundTintList(color ? android.content.res.ColorStateList.valueOf(color.android) : null);
1818
}
1919
[indeterminateProperty.setNative](value: boolean) {
20-
if (this.nativeViewProtected.getVisibility() === android.view.View.VISIBLE) {
21-
this.nativeViewProtected.setVisibility(android.view.View.GONE);
22-
this.nativeViewProtected.setIndeterminate(value);
23-
this.nativeViewProtected.setVisibility(this.busy ? android.view.View.VISIBLE : android.view.View.INVISIBLE);
24-
} else {
25-
this.nativeViewProtected.setIndeterminate(value);
26-
}
27-
}
28-
[busyProperty.getDefault]() {
29-
return false;
20+
this.nativeViewProtected.setIndeterminate(value);
21+
this[visibilityProperty.setNative](this.visibility);
3022
}
3123
[busyProperty.setNative](value) {
32-
this.nativeViewProtected.setVisibility(value ? android.view.View.VISIBLE : android.view.View.INVISIBLE);
24+
this[visibilityProperty.setNative](this.visibility);
3325
}
3426
[heightProperty.setNative](value) {
3527
this.nativeViewProtected.setTrackThickness(PercentLength.toDevicePixels(value));
3628
}
37-
// [visibilityProperty.setNative](value) {
38-
// switch (value) {
39-
// case Visibility.VISIBLE:
40-
// this.nativeViewProtected.setVisibility(this.busy ? android.view.View.VISIBLE : android.view.View.INVISIBLE);
41-
// break;
42-
// case Visibility.HIDDEN:
43-
// this.nativeViewProtected.setVisibility(android.view.View.INVISIBLE);
44-
// break;
45-
// case Visibility.COLLAPSE:
46-
// this.nativeViewProtected.setVisibility(android.view.View.GONE);
47-
// break;
48-
// default:
49-
// throw new Error(`Invalid visibility value: ${value}. Valid values are: "${Visibility.VISIBLE}", "${Visibility.HIDDEN}", "${Visibility.COLLAPSE}".`);
50-
// }
51-
// }
29+
[visibilityProperty.setNative](value) {
30+
super[visibilityProperty.setNative](this.busy || !this.indeterminate ? value : 'hidden');
31+
}
5232
public startAnimating() {
5333
this.busy = true;
5434
}
@@ -71,6 +51,6 @@ export class Progress extends ProgressBase {
7151
}
7252

7353
[trackCornerRadiusProperty.setNative](value) {
74-
this.nativeViewProtected.setTrackCornerRadius(Length.toDevicePixels(value, 0))
54+
this.nativeViewProtected.setTrackCornerRadius(Length.toDevicePixels(value, 0));
7555
}
7656
}

0 commit comments

Comments
 (0)