Skip to content

Commit

Permalink
Fix status bar disappears on setRoot (#6525)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yogevbd authored Sep 1, 2020
1 parent 02072b6 commit 83a5afa
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lib/ios/RNNBasePresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -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, *)) {
Expand All @@ -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;
}
Expand All @@ -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];
Expand Down

0 comments on commit 83a5afa

Please sign in to comment.