Skip to content

Commit 144f034

Browse files
fix: react-native-screens integration
1 parent 0464132 commit 144f034

File tree

3 files changed

+81
-49
lines changed

3 files changed

+81
-49
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
"@react-navigation/native": "^6.0.10",
4848
"@release-it/conventional-changelog": "^5.0.0",
4949
"@types/jest": "^28.1.1",
50-
"@types/react": "~17.0.21",
51-
"@types/react-native": "0.67.8",
50+
"@types/react": "^18.2.15",
51+
"@types/react-native": "^0.72.2",
5252
"commitlint": "^17.0.2",
5353
"eslint": "^7.2.0",
5454
"eslint-config-prettier": "^8.5.0",
@@ -59,13 +59,15 @@
5959
"prettier": "^2.6.2",
6060
"react": "17.0.2",
6161
"react-native": "0.68.2",
62+
"react-native-screens": "^3.22.1",
6263
"react-native-builder-bob": "^0.18.2",
6364
"release-it": "^15.0.0",
6465
"typescript": "^4.7.3"
6566
},
6667
"peerDependencies": {
6768
"react": "*",
6869
"react-native": "*",
70+
"react-native-screens": "*",
6971
"@react-navigation/native": "*",
7072
"@gorhom/bottom-sheet": "*"
7173
},

