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 "RCTStatusBarManager.h"
|
|
|
|
|
|
|
|
#import "RCTLog.h"
|
|
|
|
|
2015-06-05 15:46:17 +00:00
|
|
|
@implementation RCTConvert (UIStatusBar)
|
|
|
|
|
|
|
|
RCT_ENUM_CONVERTER(UIStatusBarStyle, (@{
|
|
|
|
@"default": @(UIStatusBarStyleDefault),
|
|
|
|
@"light-content": @(UIStatusBarStyleLightContent),
|
|
|
|
}), UIStatusBarStyleDefault, integerValue);
|
|
|
|
|
|
|
|
RCT_ENUM_CONVERTER(UIStatusBarAnimation, (@{
|
|
|
|
@"none": @(UIStatusBarAnimationNone),
|
|
|
|
@"fade": @(UIStatusBarAnimationFade),
|
|
|
|
@"slide": @(UIStatusBarAnimationSlide),
|
|
|
|
}), UIStatusBarAnimationNone, integerValue);
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
@implementation RCTStatusBarManager
|
|
|
|
|
|
|
|
static BOOL RCTViewControllerBasedStatusBarAppearance()
|
|
|
|
{
|
|
|
|
static BOOL value;
|
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
dispatch_once(&onceToken, ^{
|
2015-06-05 15:46:17 +00:00
|
|
|
value = [[[NSBundle mainBundle] objectForInfoDictionaryKey:
|
|
|
|
@"UIViewControllerBasedStatusBarAppearance"] ?: @YES boolValue];
|
2015-02-20 04:10:52 +00:00
|
|
|
});
|
2015-03-11 02:03:59 +00:00
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2015-04-08 12:42:43 +00:00
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
|
2015-04-20 19:06:02 +00:00
|
|
|
- (dispatch_queue_t)methodQueue
|
|
|
|
{
|
|
|
|
return dispatch_get_main_queue();
|
|
|
|
}
|
|
|
|
|
2015-04-08 15:52:48 +00:00
|
|
|
RCT_EXPORT_METHOD(setStyle:(UIStatusBarStyle)statusBarStyle
|
|
|
|
animated:(BOOL)animated)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-04-18 17:43:20 +00:00
|
|
|
if (RCTViewControllerBasedStatusBarAppearance()) {
|
|
|
|
RCTLogError(@"RCTStatusBarManager module requires that the \
|
|
|
|
UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO");
|
|
|
|
} else {
|
|
|
|
[[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle
|
|
|
|
animated:animated];
|
|
|
|
}
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
2015-04-08 15:52:48 +00:00
|
|
|
RCT_EXPORT_METHOD(setHidden:(BOOL)hidden
|
|
|
|
withAnimation:(UIStatusBarAnimation)animation)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-04-18 17:43:20 +00:00
|
|
|
if (RCTViewControllerBasedStatusBarAppearance()) {
|
|
|
|
RCTLogError(@"RCTStatusBarManager module requires that the \
|
|
|
|
UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO");
|
|
|
|
} else {
|
|
|
|
[[UIApplication sharedApplication] setStatusBarHidden:hidden
|
|
|
|
withAnimation:animation];
|
|
|
|
}
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|