Skip to content

Respect theme enforceNavigationBarContrast attribute#56413

Open
zoontek wants to merge 4 commits intofacebook:mainfrom
zoontek:respect-system-bars-styles
Open

Respect theme enforceNavigationBarContrast attribute#56413
zoontek wants to merge 4 commits intofacebook:mainfrom
zoontek:respect-system-bars-styles

Conversation

@zoontek
Copy link
Copy Markdown
Contributor

@zoontek zoontek commented Apr 10, 2026

Summary:

This PR adds respect of the theme's enforceNavigationBarContrast attribute in WindowUtil enableEdgeToEdge (this will allow us to delete our EdgeToEdgePackage.kt file, and prevent a glitch where the navigation bar is semi-opaque for a short instant when user explicitly set android:enforceNavigationBarContrast to false).

Changelog:

[ANDROID] [CHANGED] - Respect theme enforceNavigationBarContrast attribute

Test Plan:

  • Verified edge-to-edge rendering on API 30+ (transparent status/navigation bars, correct display cutout behavior).
  • Verified navigation bar contrast enforcement respects the theme attribute on API 29+ (with android:enforceNavigationBarContrast to true (default) and false).
  • Verified fallback navigation bar colors on API 26-28 (light/dark scrim) and API < 26 (dark scrim).

@meta-cla meta-cla 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 Apr 10, 2026
@zoontek zoontek changed the title Respect system bars styles Use WindowCompat.enableEdgeToEdge() and respect theme enforceNavigationBarContrast attribute Apr 10, 2026
Copy link
Copy Markdown

@rachel11026725 rachel11026725 left a comment

Choose a reason for hiding this comment

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

Please fix

@facebook-github-tools facebook-github-tools bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Apr 10, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 10, 2026

@alanleedev has imported this pull request. If you are a Meta employee, you can view this in D100384656.

@zoontek zoontek changed the title Use WindowCompat.enableEdgeToEdge() and respect theme enforceNavigationBarContrast attribute Respect theme enforceNavigationBarContrast attribute Apr 11, 2026
@zoontek zoontek force-pushed the respect-system-bars-styles branch from d78aed6 to 0ef7a32 Compare April 11, 2026 08:56
Comment on lines +130 to +132
if (enforceNavigationBarContrast) {
insetsController.isAppearanceLightNavigationBars = !isDarkMode
}
Copy link
Copy Markdown
Contributor

@alanleedev alanleedev Apr 14, 2026

Choose a reason for hiding this comment

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

With the new if conditional apps with android:enforceNavigationBarContrast="false" in a light theme will now get light icons on a light background (invisible). It was unconditionally set previously.

It wasn't clear if this was tested; enforceNavigationBarContrast="false" + light theme → nav button icons are still dark/visible

Copy link
Copy Markdown
Contributor Author

@zoontek zoontek Apr 14, 2026

Choose a reason for hiding this comment

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

@alanleedev That's the expected behavior. When android:enforceNavigationBarContrast is set to false, React Native should not update the navigation bar theme and should instead stick to the default (light, similar to the status bar). If we update the default based on the device theme when the user explicitly requests control over the navigation bar button color, it would no longer match the current StatusBar behavior (or the default value in its props stack - which is light in StatusBarModule).

The goal is to rely on external libraries to change the navigation bar theme (such as expo-navigation-bar), since a NavigationBar component is unlikely to ever land in React Native core:

export const App = () => (
  <>
    <StatusBar style="auto" />
    <NavigationBar style="auto" />
  </>
);

Copy link
Copy Markdown
Contributor Author

@zoontek zoontek Apr 14, 2026

Choose a reason for hiding this comment

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

It wasn't clear if this was tested; enforceNavigationBarContrast="false" + light theme → nav button icons are still dark/visible

Don't forget to set enforceNavigationBarContrast in both packages/rn-tester/android/app/src/main/res/values/styles.xml and packages/rn-tester/android/app/src/main/res/values-night/styles.xml to test in both light and dark mode, as those 2 files exist - even if values-night/styles.xml could be deleted, as it has the same content.

@alanleedev
Copy link
Copy Markdown
Contributor

would be great if there are some screenshots

@zoontek
Copy link
Copy Markdown
Contributor Author

zoontek commented Apr 14, 2026

@alanleedev Here is some screenshots, all of them has been made with the StatusBar component commented to preserve the default behavior:

return (
  <RNTesterThemeContext.Provider value={theme}>
    {/* {Platform.OS === 'android' ? (
      <StatusBar
        barStyle="dark-content"
        backgroundColor={theme.GroupedBackgroundColor}
      />
    ) : null} */}
    {/* … */}

Android 7 (DarkNavigationBarColor)

Android 7

Android 9 (LightNavigationBarColor)

Android 9

Android 14 - light mode

Android 14 - light

Android 14 - dark mode

Android 14 - dark

Android 14 - light mode, android:enforceNavigationBarContrast set to false

Android 14 - light, enforced false

Android 14 - dark mode, android:enforceNavigationBarContrast set to false

Android 14 - dark, enforced false

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. p: Expo Partner: Expo Partner 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