From 83a5afa84b3ed79284a1c28c4634506d0641df02 Mon Sep 17 00:00:00 2001 From: Yogev Ben David Date: Tue, 1 Sep 2020 19:47:08 +0300 Subject: [PATCH] Fix status bar disappears on setRoot (#6525) It appears that UIViewController's delegate methods `preferredStatusBarStyle` and `prefersStatusBarHidden` needs to run faster than it does now. So instead of resolving all the options object, I changed it to resolve only the `statusBar` options object, which fix's the issue. Closes #6506 --- lib/ios/RNNBasePresenter.m | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/ios/RNNBasePresenter.m b/lib/ios/RNNBasePresenter.m index 13e36fe1279..8a78e057ccf 100644 --- a/lib/ios/RNNBasePresenter.m +++ b/lib/ios/RNNBasePresenter.m @@ -92,8 +92,8 @@ - (void)viewDidLayoutSubviews { } - (UIStatusBarStyle)getStatusBarStyle { - RNNNavigationOptions *withDefault = [self.boundViewController.resolveOptions withDefault:[self defaultOptions]]; - NSString* statusBarStyle = [withDefault.statusBar.style getWithDefaultValue:@"default"]; + RNNStatusBarOptions *statusBarOptions = [self resolveStatusBarOptions]; + NSString* statusBarStyle = [statusBarOptions.style getWithDefaultValue:@"default"]; if ([statusBarStyle isEqualToString:@"light"]) { return UIStatusBarStyleLightContent; } else if (@available(iOS 13.0, *)) { @@ -107,6 +107,20 @@ - (UIStatusBarStyle)getStatusBarStyle { } } +- (BOOL)getStatusBarVisibility { + RNNStatusBarOptions *statusBarOptions = [self resolveStatusBarOptions]; + if (statusBarOptions.visible.hasValue) { + return ![statusBarOptions.visible get]; + } else if ([statusBarOptions.hideWithTopBar getWithDefaultValue:NO]) { + return self.boundViewController.stack.isNavigationBarHidden; + } + return NO; +} + +- (RNNStatusBarOptions*)resolveStatusBarOptions { + return (RNNStatusBarOptions*)[[self.boundViewController.options.statusBar mergeInOptions:self.boundViewController.getCurrentChild.presenter.resolveStatusBarOptions] withDefault:self.defaultOptions.statusBar]; +} + - (UINavigationItem *)currentNavigationItem { return self.boundViewController.getCurrentChild.navigationItem; } @@ -115,16 +129,6 @@ - (UIInterfaceOrientationMask)getOrientation { return [self.boundViewController.resolveOptions withDefault:self.defaultOptions].layout.supportedOrientations; } -- (BOOL)getStatusBarVisibility { - RNNNavigationOptions *withDefault = [self.boundViewController.resolveOptions withDefault:self.defaultOptions]; - if (withDefault.statusBar.visible.hasValue) { - return ![withDefault.statusBar.visible get]; - } else if ([withDefault.statusBar.hideWithTopBar getWithDefaultValue:NO]) { - return self.boundViewController.stack.isNavigationBarHidden; - } - return NO; -} - - (BOOL)hidesBottomBarWhenPushed { RNNNavigationOptions *withDefault = (RNNNavigationOptions *)[self.boundViewController.topMostViewController.resolveOptions withDefault:self.defaultOptions]; return ![withDefault.bottomTabs.visible getWithDefaultValue:YES];