@@ -5,9 +5,10 @@ import {
5
5
BottomSheetView as RNBottomSheetView ,
6
6
} from '@gorhom/bottom-sheet' ;
7
7
import { ParamListBase , useTheme } from '@react-navigation/native' ;
8
- import { FullWindowOverlay } from 'react-native-screens' ;
9
- import { SafeAreaProvider } from 'react-native-safe-area-context' ;
10
8
import * as React from 'react' ;
9
+ import { Platform , StyleSheet } from 'react-native' ;
10
+ import { SafeAreaProvider } from 'react-native-safe-area-context' ;
11
+ import { FullWindowOverlay } from 'react-native-screens' ;
11
12
import type {
12
13
BottomSheetDescriptorMap ,
13
14
BottomSheetNavigationConfig ,
@@ -20,6 +21,24 @@ type BottomSheetModalScreenProps = BottomSheetModalProps & {
20
21
navigation : BottomSheetNavigationProp < ParamListBase > ;
21
22
} ;
22
23
24
+ function Overlay ( { children } : { children : React . ReactNode } ) {
25
+ if ( Platform . OS === 'ios' ) {
26
+ return (
27
+ < FullWindowOverlay >
28
+ < SafeAreaProvider style = { styles . safeAreaProvider } >
29
+ { children }
30
+ </ SafeAreaProvider >
31
+ </ FullWindowOverlay >
32
+ ) ;
33
+ } else {
34
+ return (
35
+ < SafeAreaProvider style = { styles . safeAreaProvider } >
36
+ { children }
37
+ </ SafeAreaProvider >
38
+ ) ;
39
+ }
40
+ }
41
+
23
42
function BottomSheetModalScreen ( {
24
43
index,
25
44
navigation,
@@ -117,53 +136,55 @@ export function BottomSheetView({ state, descriptors }: Props) {
117
136
return (
118
137
< >
119
138
{ firstScreen . render ( ) }
120
- < FullWindowOverlay >
121
- < SafeAreaProvider style = { { flex : 1 , pointerEvents : 'box-none' } } >
122
- { shouldRenderProvider . current && (
123
- < BottomSheetModalProvider >
124
- { state . routes . slice ( 1 ) . map ( ( route ) => {
125
- const { options, navigation, render } = descriptors [ route . key ] ;
126
-
127
- const {
128
- index,
129
- backgroundStyle,
130
- handleIndicatorStyle,
131
- snapPoints,
132
- enableDynamicSizing,
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 != null ? snapPoints . length - 1 : 0 ,
144
- ) }
145
- snapPoints = {
146
- snapPoints == null && ! enableDynamicSizing
147
- ? DEFAULT_SNAP_POINTS
148
- : snapPoints
149
- }
150
- enableDynamicSizing = { enableDynamicSizing }
151
- navigation = { navigation }
152
- backgroundStyle = { [ themeBackgroundStyle , backgroundStyle ] }
153
- handleIndicatorStyle = { [
154
- themeHandleIndicatorStyle ,
155
- handleIndicatorStyle ,
156
- ] }
157
- { ...sheetProps }
158
- >
159
- { render ( ) }
160
- </ BottomSheetModalScreen >
161
- ) ;
162
- } ) }
163
- </ BottomSheetModalProvider >
164
- ) }
165
- </ SafeAreaProvider >
166
- </ FullWindowOverlay >
139
+ < Overlay >
140
+ { shouldRenderProvider . current && (
141
+ < BottomSheetModalProvider >
142
+ { state . routes . slice ( 1 ) . map ( ( route ) => {
143
+ const { options, navigation, render } = descriptors [ route . key ] ;
144
+
145
+ const {
146
+ index,
147
+ backgroundStyle,
148
+ handleIndicatorStyle,
149
+ snapPoints,
150
+ enableDynamicSizing,
151
+ ...sheetProps
152
+ } = options ;
153
+
154
+ return (
155
+ < BottomSheetModalScreen
156
+ key = { route . key }
157
+ // Make sure index is in range, it could be out if snapToIndex is persisted
158
+ // and snapPoints is changed.
159
+ index = { Math . min (
160
+ route . snapToIndex ?? index ?? 0 ,
161
+ snapPoints != null ? snapPoints . length - 1 : 0 ,
162
+ ) }
163
+ snapPoints = {
164
+ snapPoints == null && ! enableDynamicSizing
165
+ ? DEFAULT_SNAP_POINTS
166
+ : snapPoints
167
+ }
168
+ enableDynamicSizing = { enableDynamicSizing }
169
+ navigation = { navigation }
170
+ backgroundStyle = { [ themeBackgroundStyle , backgroundStyle ] }
171
+ handleIndicatorStyle = { [
172
+ themeHandleIndicatorStyle ,
173
+ handleIndicatorStyle ,
174
+ ] }
175
+ { ...sheetProps }
176
+ >
177
+ { render ( ) }
178
+ </ BottomSheetModalScreen >
179
+ ) ;
180
+ } ) }
181
+ </ BottomSheetModalProvider >
182
+ ) }
183
+ </ Overlay >
167
184
</ >
168
185
) ;
169
186
}
187
+
188
+ const styles = StyleSheet . create ( {
189
+ safeAreaProvider : { flex : 1 , pointerEvents : 'box-none' } ,
190
+ } ) ;
0 commit comments