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
|
|
|
|
|
|
|
#import "RCTUIActivityIndicatorViewManager.h"
|
|
|
|
|
|
|
|
#import "RCTConvert.h"
|
|
|
|
|
2015-03-26 04:29:28 +00:00
|
|
|
@implementation RCTConvert (UIActivityIndicatorView)
|
|
|
|
|
|
|
|
RCT_ENUM_CONVERTER(UIActivityIndicatorViewStyle, (@{
|
|
|
|
@"white-large": @(UIActivityIndicatorViewStyleWhiteLarge),
|
|
|
|
@"large-white": @(UIActivityIndicatorViewStyleWhiteLarge),
|
|
|
|
@"white": @(UIActivityIndicatorViewStyleWhite),
|
|
|
|
@"gray": @(UIActivityIndicatorViewStyleGray),
|
|
|
|
}), UIActivityIndicatorViewStyleWhiteLarge, integerValue)
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
@implementation RCTUIActivityIndicatorViewManager
|
|
|
|
|
|
|
|
- (UIView *)view
|
|
|
|
{
|
|
|
|
return [[UIActivityIndicatorView alloc] init];
|
|
|
|
}
|
|
|
|
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(activityIndicatorViewStyle, UIActivityIndicatorViewStyle)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(color, UIColor)
|
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(animating, BOOL, UIActivityIndicatorView)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-03-01 23:33:55 +00:00
|
|
|
BOOL animating = json ? [json boolValue] : [defaultView isAnimating];
|
2015-02-20 04:10:52 +00:00
|
|
|
if (animating != [view isAnimating]) {
|
|
|
|
if (animating) {
|
|
|
|
[view startAnimating];
|
|
|
|
} else {
|
|
|
|
[view stopAnimating];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
- (NSDictionary *)constantsToExport
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
|
|
|
return
|
|
|
|
@{
|
|
|
|
@"StyleWhite": @(UIActivityIndicatorViewStyleWhite),
|
|
|
|
@"StyleWhiteLarge": @(UIActivityIndicatorViewStyleWhiteLarge),
|
|
|
|
@"StyleGray": @(UIActivityIndicatorViewStyleGray),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|