Skip to content

feat(Android,**unstable**): integration with react-native-edge-to-edge #2464

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

Merged
merged 11 commits into from
Apr 18, 2025
Merged
1 change: 1 addition & 0 deletions Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"nanoid": "^4.0.2",
"react": "19.0.0",
"react-native": "0.78.0-rc.5",
"react-native-edge-to-edge": "^1.6.0",
"react-native-gesture-handler": "2.22.0",
"react-native-reanimated": "3.17.1",
"react-native-restart": "^0.0.27",
Expand Down
11 changes: 11 additions & 0 deletions Example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3101,6 +3101,7 @@ __metadata:
react: "npm:19.0.0"
react-native: "npm:0.78.0-rc.5"
react-native-codegen: "npm:^0.71.3"
react-native-edge-to-edge: "npm:^1.6.0"
react-native-gesture-handler: "npm:2.22.0"
react-native-reanimated: "npm:3.17.1"
react-native-restart: "npm:^0.0.27"
Expand Down Expand Up @@ -8859,6 +8860,16 @@ __metadata:
languageName: node
linkType: hard

"react-native-edge-to-edge@npm:^1.6.0":
version: 1.6.0
resolution: "react-native-edge-to-edge@npm:1.6.0"
peerDependencies:
react: "*"
react-native: "*"
checksum: 10c0/6373cc1b447eae31689a9b62e38b15621e9273626e2324700c4c3eb58c02ce489236a4b9e3e0dc1187e062defd8316195c5b1213facd718706b79b92127a05a3
languageName: node
linkType: hard

"react-native-gesture-handler@npm:2.22.0":
version: 2.22.0
resolution: "react-native-gesture-handler@npm:2.22.0"
Expand Down
1 change: 1 addition & 0 deletions FabricExample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"nanoid": "^4.0.2",
"react": "19.0.0",
"react-native": "0.78.0-rc.5",
"react-native-edge-to-edge": "^1.6.0",
"react-native-gesture-handler": "2.22.0",
"react-native-reanimated": "^4.0.0-nightly-20250218-e5a0cdf69",
"react-native-restart": "^0.0.27",
Expand Down
11 changes: 11 additions & 0 deletions FabricExample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2952,6 +2952,7 @@ __metadata:
prettier: "npm:2.8.8"
react: "npm:19.0.0"
react-native: "npm:0.78.0-rc.5"
react-native-edge-to-edge: "npm:^1.6.0"
react-native-gesture-handler: "npm:2.22.0"
react-native-reanimated: "npm:^4.0.0-nightly-20250218-e5a0cdf69"
react-native-restart: "npm:^0.0.27"
Expand Down Expand Up @@ -8525,6 +8526,16 @@ __metadata:
languageName: node
linkType: hard

"react-native-edge-to-edge@npm:^1.6.0":
version: 1.6.0
resolution: "react-native-edge-to-edge@npm:1.6.0"
peerDependencies:
react: "*"
react-native: "*"
checksum: 10c0/6373cc1b447eae31689a9b62e38b15621e9273626e2324700c4c3eb58c02ce489236a4b9e3e0dc1187e062defd8316195c5b1213facd718706b79b92127a05a3
languageName: node
linkType: hard

"react-native-gesture-handler@npm:2.22.0":
version: 2.22.0
resolution: "react-native-gesture-handler@npm:2.22.0"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"homepage": "https://github.com/software-mansion/react-native-screens#readme",
"dependencies": {
"react-freeze": "^1.0.0",
"react-native-is-edge-to-edge": "^1.1.7",
"warn-once": "^0.1.0"
},
"peerDependencies": {
Expand Down
9 changes: 8 additions & 1 deletion src/components/Screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import React from 'react';
import { Animated, View, Platform } from 'react-native';

import { EDGE_TO_EDGE, transformEdgeToEdgeProps } from './helpers/edge-to-edge';

import TransitionProgressContext from '../TransitionProgressContext';
import DelayedFreeze from './helpers/DelayedFreeze';
import { ScreenProps } from '../types';
Expand Down Expand Up @@ -165,7 +167,7 @@
React.useImperativeHandle(ref, () => innerRef.current!, []);
const prevActivityState = usePrevious(props.activityState);

const setRef = (ref: ViewConfig) => {

Check warning on line 170 in src/components/Screen.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

'ref' is already declared in the upper scope on line 165 column 31
innerRef.current = ref;
props.onComponentRef?.(ref);
};
Expand Down Expand Up @@ -242,7 +244,7 @@
gestureResponseDistance,
onGestureCancel,
style,
...props

Check warning on line 247 in src/components/Screen.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

'props' is already declared in the upper scope on line 165 column 24
} = rest;

