1
- import { PortalHost , useModalPortalRoot } from '@rn-primitives/portal' ;
1
+ import { PortalHost } from '@rn-primitives/portal' ;
2
2
import * as React from 'react' ;
3
- import { View } from 'react-native' ;
3
+ import { Platform , View } from 'react-native' ;
4
4
import { useSafeAreaInsets } from 'react-native-safe-area-context' ;
5
+ import { FullWindowOverlay } from 'react-native-screens' ;
5
6
import { Button } from '~/components/ui/button' ;
6
7
import { Input } from '~/components/ui/input' ;
7
8
import {
@@ -16,18 +17,20 @@ import {
16
17
import { Text } from '~/components/ui/text' ;
17
18
import { H1 , Muted } from '~/components/ui/typography' ;
18
19
20
+ const CUSTOM_PORTAL_HOST_NAME = 'modal-example' ;
21
+ const WindowOverlay = Platform . OS === 'ios' ? FullWindowOverlay : React . Fragment ;
22
+
19
23
export default function ModalScreen ( ) {
20
24
const insets = useSafeAreaInsets ( ) ;
21
- const { sideOffset, ...rootProps } = useModalPortalRoot ( ) ;
22
25
const contentInsets = {
23
26
top : insets . top ,
24
- bottom : insets . bottom + Math . abs ( sideOffset ) ,
27
+ bottom : insets . bottom ,
25
28
left : 16 ,
26
29
right : 16 ,
27
30
} ;
28
31
29
32
return (
30
- < View { ... rootProps } >
33
+ < >
31
34
< View className = 'flex-1 justify-center items-center' >
32
35
< View className = 'p-4 native:pb-24 max-w-md gap-6' >
33
36
< View className = 'gap-1' >
@@ -46,9 +49,8 @@ export default function ModalScreen() {
46
49
</ SelectTrigger >
47
50
< SelectContent
48
51
insets = { contentInsets }
49
- sideOffset = { sideOffset }
50
52
className = 'w-full'
51
- portalHost = 'modal-example'
53
+ portalHost = { CUSTOM_PORTAL_HOST_NAME }
52
54
>
53
55
< SelectGroup >
54
56
< SelectLabel > Roles</ SelectLabel >
@@ -81,7 +83,9 @@ export default function ModalScreen() {
81
83
</ View >
82
84
</ View >
83
85
</ View >
84
- < PortalHost name = 'modal-example' />
85
- </ View >
86
+ < WindowOverlay >
87
+ < PortalHost name = { CUSTOM_PORTAL_HOST_NAME } />
88
+ </ WindowOverlay >
89
+ </ >
86
90
) ;
87
91
}
0 commit comments