1- import { ActivityIndicatorBase , busyProperty } from './activity-indicator-common' ;
1+ import { ActivityIndicatorBase , busyProperty , iosIndicatorViewStyleProperty } from './activity-indicator-common' ;
22import { colorProperty } from '../styling/style-properties' ;
33import { Color } from '../../color' ;
44import { iOSNativeHelper } from '../../utils' ;
5+ import { IOSIndicatorViewStyle } from '.' ;
56
67export * from './activity-indicator-common' ;
78
@@ -10,10 +11,8 @@ const majorVersion = iOSNativeHelper.MajorVersion;
1011export class ActivityIndicator extends ActivityIndicatorBase {
1112 nativeViewProtected : UIActivityIndicatorView ;
1213
13- private _activityIndicatorViewStyle = majorVersion <= 12 || ! UIActivityIndicatorViewStyle . Medium ? UIActivityIndicatorViewStyle . Gray : UIActivityIndicatorViewStyle . Medium ;
14-
1514 createNativeView ( ) {
16- const viewStyle = this . _activityIndicatorViewStyle ;
15+ const viewStyle = this . _getNativeIndicatorViewStyle ( this . iosIndicatorViewStyle ) ;
1716 const view = UIActivityIndicatorView . alloc ( ) . initWithActivityIndicatorStyle ( viewStyle ) ;
1817 view . hidesWhenStopped = true ;
1918
@@ -25,15 +24,27 @@ export class ActivityIndicator extends ActivityIndicatorBase {
2524 return this . nativeViewProtected ;
2625 }
2726
28- [ busyProperty . getDefault ] ( ) : boolean {
29- if ( ( < any > this . nativeViewProtected ) . isAnimating ) {
30- return ( < any > this . nativeViewProtected ) . isAnimating ( ) ;
31- } else {
32- return this . nativeViewProtected . animating ;
27+ private _getNativeIndicatorViewStyle ( value : IOSIndicatorViewStyle ) : UIActivityIndicatorViewStyle {
28+ let viewStyle : UIActivityIndicatorViewStyle ;
29+
30+ switch ( value ) {
31+ case 'large' :
32+ viewStyle = majorVersion > 12 ? UIActivityIndicatorViewStyle . Large : UIActivityIndicatorViewStyle . WhiteLarge ;
33+ break ;
34+ default :
35+ viewStyle = majorVersion > 12 ? UIActivityIndicatorViewStyle . Medium : UIActivityIndicatorViewStyle . Gray ;
36+ break ;
3337 }
38+
39+ return viewStyle ;
40+ }
41+
42+ [ busyProperty . getDefault ] ( ) : boolean {
43+ return this . nativeViewProtected . animating ;
3444 }
3545 [ busyProperty . setNative ] ( value : boolean ) {
3646 const nativeView = this . nativeViewProtected ;
47+
3748 if ( value ) {
3849 nativeView . startAnimating ( ) ;
3950 } else {
@@ -51,4 +62,8 @@ export class ActivityIndicator extends ActivityIndicatorBase {
5162 [ colorProperty . setNative ] ( value : UIColor | Color ) {
5263 this . nativeViewProtected . color = value instanceof Color ? value . ios : value ;
5364 }
65+
66+ [ iosIndicatorViewStyleProperty . setNative ] ( value : IOSIndicatorViewStyle ) {
67+ this . nativeViewProtected . activityIndicatorViewStyle = this . _getNativeIndicatorViewStyle ( value ) ;
68+ }
5469}
0 commit comments