Skip to content

Conversation

@NathanWalker
Copy link
Contributor

@NathanWalker NathanWalker commented Sep 24, 2025

Allows statusBarStyle to be defined on any view for explicit per view control, whether presented in modal or not.

Note: You must remove Info.plist key UIViewControllerBasedStatusBarAppearance
It defaults to true when not present: https://developer.apple.com/documentation/bundleresources/information-property-list/uiviewcontrollerbasedstatusbarappearance

Or you can explicitly set it to true:

<key>UIViewControllerBasedStatusBarAppearance</key> 
<true/>

False value will make this property have no effect.

Before

You could patch-package to control some cases but was dificult to have explicit control over status bar color in varied acute cases.
Screenshot 2025-09-24 at 11 02 24 AM

After

Screenshot 2025-09-24 at 11 15 20 AM

ShowModalOptions now allows statusBarStyle to be set within ios options.

Allows statusBarStyle to be defined on any view for explicit per view control, whether presented in modal or not.
Note: You must remove Info.plist key `UIViewControllerBasedStatusBarAppearance`
It defaults to true when not present: https://developer.apple.com/documentation/bundleresources/information-property-list/uiviewcontrollerbasedstatusbarappearance
Or you can explicitly set it to true:
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>

False value will make this property have no effect.
@NathanWalker NathanWalker added this to the 9.0 milestone Sep 24, 2025
@nx-cloud
Copy link

nx-cloud bot commented Sep 24, 2025

View your CI Pipeline Execution ↗ for commit 57692de

Command Status Duration Result
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-01 05:51:48 UTC

@NathanWalker NathanWalker added the docs needed Additional documentation on this issue/PR is needed label Sep 27, 2025
@NathanWalker NathanWalker changed the title feat(ios): ease of use on explicit preferredStatusBarStyle feat(core): ease of use and more control over statusBarStyle Oct 31, 2025
@NathanWalker NathanWalker changed the title feat(core): ease of use and more control over statusBarStyle feat(core): statusBarStyle ease of use and more control Oct 31, 2025
@farfromrefug
Copy link
Collaborator

That implementation seems a bit "dangerous" in the sense that it will have inconsistent behaviours:

  • multiple views defining the prop in the same layout
  • define it in a view shown in a alert or modal, close the modal/alert and the status bar style wont go back.

It seems much safer and controllable to have it implemented on a page for which we have navigation events for pages, modals, bottomsheets. You can see how i implemented it in https://github.com/nativescript-community/systemui

@NathanWalker
Copy link
Contributor Author

NathanWalker commented Oct 31, 2025

@farfromrefug unfortunately https://developer.apple.com/documentation/uikit/uiapplication/setstatusbarhidden(_:with:)?language=objc been deprecated since iOS 9. The impl in systemui doesn't account for https://developer.apple.com/documentation/uikit/uiviewcontroller/preferredstatusbarstyle (this impl is what auto handles the cases of modals, setting, closing, going back to original) nor for modal cases via modalPresentationCapturesStatusBarAppearance either; best handled in core since the UIViewController creation derives from there.

@NathanWalker
Copy link
Contributor Author

Although it's possible you could set statusBarStyle on a view (nested), the recommendation is to set on Page or with various flavors where you don't declare a Page directly (thus the changes), can set on the base View which helps those cases as well as modals.

@farfromrefug
Copy link
Collaborator

@farfromrefug unfortunately https://developer.apple.com/documentation/uikit/uiapplication/setstatusbarhidden(_:with:)?language=objc been deprecated since iOS 9. The impl in systemui doesn't account for https://developer.apple.com/documentation/uikit/uiviewcontroller/preferredstatusbarstyle (this impl is what auto handles the cases of modals, setting, closing, going back to original) nor for modal cases via modalPresentationCapturesStatusBarAppearance either; best handled in core since the UIViewController creation derives from there.

OK i understand. Indeed it seems good the way you set it up. thanks

@NathanWalker
Copy link
Contributor Author

Good call @CatchABus updated to include handling android as well now while improving more with iOS:
00af83a

Added a demo page now which switches status bar color when navigating into within toolbox and can also open a modal which changes it again to provide easy to test the behavior.

@NathanWalker
Copy link
Contributor Author

NathanWalker commented Nov 1, 2025

@farfromrefug I added a statusBarStyle check in onLoaded. If defined it will reset it to that particular page style when moving through pages. This solves, for example, the Android case where you navigate into a deep navigation stack with views that change status bar text colors. Now navigating back will restore whichever statusBarStyle each page was. Works on modal views as well 👍 This matches how iOS behaves with it's individual view controller checks (also using statusBarStyle).

[skip ci]
@NathanWalker NathanWalker merged commit e90e6d9 into main Nov 1, 2025
4 checks passed
@NathanWalker NathanWalker deleted the feat/ios-preferredstatusbar-control branch November 1, 2025 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs needed Additional documentation on this issue/PR is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants