feat(android): Edge-to-edge Modal (navigationBarTranslucent prop) #47254
+117
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
The future of Android is edge-to-edge and to make the React Native developer experience seamless in this regard, the ecosystem needs to transition from “opaque system bars by default” to “edge-to-edge by default.”
Currently, there's no easy way to have edge-to-edge modals, as they are implemented using
Dialog
instances (a separateWindow
) and only provide astatusBarTranslucent
prop.I tried to implement it in
react-native-edge-to-edge
by listening to thetopShow
UIManager
event. But if it works well when there's a defined animation, we can see a quick jump when there's none, because there's too much delay before the event, and edge-to-edge cannot be applied quick enough to the dialog window.react-native-edge-to-edge implem with animation (no jump)
no-bug-jump-anim.mov
react-native-edge-to-edge implem without animation (jump)
bug-jump-no-anim.mov
For this reason, and because listening to event feels a bit hacky, I think it will be better to go for a new prop directly on RN Modal component:
navigationBarTranslucent
Note
navigationBarTranslucent
cannot be used withoutstatusBarTranslucent
, as setting both enable edge-to-edge, like AndroidX would do and it would requires extra (and unecessary, given the direction Android is taking) work to find a way to keep the status bar opaque but the navigation bar transparent that work on Android 6 to 15+Additional infos
O_MR1
toQ
(and notO
toQ
) as theandroid:windowLightNavigationBar
style attribute is not available onO
(it can only be applied programmatically on API 26).Changelog:
[ANDROID] [ADDED] - Add navigationBarTranslucent prop to Modal component
Test Plan:
Run the tester app, toggle
navigationBarTranslucent
:rn-tester.mov