2015-03-23 20:28:42 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-04-26 09:22:34 +00:00
|
|
|
#import "RCTActivityIndicatorViewManager.h"
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
#import "RCTConvert.h"
|
|
|
|
|
2015-03-26 04:29:28 +00:00
|
|
|
@implementation RCTConvert (UIActivityIndicatorView)
|
|
|
|
|
2015-04-26 09:22:34 +00:00
|
|
|
// NOTE: It's pointless to support UIActivityIndicatorViewStyleGray
|
|
|
|
// as we can set the color to any arbitrary value that we want to
|
|
|
|
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_ENUM_CONVERTER(UIActivityIndicatorViewStyle, (@{
|
2015-04-26 09:22:34 +00:00
|
|
|
@"large": @(UIActivityIndicatorViewStyleWhiteLarge),
|
|
|
|
@"small": @(UIActivityIndicatorViewStyleWhite),
|
2015-03-26 04:29:28 +00:00
|
|
|
}), UIActivityIndicatorViewStyleWhiteLarge, integerValue)
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-04-26 09:22:34 +00:00
|
|
|
@implementation RCTActivityIndicatorViewManager
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-04-26 09:22:34 +00:00
|
|
|
RCT_EXPORT_MODULE()
|
2015-04-08 12:42:43 +00:00
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
- (UIView *)view
|
|
|
|
{
|
|
|
|
return [[UIActivityIndicatorView alloc] init];
|
|
|
|
}
|
|
|
|
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(color, UIColor)
|
2015-04-26 09:22:34 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(hidesWhenStopped, BOOL)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(size, activityIndicatorViewStyle, UIActivityIndicatorViewStyle)
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(animating, BOOL, UIActivityIndicatorView)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-04-26 09:22:34 +00:00
|
|
|
BOOL animating = json ? [RCTConvert BOOL:json] : [defaultView isAnimating];
|
2015-02-20 04:10:52 +00:00
|
|
|
if (animating != [view isAnimating]) {
|
|
|
|
if (animating) {
|
|
|
|
[view startAnimating];
|
|
|
|
} else {
|
|
|
|
[view stopAnimating];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|