You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(Android,**unstable**): integration with react-native-edge-to-edge (#2464)
> [!note]
> note by @kkafar:
> Please note that I merge this as unstable behaviour, since I might
want to remove the dependency & code once we land
facebook/react-native#47554 in core or endup
with only edge-to-edge supported by Android.
## Description
This follow a discussion started [on the react-navigation
repository](react-navigation/react-navigation#12217).
## Motivation
The future of Android is
[edge-to-edge](https://developer.android.com/about/versions/15/behavior-changes-15#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.”
To prevent library authors from implementing their own edge-to-edge
solutions—which could interfere with other libraries—and because it’s
not possible to reliably detect if edge-to-edge is already enabled on
Android, we have collaborated with [Expo](https://expo.dev/) to create a
library that handles this functionality and is detectable using a simple
helper:
[`react-native-is-edge-to-edge`](https://github.com/zoontek/react-native-edge-to-edge/tree/main/react-native-is-edge-to-edge).
This approach allows you to bypass certain options and props (in this
case, `Screen` `statusBarTranslucent`, `navigationBarTranslucent`,
`statusBarColor` and `navigationBarColor` - [setting background color is
deprecated](https://developer.android.com/about/versions/15/behavior-changes-15#deprecated-apis)).
All are Android only props and are now obsolete / deprecated (at least,
when running in edge-to-edge mode)
## Changes
- Add `react-native-is-edge-to-edge` to bypass `statusBarTranslucent`,
`navigationBarTranslucent`, `statusBarColor` and `navigationBarColor`
values
- Add a warning about their usage when running in edge-to-edge mode.
## Test code and steps to reproduce
- Install
[react-native-edge-to-edge](https://github.com/zoontek/react-native-edge-to-edge)
in the Example app.
- Force `react-navigation` to use local version of
`react-native-screens`.
> [!WARNING]
> For the `StatusBar` example, `react-native` `headerTopInsetEnabled`
might interfere when `statusBarTranslucent` is explicitely set to
`false`, but the user will receive a warning inviting him to remove the
option / prop, so that's acceptable.
## More
If you want to bypass some Kotlin code directly, consider this util:
```kotlin
object EdgeToEdgeUtil {
val ENABLED: Boolean
get() = try {
// we cannot detect edge-to-edge, but we can detect react-native-edge-to-edge install
Class.forName("com.zoontek.rnedgetoedge.EdgeToEdgePackage")
true
} catch (exception: ClassNotFoundException) {
false
}
}
```
## Checklist
- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Updated documentation: <!-- For adding new props to native-stack
-->
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx
- [ ] Ensured that CI passes
---------
Co-authored-by: Kacper Kafara <[email protected]>
0 commit comments