-
-
Notifications
You must be signed in to change notification settings - Fork 539
/
Copy pathTest1096.tsx
89 lines (81 loc) · 2.21 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
import * as React from 'react';
import { Button, StyleSheet, View, Modal } from 'react-native';
import {FullWindowOverlay} from 'react-native-screens';
import {
createNativeStackNavigator,
NativeStackNavigationProp,
} from 'react-native-screens/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 style={{position: 'absolute', width: '100%', height: '100%', justifyContent: 'center'}}>
<View style={styles.box} />
<Button title="click me" onPress={() => console.warn('clicked')} />
</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={{ stackPresentation: 'modal' }}
/>
</NativeStack.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'flex-start',
justifyContent: 'center',
},
box: {
width: 40,
height: 40,
borderRadius: 10,
borderWidth: 2,
borderColor: 'black',
backgroundColor: 'red',
},
});