diff --git a/tns-core-modules/ui/activity-indicator/activity-indicator.android.ts b/tns-core-modules/ui/activity-indicator/activity-indicator.android.ts index 489607fd0..ad0b5497e 100644 --- a/tns-core-modules/ui/activity-indicator/activity-indicator.android.ts +++ b/tns-core-modules/ui/activity-indicator/activity-indicator.android.ts @@ -1,4 +1,4 @@ -import { ActivityIndicatorBase, busyProperty, colorProperty, visibilityProperty } from "./activity-indicator-common"; +import { ActivityIndicatorBase, busyProperty, colorProperty, visibilityProperty, Visibility } from "./activity-indicator-common"; export * from "./activity-indicator-common"; @@ -16,18 +16,31 @@ export class ActivityIndicator extends ActivityIndicatorBase { } get [busyProperty.native](): boolean { - return this._progressBar.getVisibility() === android.view.View.VISIBLE; + return false; } set [busyProperty.native](value: boolean) { - this._progressBar.setVisibility(value ? android.view.View.VISIBLE : android.view.View.INVISIBLE); + if (this.visibility === Visibility.VISIBLE) { + this._progressBar.setVisibility(value ? android.view.View.VISIBLE : android.view.View.INVISIBLE); + } } - get [visibilityProperty.native](): number { - return this._progressBar.getVisibility(); + get [visibilityProperty.native](): Visibility { + return Visibility.HIDDEN; } - set [visibilityProperty.native](value: number) { - this.busy = value === android.view.View.VISIBLE; - this._progressBar.setVisibility(value); + set [visibilityProperty.native](value: Visibility) { + switch (value) { + case Visibility.VISIBLE: + this._progressBar.setVisibility(this.busy ? android.view.View.VISIBLE : android.view.View.INVISIBLE); + break; + case Visibility.HIDDEN: + this._progressBar.setVisibility(android.view.View.INVISIBLE); + break; + case Visibility.COLLAPSE: + this._progressBar.setVisibility(android.view.View.GONE); + break; + default: + throw new Error(`Invalid visibility value: ${value}. Valid values are: "${Visibility.VISIBLE}", "${Visibility.HIDDEN}", "${Visibility.COLLAPSE}".`); + } } get [colorProperty.native](): number { diff --git a/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts b/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts index d96349ee9..e1bd97fb5 100644 --- a/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts +++ b/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts @@ -1,4 +1,4 @@ -import { ActivityIndicatorBase, busyProperty, colorProperty, visibilityProperty } from "./activity-indicator-common"; +import { ActivityIndicatorBase, busyProperty, colorProperty, visibilityProperty, Visibility } from "./activity-indicator-common"; import { ios } from "utils/utils"; export * from "./activity-indicator-common"; @@ -33,13 +33,6 @@ export class ActivityIndicator extends ActivityIndicatorBase { } } - get [visibilityProperty.native](): string { - return this.nativeView.hidden ? "collapse" : "visible"; - } - set [visibilityProperty.native](value: string) { - this.nativeView.hidden = value !== "visible"; - } - get [colorProperty.native](): UIColor { return this.nativeView.color; } diff --git a/tns-core-modules/ui/core/view-base.ts b/tns-core-modules/ui/core/view-base.ts index 6e3045d29..e31524dc9 100644 --- a/tns-core-modules/ui/core/view-base.ts +++ b/tns-core-modules/ui/core/view-base.ts @@ -500,17 +500,6 @@ export class ViewBase extends Observable implements ViewBaseDefinition { } } -export const visibilityProperty = new CssProperty({ - name: "visibility", cssName: "visibility", defaultValue: "visible", affectsLayout: isIOS, valueChanged: (target, newValue) => { - if (newValue !== "visible" && newValue !== "collapse" && newValue !== "collapsed" && newValue !== "hidden") { - throw new Error(`Invalid visibility value: ${newValue}`); - } - - target.view.isCollapsed = (newValue === "collapse" || newValue === "collapsed"); - } -}); -visibilityProperty.register(Style); - export const bindingContextProperty = new InheritedProperty({ name: "bindingContext" }); bindingContextProperty.register(ViewBase); diff --git a/tns-core-modules/ui/core/view-common.ts b/tns-core-modules/ui/core/view-common.ts index 6980cb159..3c25e6613 100644 --- a/tns-core-modules/ui/core/view-common.ts +++ b/tns-core-modules/ui/core/view-common.ts @@ -396,10 +396,10 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { this.style.verticalAlignment = value; } - get visibility(): "visible" | "hidden" | "collapse" | "collapsed" { + get visibility(): Visibility { return this.style.visibility; } - set visibility(value: "visible" | "hidden" | "collapse" | "collapsed") { + set visibility(value: Visibility) { this.style.visibility = value; } @@ -1863,4 +1863,20 @@ const fontProperty = new ShorthandProperty