Skip to content

Add edge-to-edge opt-in support #52088

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zoontek
Copy link
Contributor

@zoontek zoontek commented Jun 17, 2025

Summary:

This follows #47554

Compared to the initial proposal, I had to remove the edgeToEdgeEnabled property from the root gradle.properties and put it in the app gradle.properties instead (explaining the AgpConfiguratorUtils.kt / GenerateEntryPointTask.kt / ProjectUtils.kt / PropertyUtils.kt changes)

This PR:

  • Enable edge-to-edge for MainActivity (when edgeToEdgeEnabled is set to true)
  • Disable StatusBar backgroundColor and translucent (when edgeToEdgeEnabled is set to true)
  • Enforce statusBarTranslucent and navigationBarTranslucent on Modal when edge-to-edge is enabled
  • Add an isEdgeToEdge constant to DeviceInfoModule for react-native-is-edge-to-edge detection

Changelog:

  • [Android] [Added] - Add edge-to-edge opt-in support

Test Plan:

  • Update enableEdgeToEdge value in packages/rn-tester/android/app/gradle.properties
  • Recompile
demo.mp4

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

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

@facebook-github-bot
Copy link
Contributor

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

@zoontek
Copy link
Contributor Author

zoontek commented Jun 20, 2025

@sbuggay Do you need me to rebase?

@cortinico
Copy link
Contributor

@sbuggay Do you need me to rebase?

Yeah that would be good. Also this PR is now driven by @alanleedev

@zoontek zoontek force-pushed the add-enable-edge-to-edge branch 2 times, most recently from 0515f30 to 63da6e7 Compare June 20, 2025 14:40
@zoontek
Copy link
Contributor Author

zoontek commented Jun 20, 2025

@cortinico @alanleedev Commits squashed + branch rebased against main

@zoontek zoontek force-pushed the add-enable-edge-to-edge branch from c431f28 to b1614e2 Compare June 20, 2025 14:44
@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.

@alanleedev
Copy link
Contributor

@zoontek Need to fix code here: https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCxxPlatform/react/coremodules/DeviceInfoModule.h#L31

using DeviceInfoConstants = NativeDeviceInfoDeviceInfoConstants<
    DimensionsPayload,
    std::optional<bool>,
    std::optional<bool>>;

@zoontek
Copy link
Contributor Author

zoontek commented Jun 23, 2025

@alanleedev Done ✅

internal val Project.isEdgeToEdgeEnabled: Boolean
get() =
(project.hasProperty(EDGE_TO_EDGE_ENABLED) &&
project.property(EDGE_TO_EDGE_ENABLED).toString().toBoolean()) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
project.property(EDGE_TO_EDGE_ENABLED).toString().toBoolean()) ||
Boolean.parseBoolean(project.property(EDGE_TO_EDGE_ENABLED)) ||

@@ -121,6 +122,9 @@ public void onCreate(Bundle savedInstanceState) {
() -> {
String mainComponentName = getMainComponentName();
final Bundle launchOptions = composeLaunchOptions();
if (WindowUtilKt.isEdgeToEdgeFeatureFlagOn() && mActivity != null) {
WindowUtilKt.enableEdgeToEdge(mActivity.getWindow());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got a lint warning here as mActivity.getWindow() is nullable so may need to add a null check.

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. 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.

4 participants