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: detect edge-to-edge and bypass some props #2464

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: detect edge-to-edge and bypass some props
# Conflicts:
#	src/components/Screen.tsx
#	yarn.lock
  • Loading branch information
zoontek committed Jan 20, 2025
commit d77500c862efdee359ac984f4c22ca22cccae4df
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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.6",
"warn-once": "^0.1.0"
},
"peerDependencies": {
Expand Down
26 changes: 26 additions & 0 deletions src/components/Screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import React from 'react';
import { Animated, View, Platform } from 'react-native';
import {
controlEdgeToEdgeValues,
isEdgeToEdge,
} from 'react-native-is-edge-to-edge';

import TransitionProgressContext from '../TransitionProgressContext';
import DelayedFreeze from './helpers/DelayedFreeze';
Expand Down Expand Up @@ -49,6 +53,8 @@ interface ViewConfig extends View {
};
}

const EDGE_TO_EDGE = isEdgeToEdge();

// This value must be kept in sync with native side.
const SHEET_FIT_TO_CONTENTS = [-1];
const SHEET_COMPAT_LARGE = [1.0];
Expand Down Expand Up @@ -178,9 +184,25 @@ export const InnerScreen = React.forwardRef<View, ScreenProps>(
enabled = screensEnabled(),
freezeOnBlur = freezeEnabled(),
shouldFreeze,

// edge-to-edge related props
navigationBarColor,
navigationBarTranslucent,
statusBarColor,
statusBarTranslucent,

...rest
} = props;

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

// To maintain default behavior of formSheet stack presentation style and to have reasonable
// defaults for new medium-detent iOS API we need to set defaults here
const {
Expand Down Expand Up @@ -280,6 +302,10 @@ export const InnerScreen = React.forwardRef<View, ScreenProps>(
<DelayedFreeze freeze={freeze}>
<AnimatedScreen
{...props}
navigationBarColor={EDGE_TO_EDGE ? undefined : navigationBarColor}
navigationBarTranslucent={EDGE_TO_EDGE || navigationBarTranslucent}
statusBarColor={EDGE_TO_EDGE ? undefined : statusBarColor}
statusBarTranslucent={EDGE_TO_EDGE || statusBarTranslucent}
/**
* This messy override is to conform NativeProps used by codegen and
* our Public API. To see reasoning go to this PR:
Expand Down
Loading