Skip to content

Commit

Permalink
iOS13 status bar has now 3 styles (facebook#26294)
Browse files Browse the repository at this point in the history
Summary:
iOS13 status bar has now 3 styles
UIStatusBarStyleDefault, UIStatusBarStyleLightContent, UIStatusBarStyleDarkContent

UIStatusBarStyleDefault now acts as an automatic style which will set it’s value dynamically based on the the userinterfacestyle(One of the traits) of the viewcontroller that controls the status bar appearance.

[iOS] [Fixed] - iOS13 new status bar style UIStatusBarStyleDarkContent
Pull Request resolved: facebook#26294

Differential Revision: D17314054

Pulled By: cpojer

fbshipit-source-id: ea109e729bb551dff314bc00a056860a8febb0e9
  • Loading branch information
gaodeng authored and ide committed Sep 25, 2019
1 parent c084ab4 commit fa77e28
Showing 1 changed file with 38 additions and 11 deletions.
49 changes: 38 additions & 11 deletions React/Modules/RCTStatusBarManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,44 @@
#if !TARGET_OS_TV
@implementation RCTConvert (UIStatusBar)

RCT_ENUM_CONVERTER(UIStatusBarStyle, (@{
@"default": @(UIStatusBarStyleDefault),
@"light-content": @(UIStatusBarStyleLightContent),
@"dark-content": @(UIStatusBarStyleDefault),
}), UIStatusBarStyleDefault, integerValue);

RCT_ENUM_CONVERTER(UIStatusBarAnimation, (@{
@"none": @(UIStatusBarAnimationNone),
@"fade": @(UIStatusBarAnimationFade),
@"slide": @(UIStatusBarAnimationSlide),
}), UIStatusBarAnimationNone, integerValue);
+ (UIStatusBarStyle)UIStatusBarStyle:(id)json RCT_DYNAMIC
{
static NSDictionary *mapping;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (@available(iOS 13.0, *)) {
mapping = @{
@"default" : @(UIStatusBarStyleDefault),
@"light-content" : @(UIStatusBarStyleLightContent),
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
@"dark-content" : @(UIStatusBarStyleDarkContent)
#else
@"dark-content": @(UIStatusBarStyleDefault)
#endif
};

} else {
mapping = @{
@"default" : @(UIStatusBarStyleDefault),
@"light-content" : @(UIStatusBarStyleLightContent),
@"dark-content" : @(UIStatusBarStyleDefault)
};
}
});
return _RCT_CAST(
type, [RCTConvertEnumValue("UIStatusBarStyle", mapping, @(UIStatusBarStyleDefault), json) integerValue]);
}

RCT_ENUM_CONVERTER(
UIStatusBarAnimation,
(@{
@"none" : @(UIStatusBarAnimationNone),
@"fade" : @(UIStatusBarAnimationFade),
@"slide" : @(UIStatusBarAnimationSlide),
}),
UIStatusBarAnimationNone,
integerValue);

@end
#endif
Expand Down

0 comments on commit fa77e28

Please sign in to comment.