mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00

recycleNativeView filed now accepts: "always" | "never" | "auto". Always will recycle the nativeView no matter if its nativeView or android proprties are accessed. Never will disable recycling. Auto will recycle it only if nativeView and android properties are not accessed.
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { ActivityIndicatorBase, busyProperty, colorProperty, Color } from "./activity-indicator-common";
|
|
|
|
export * from "./activity-indicator-common";
|
|
|
|
export class ActivityIndicator extends ActivityIndicatorBase {
|
|
nativeViewProtected: UIActivityIndicatorView;
|
|
|
|
constructor() {
|
|
super();
|
|
this.nativeViewProtected = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(UIActivityIndicatorViewStyle.Gray);
|
|
this.nativeViewProtected.hidesWhenStopped = true;
|
|
}
|
|
|
|
get ios(): UIActivityIndicatorView {
|
|
return this.nativeViewProtected;
|
|
}
|
|
|
|
[busyProperty.getDefault](): boolean {
|
|
if ((<any>this.nativeViewProtected).isAnimating) {
|
|
return (<any>this.nativeViewProtected).isAnimating();
|
|
}
|
|
else {
|
|
return this.nativeViewProtected.animating;
|
|
}
|
|
}
|
|
[busyProperty.setNative](value: boolean) {
|
|
let nativeView = this.nativeViewProtected;
|
|
if (value) {
|
|
nativeView.startAnimating();
|
|
} else {
|
|
nativeView.stopAnimating();
|
|
}
|
|
|
|
if (nativeView.hidesWhenStopped) {
|
|
this.requestLayout();
|
|
}
|
|
}
|
|
|
|
[colorProperty.getDefault](): UIColor {
|
|
return this.nativeViewProtected.color;
|
|
}
|
|
[colorProperty.setNative](value: UIColor | Color) {
|
|
this.nativeViewProtected.color = value instanceof Color ? value.ios : value;
|
|
}
|
|
} |