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

feat(android): Edge-to-edge Modal (navigationBarTranslucent prop) #47254

Closed

Conversation

zoontek
Copy link
Contributor

@zoontek zoontek commented Oct 28, 2024

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 separate Window) and only provide a statusBarTranslucent prop.

I tried to implement it in react-native-edge-to-edge by listening to the topShow 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 without statusBarTranslucent, 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

  • Colors used for the buttons navigation bar in the PR are the default Android ones (light and dark)
  • Compared to the Google implementation, the light scrim is applied from O_MR1 to Q (and not O to Q) as the android:windowLightNavigationBar style attribute is not available on O (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

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Oct 28, 2024
@facebook-github-bot
Copy link
Contributor

@alanleedev has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@alanleedev merged this pull request in 7a6c7a4.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Nov 7, 2024
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @zoontek in 7a6c7a4

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants