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' ;
2
2
import { ProgressBase , busyProperty , indeterminateProperty , progressBackgroundColorProperty , progressColorProperty , trackCornerRadiusProperty } from './progress-common' ;
3
3
import { getRippleColor } from '@nativescript-community/ui-material-core' ;
4
4
import { inflateLayout } from '@nativescript-community/ui-material-core/android/utils' ;
@@ -17,38 +17,18 @@ export class Progress extends ProgressBase {
17
17
this . nativeViewProtected . setProgressBackgroundTintList ( color ? android . content . res . ColorStateList . valueOf ( color . android ) : null ) ;
18
18
}
19
19
[ 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 ) ;
30
22
}
31
23
[ busyProperty . setNative ] ( value ) {
32
- this . nativeViewProtected . setVisibility ( value ? android . view . View . VISIBLE : android . view . View . INVISIBLE ) ;
24
+ this [ visibilityProperty . setNative ] ( this . visibility ) ;
33
25
}
34
26
[ heightProperty . setNative ] ( value ) {
35
27
this . nativeViewProtected . setTrackThickness ( PercentLength . toDevicePixels ( value ) ) ;
36
28
}
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
+ }
52
32
public startAnimating ( ) {
53
33
this . busy = true ;
54
34
}
@@ -71,6 +51,6 @@ export class Progress extends ProgressBase {
71
51
}
72
52
73
53
[ trackCornerRadiusProperty . setNative ] ( value ) {
74
- this . nativeViewProtected . setTrackCornerRadius ( Length . toDevicePixels ( value , 0 ) )
54
+ this . nativeViewProtected . setTrackCornerRadius ( Length . toDevicePixels ( value , 0 ) ) ;
75
55
}
76
56
}
0 commit comments