1 | import { ActivityIndicatorBase, busyProperty } from './activity-indicator-common';
|
2 | import { colorProperty } from '../styling/style-properties';
|
3 | import { Color } from '../../color';
|
4 | import { iOSNativeHelper } from '../../utils';
|
5 | export * from './activity-indicator-common';
|
6 | const majorVersion = iOSNativeHelper.MajorVersion;
|
7 | export class ActivityIndicator extends ActivityIndicatorBase {
|
8 | constructor() {
|
9 | super(...arguments);
|
10 | this._activityIndicatorViewStyle = majorVersion <= 12 || !100 ? 2 : 100 ;
|
11 | }
|
12 | createNativeView() {
|
13 | const viewStyle = this._activityIndicatorViewStyle;
|
14 | const view = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(viewStyle);
|
15 | view.hidesWhenStopped = true;
|
16 | return view;
|
17 | }
|
18 |
|
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 |
|
\ | No newline at end of file |