-
-
Notifications
You must be signed in to change notification settings - Fork 519
/
Test1096.tsx
95 lines (88 loc) · 2.32 KB
/
Test1096.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import * as React from 'react';
import { Button, StyleSheet, View, Modal } from 'react-native';
import { FullWindowOverlay } from 'react-native-screens';
import {
createNativeStackNavigator,
NativeStackNavigationProp,
} from '@react-navigation/native-stack';
import { NavigationContainer, ParamListBase } from '@react-navigation/native';
function Home({
navigation,
}: {
navigation: NativeStackNavigationProp<ParamListBase>;
}) {
const [isShowModal, setIsShowModal] = React.useState(false);
return (
<View style={styles.container}>
<Button title="show rn modal" onPress={() => setIsShowModal(true)} />
<Button
title="Go to RNScreens modal"
onPress={() => navigation.navigate('Modal')}
/>
<Modal
animationType="slide"
visible={isShowModal}
presentationStyle="pageSheet">
<View style={styles.container}>
<Button
title="dismiss rn modal"
onPress={() => setIsShowModal(false)}
/>
</View>
</Modal>
<FullWindowOverlay>
<View style={styles.overlay} pointerEvents="box-none">
<View style={styles.box} />
<Button title="click me" onPress={() => console.warn('clicked')} />
</View>
</FullWindowOverlay>
</View>
);
}
function ModalScreen({
navigation,
}: {
navigation: NativeStackNavigationProp<ParamListBase>;
}) {
return (
<View style={styles.container}>
<Button title="dismiss modal" onPress={() => navigation.goBack()} />
</View>
);
}
const NativeStack = createNativeStackNavigator();
export default function App() {
return (
<NavigationContainer>
<NativeStack.Navigator>
<NativeStack.Screen name="Home" component={Home} />
<NativeStack.Screen
name="Modal"
component={ModalScreen}
options={{ presentation: 'modal' }}
/>
</NativeStack.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'flex-start',
justifyContent: 'center',
},
overlay: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: `rgba(0,0,0,0.5)`,
},
box: {
width: 40,
height: 40,
borderRadius: 10,
borderWidth: 2,
borderColor: 'black',
backgroundColor: 'red',
},
});