[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[iOS] Support to use loading-indicator separately.
Browse files Browse the repository at this point in the history
* feature: Support to use loading-indicator separately. Use animating property to control.
* doc pr: apache/incubator-weex-site#363
* demo: http://dotwe.org/vue/15b0ac96db6e1837ef5c27c0345b7fb6
  • Loading branch information
huanglei.hl committed Mar 28, 2019
1 parent 36dce32 commit af516f2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ios/sdk/WeexSDK/Sources/Component/WXLoadingIndicator.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@implementation WXLoadingIndicator {
UIActivityIndicatorView *_indicator;
UIColor *_indicatorColor;
id _animating;
}

- (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes events:(NSArray *)events weexInstance:(WXSDKInstance *)weexInstance {
Expand All @@ -31,6 +32,9 @@ - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDict
if (styles[@"color"]) {
_indicatorColor = [WXConvert UIColor:styles[@"color"]];
}
if (attributes[@"animating"]) {
_animating = attributes[@"animating"];
}
}
return self;
}
Expand All @@ -45,6 +49,13 @@ - (void)viewDidLoad {
if (_indicatorColor) {
_indicator.color = _indicatorColor;
}
if (_animating) {
if ([WXConvert BOOL:_animating]) {
[_indicator startAnimating];
} else {
[_indicator stopAnimating];
}
}
}

- (void)updateStyles:(NSDictionary *)styles {
Expand All @@ -54,6 +65,19 @@ - (void)updateStyles:(NSDictionary *)styles {
}
}

- (void)updateAttributes:(NSDictionary *)attributes
{
if (attributes[@"animating"]) {
_animating = attributes[@"animating"];

if ([WXConvert BOOL:_animating]) {
[_indicator startAnimating];
} else {
[_indicator stopAnimating];
}
}
}

#pragma mark - lifeCircle

- (void)viewWillUnload {
Expand Down

0 comments on commit af516f2

Please sign in to comment.