Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bicolor Status Bar Bug #6506

Closed
danilobuerger opened this issue Aug 24, 2020 · 3 comments · Fixed by #6525
Closed

Bicolor Status Bar Bug #6506

danilobuerger opened this issue Aug 24, 2020 · 3 comments · Fixed by #6525

Comments

@danilobuerger
Copy link
Collaborator

Issue Description

Multiple calls to Navigation.setRoot lead to the status bar becoming bicolor (text white, icons black).

Before After
Simulator Screen Shot - iPhone SE (2nd generation) - 2020-08-24 at 15 59 16 Simulator Screen Shot - iPhone SE (2nd generation) - 2020-08-24 at 15 59 08

Steps to Reproduce / Code Snippets / Screenshots

Easily reproducible with current playground (https://github.com/wix/react-native-navigation/tree/6022f434a8b4cd4a1b03f1f9f2a13e6912b7e07e):

diff --git a/playground/src/app.ts b/playground/src/app.ts
index dbe0ce1a7..4907ee482 100644
--- a/playground/src/app.ts
+++ b/playground/src/app.ts
@@ -26,10 +26,17 @@ function start() {
   setDefaultOptions();
   Navigation.events().registerAppLaunchedListener(async () => {
     Navigation.dismissAllModals();
-    setRoot();
+    repeatedlyCallSetRoot();
   });
 }
 
+function repeatedlyCallSetRoot() {
+  setRoot();
+  setTimeout(() => {
+    repeatedlyCallSetRoot();
+  }, 5000);
+}
+
 function setRoot() {
   Navigation.setRoot({
     root: {

Now Navigation.setRoot is called every 5 seconds in the playground app, leading to the bicolor status bar.


Environment

@danilobuerger
Copy link
Collaborator Author

danilobuerger commented Aug 24, 2020

Modifying RNNBasePresenter results in it not happening any more:

diff --git a/lib/ios/RNNBasePresenter.m b/lib/ios/RNNBasePresenter.m
index a4bf12294..f3fc3a099 100644
--- a/lib/ios/RNNBasePresenter.m
+++ b/lib/ios/RNNBasePresenter.m
@@ -90,19 +90,7 @@ - (void)viewDidLayoutSubviews {
 }
 
 - (UIStatusBarStyle)getStatusBarStyle {
-    RNNNavigationOptions *withDefault = [self.boundViewController.resolveOptions withDefault:[self defaultOptions]];
-    NSString* statusBarStyle = [withDefault.statusBar.style getWithDefaultValue:@"default"];
-    if ([statusBarStyle isEqualToString:@"light"]) {
-        return UIStatusBarStyleLightContent;
-    } else if (@available(iOS 13.0, *)) {
-        if ([statusBarStyle isEqualToString:@"dark"]) {
-            return UIStatusBarStyleDarkContent;
-        } else {
-            return UIStatusBarStyleDefault;
-        }
-    } else {
-        return UIStatusBarStyleDefault;
-    }
+    return UIStatusBarStyleDarkContent;
 }
 
 - (UINavigationItem *)currentNavigationItem {
@@ -114,12 +102,6 @@ - (UIInterfaceOrientationMask)getOrientation {
 }
 
 - (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;
 }
 

@danilobuerger
Copy link
Collaborator Author

danilobuerger commented Aug 24, 2020

It seems to be timing related as doing a NSThread sleep inside getStatusBarStyle makes it reproducible again:

- (UIStatusBarStyle)getStatusBarStyle {
    [NSThread sleepForTimeInterval:0.01f];
    return UIStatusBarStyleDarkContent;
}

@danilobuerger
Copy link
Collaborator Author

Setting the NSThread sleep to larger values (tested 1.0f) fixes the bug again.

guyca pushed a commit that referenced this issue Sep 1, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants