UNPKG

1.79 kBJavaScriptView Raw
1import { ActivityIndicatorBase, busyProperty } from './activity-indicator-common';
2import { colorProperty } from '../styling/style-properties';
3import { Color } from '../../color';
4import { iOSNativeHelper } from '../../utils';
5export * from './activity-indicator-common';
6const majorVersion = iOSNativeHelper.MajorVersion;
7export class ActivityIndicator extends ActivityIndicatorBase {
8 constructor() {
9 super(...arguments);
10 this._activityIndicatorViewStyle = majorVersion <= 12 || !100 /* UIActivityIndicatorViewStyle.Medium */ ? 2 /* UIActivityIndicatorViewStyle.Gray */ : 100 /* UIActivityIndicatorViewStyle.Medium */;
11 }
12 createNativeView() {
13 const viewStyle = this._activityIndicatorViewStyle;
14 const view = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(viewStyle);
15 view.hidesWhenStopped = true;
16 return view;
17 }
18 // @ts-ignore
19 get ios() {
20 return this.nativeViewProtected;
21 }
22 [busyProperty.getDefault]() {
23 if (this.nativeViewProtected.isAnimating) {
24 return this.nativeViewProtected.isAnimating();
25 }
26 else {
27 return this.nativeViewProtected.animating;
28 }
29 }
30 [busyProperty.setNative](value) {
31 const nativeView = this.nativeViewProtected;
32 if (value) {
33 nativeView.startAnimating();
34 }
35 else {
36 nativeView.stopAnimating();
37 }
38 if (nativeView.hidesWhenStopped) {
39 this.requestLayout();
40 }
41 }
42 [colorProperty.getDefault]() {
43 return this.nativeViewProtected.color;
44 }
45 [colorProperty.setNative](value) {
46 this.nativeViewProtected.color = value instanceof Color ? value.ios : value;
47 }
48}
49//# sourceMappingURL=index.ios.js.map
\No newline at end of file