From 36e0e81dfb796406f7a0be3861178eaa2b1c2cd5 Mon Sep 17 00:00:00 2001 From: Yogev Ben David Date: Mon, 27 Jul 2020 19:42:33 +0300 Subject: [PATCH] Fix statusBar visibility through mergeOptions (#6437) `mergeOptions` with `statusBar.visible` didn't work on iOS. This PR fix it. --- lib/ios/RNNBasePresenter.m | 4 ++++ playground/ios/NavigationTests/RNNBasePresenterTest.m | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/ios/RNNBasePresenter.m b/lib/ios/RNNBasePresenter.m index 3bd4da426cc..a4bf1229492 100644 --- a/lib/ios/RNNBasePresenter.m +++ b/lib/ios/RNNBasePresenter.m @@ -72,6 +72,10 @@ - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigat if (options.window.backgroundColor.hasValue) { UIApplication.sharedApplication.delegate.window.backgroundColor = withDefault.window.backgroundColor.get; } + + if (options.statusBar.visible.hasValue) { + [self.boundViewController setNeedsStatusBarAppearanceUpdate]; + } } - (void)renderComponents:(RNNNavigationOptions *)options perform:(RNNReactViewReadyCompletionBlock)readyBlock { diff --git a/playground/ios/NavigationTests/RNNBasePresenterTest.m b/playground/ios/NavigationTests/RNNBasePresenterTest.m index 67f83c1a423..b238f0df65d 100644 --- a/playground/ios/NavigationTests/RNNBasePresenterTest.m +++ b/playground/ios/NavigationTests/RNNBasePresenterTest.m @@ -123,4 +123,13 @@ - (void)testHidesBottomBarWhenPushed_resolveChildHidesBarBeforeParent { XCTAssertTrue(_boundViewController.hidesBottomBarWhenPushed); } +- (void)testMergeOptions_updatesStatusBarVisibility { + RNNNavigationOptions* mergeOptions = [RNNNavigationOptions emptyOptions]; + mergeOptions.statusBar.visible = [Bool withValue:@(0)]; + + [[self.mockBoundViewController expect] setNeedsStatusBarAppearanceUpdate]; + [self.uut mergeOptions:mergeOptions resolvedOptions:nil]; + [self.mockBoundViewController verify]; +} + @end