if (active !== undefined && activityState === undefined) {
Expand All @@ -264,7 +266,7 @@
}
}

const handleRef = (ref: ViewConfig) => {

Check warning on line 269 in src/components/Screen.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

'ref' is already declared in the upper scope on line 165 column 31
// Workaround is necessary to prevent React Native from hiding frozen screens.
// See this PR: https://github.com/grahammendick/navigation/pull/860
if (ref?.viewConfig?.validAttributes?.style) {
Expand Down Expand Up @@ -367,7 +369,7 @@
style,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
onComponentRef,
...props

Check warning on line 372 in src/components/Screen.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

'props' is already declared in the upper scope on line 165 column 24
} = rest;

if (active !== undefined && activityState === undefined) {
Expand All @@ -375,7 +377,7 @@
}
return (
<Animated.View
style={[style, { display: activityState !== 0 ? 'flex' : 'none' }]}

Check warning on line 380 in src/components/Screen.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

Inline style: { display: "activityState !== 0 ? 'flex' : 'none'" }
ref={setRef}
{...props}
/>
Expand All @@ -391,7 +393,12 @@
const Screen = React.forwardRef<View, ScreenProps>((props, ref) => {
const ScreenWrapper = React.useContext(ScreenContext) || InnerScreen;

return <ScreenWrapper {...props} ref={ref} />;
return (
<ScreenWrapper
{...(EDGE_TO_EDGE ? transformEdgeToEdgeProps(props) : props)}
ref={ref}
/>
);
});

Screen.displayName = 'Screen';
Expand Down
2 changes: 2 additions & 0 deletions src/components/ScreenStackHeaderConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
// Native components
import ScreenStackHeaderConfigNativeComponent from '../fabric/ScreenStackHeaderConfigNativeComponent';
import ScreenStackHeaderSubviewNativeComponent from '../fabric/ScreenStackHeaderSubviewNativeComponent';
import { EDGE_TO_EDGE } from './helpers/edge-to-edge';

export const ScreenStackHeaderSubview: React.ComponentType<
React.PropsWithChildren<ViewProps & { type?: HeaderSubviewTypes }>
> = ScreenStackHeaderSubviewNativeComponent as any;

Check warning on line 25 in src/components/ScreenStackHeaderConfig.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

Unexpected any. Specify a different type

export const ScreenStackHeaderConfig = React.forwardRef<
View,
Expand All @@ -30,6 +31,7 @@
<ScreenStackHeaderConfigNativeComponent
{...props}
ref={ref}
topInsetEnabled={EDGE_TO_EDGE ? true : props.topInsetEnabled}
style={styles.headerConfig}
pointerEvents="box-none"
/>
Expand Down
33 changes: 33 additions & 0 deletions src/components/helpers/edge-to-edge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
controlEdgeToEdgeValues,
isEdgeToEdge,
} from 'react-native-is-edge-to-edge';
import { ScreenProps } from '../../types';

export const EDGE_TO_EDGE = isEdgeToEdge();

export function transformEdgeToEdgeProps(props: ScreenProps): ScreenProps {
const {
// Filter out edge-to-edge related props
statusBarColor,
statusBarTranslucent,
navigationBarColor,
navigationBarTranslucent,
...rest
} = props;

if (__DEV__) {
controlEdgeToEdgeValues({
statusBarColor,
statusBarTranslucent,
navigationBarColor,
navigationBarTranslucent,
});
}

return {
...rest,
statusBarTranslucent: true,
navigationBarTranslucent: true,
};
}
Loading
Loading