src/BottomSheetView.tsx

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '@gorhom/bottom-sheet';
88
import { ParamListBase, useTheme } from '@react-navigation/native';
99
import * as React from 'react';
10+
import { FullWindowOverlay } from 'react-native-screens';
1011
import type {
1112
BottomSheetDescriptorMap,
1213
BottomSheetNavigationConfig,
@@ -121,45 +122,47 @@ export function BottomSheetView({ state, descriptors }: Props) {
121122
<>
122123
{firstScreen.render()}
123124
{shouldRenderProvider.current && (
124-
<BottomSheetModalProvider>
125-
{state.routes.slice(1).map((route) => {
126-
const { options, navigation, render } = descriptors[route.key];
127-
128-
const {
129-
index,
130-
backgroundStyle,
131-
handleIndicatorStyle,
132-
snapPoints = animatedSnapPoints.value,
133-
...sheetProps
134-
} = options;
135-
136-
return (
137-
<BottomSheetModalScreen
138-
key={route.key}
139-
// Make sure index is in range, it could be out if snapToIndex is persisted
140-
// and snapPoints is changed.
141-
index={Math.min(
142-
route.snapToIndex ?? index ?? 0,
143-
snapPoints.length - 1,
144-
)}
145-
contentHeight={animatedContentHeight}
146-
handleHeight={animatedHandleHeight}
147-
snapPoints={snapPoints}
148-
navigation={navigation}
149-
backgroundStyle={[themeBackgroundStyle, backgroundStyle]}
150-
handleIndicatorStyle={[
151-
themeHandleIndicatorStyle,
152-
handleIndicatorStyle,
153-
]}
154-
{...sheetProps}
155-
>
156-
<RNBottomSheetView onLayout={handleContentLayout}>
157-
{render()}
158-
</RNBottomSheetView>
159-
</BottomSheetModalScreen>
160-
);
161-
})}
162-
</BottomSheetModalProvider>
125+
<FullWindowOverlay>
126+
<BottomSheetModalProvider>
127+
{state.routes.slice(1).map((route) => {
128+
const { options, navigation, render } = descriptors[route.key];
129+
130+
const {
131+
index,
132+
backgroundStyle,
133+
handleIndicatorStyle,
134+
snapPoints = animatedSnapPoints.value,
135+
...sheetProps
136+
} = options;
137+
138+
return (
139+
<BottomSheetModalScreen
140+
key={route.key}
141+
// Make sure index is in range, it could be out if snapToIndex is persisted
142+
// and snapPoints is changed.
143+
index={Math.min(
144+
route.snapToIndex ?? index ?? 0,
145+
snapPoints.length - 1,
146+
)}
147+
contentHeight={animatedContentHeight}
148+
handleHeight={animatedHandleHeight}
149+
snapPoints={snapPoints}
150+
navigation={navigation}
151+
backgroundStyle={[themeBackgroundStyle, backgroundStyle]}
152+
handleIndicatorStyle={[
153+
themeHandleIndicatorStyle,
154+
handleIndicatorStyle,
155+
]}
156+
{...sheetProps}
157+
>
158+
<RNBottomSheetView onLayout={handleContentLayout}>
159+
{render()}
160+
</RNBottomSheetView>
161+
</BottomSheetModalScreen>
162+
);
163+
})}
164+
</BottomSheetModalProvider>
165+
</FullWindowOverlay>
163166
)}
164167
</>
165168
);

yarn.lock

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,6 +1925,14 @@
19251925
resolved "https://registry.yarnpkg.com/@react-native/polyfills/-/polyfills-2.0.0.tgz#4c40b74655c83982c8cf47530ee7dc13d957b6aa"
19261926
integrity sha512-K0aGNn1TjalKj+65D7ycc1//H9roAQ51GJVk5ZJQFb2teECGmzd86bYDC0aYdbRf7gtovescq4Zt6FR0tgXiHQ==
19271927

1928+
"@react-native/virtualized-lists@^0.72.4":
1929+
version "0.72.6"
1930+
resolved "https://registry.yarnpkg.com/@react-native/virtualized-lists/-/virtualized-lists-0.72.6.tgz#375f88a1371927d803afad8d8a0ede3261464030"
1931+
integrity sha512-JhT6ydu35LvbSKdwnhWDuGHMOwM0WAh9oza/X8vXHA8ELHRyQ/4p8eKz/bTQcbQziJaaleUURToGhFuCtgiMoA==
1932+
dependencies:
1933+
invariant "^2.2.4"
1934+
nullthrows "^1.1.1"
1935+
19281936
"@react-navigation/core@^6.2.1":
19291937
version "6.2.1"
19301938
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-6.2.1.tgz#90459f9afd25b71a9471b0706ebea2cdd2534fc4"
@@ -2176,11 +2184,12 @@
21762184
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf"
21772185
integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==
21782186

2179-
"@types/react-native@0.67.8":
2180-
version "0.67.8"
2181-
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.67.8.tgz#edaaa0527b835fffbfc34c09874722b6e4a4d1f3"
2182-
integrity sha512-xA8rYiTHvO6RoZv/LFnmEeqRuhA2y34mGB8zX3bGHe/pCt9jEStUPyUO4q1KcDc9GiGIOBD8ArfRtThprAjSfQ==
2187+
"@types/react-native@^0.72.2":
2188+
version "0.72.2"
2189+
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.72.2.tgz#27c931a899c555b28e20cdd12e570b017808de96"
2190+
integrity sha512-/eEjr04Zqo7mTMszuSdrLx90+j5nWhDMMOgtnKZfAYyV3RwmlpSb7F17ilmMMxZWJY81n/JZ4e6wdhMJFpjrCg==
21832191
dependencies:
2192+
"@react-native/virtualized-lists" "^0.72.4"
21842193
"@types/react" "*"
21852194

21862195
"@types/react@*":
@@ -2192,10 +2201,10 @@
21922201
"@types/scheduler" "*"
21932202
csstype "^3.0.2"
21942203

2195-
"@types/react@~17.0.21":
2196-
version "17.0.45"
2197-
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.45.tgz#9b3d5b661fd26365fefef0e766a1c6c30ccf7b3f"
2198-
integrity sha512-YfhQ22Lah2e3CHPsb93tRwIGNiSwkuz1/blk4e6QrWS0jQzCSNbGLtOEYhPg02W0yGTTmpajp7dCTbBAMN3qsg==
2204+
"@types/react@^18.2.15":
2205+
version "18.2.15"
2206+
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.15.tgz#14792b35df676c20ec3cf595b262f8c615a73066"
2207+
integrity sha512-oEjE7TQt1fFTFSbf8kkNuc798ahTUzn3Le67/PWjE8MAfYAD/qB7O8hSTcromLFqHCt9bcdOg5GXMokzTjJ5SA==
21992208
dependencies:
22002209
"@types/prop-types" "*"
22012210
"@types/scheduler" "*"
@@ -7911,6 +7920,11 @@ react-devtools-core@^4.23.0:
79117920
shell-quote "^1.6.1"
79127921
ws "^7"
79137922

7923+
react-freeze@^1.0.0:
7924+
version "1.0.3"
7925+
resolved "https://registry.yarnpkg.com/react-freeze/-/react-freeze-1.0.3.tgz#5e3ca90e682fed1d73a7cb50c2c7402b3e85618d"
7926+
integrity sha512-ZnXwLQnGzrDpHBHiC56TXFXvmolPeMjTn1UOm610M4EXGzbEDR7oOIyS2ZiItgbs6eZc4oU/a0hpk8PrcKvv5g==
7927+
79147928
"react-is@^16.12.0 || ^17.0.0", react-is@^17.0.1:
79157929
version "17.0.2"
79167930
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
@@ -7977,6 +7991,14 @@ react-native-redash@^16.1.1:
79777991
normalize-svg-path "^1.0.1"
79787992
parse-svg-path "^0.1.2"
79797993

7994+
react-native-screens@^3.22.1:
7995+
version "3.22.1"
7996+
resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-3.22.1.tgz#b0eb0696dbf1f9a852061cc71c0f8cdb95ed8e53"
7997+
integrity sha512-ffzwUdVKf+iLqhWSzN5DXBm0s2w5sN0P+TaHHPAx42LT7+DT0g8PkHT1QDvxpR5vCEPSS1i3EswyVK4HCuhTYg==
7998+
dependencies:
7999+
react-freeze "^1.0.0"
8000+
warn-once "^0.1.0"
8001+
79808002
react-native@0.68.2:
79818003
version "0.68.2"
79828004
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.68.2.tgz#07547cd31bb9335a7fa4135cfbdc24e067142585"
@@ -9524,6 +9546,11 @@ walker@^1.0.7, walker@^1.0.8:
95249546
dependencies:
95259547
makeerror "1.0.12"
95269548

9549+
warn-once@^0.1.0:
9550+
version "0.1.1"
9551+
resolved "https://registry.yarnpkg.com/warn-once/-/warn-once-0.1.1.tgz#952088f4fb56896e73fd4e6a3767272a3fccce43"
9552+
integrity sha512-VkQZJbO8zVImzYFteBXvBOZEl1qL175WH8VmZcxF2fZAoudNhNDvHi+doCaAEdU2l2vtcIwa2zn0QK5+I1HQ3Q==
9553+
95279554
wcwidth@^1.0.1:
95289555
version "1.0.1"
95299556
resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"

0 commit comments

Comments
 (0)