|
@@ -0,0 +1,74 @@
|
|
1
|
+import * as React from 'react';
|
|
2
|
+import { Text, View, Button } from 'react-native';
|
|
3
|
+import { NavigationContainer } from '@react-navigation/native';
|
|
4
|
+import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
5
|
+import { createNativeStackNavigator } from 'react-native-screens/native-stack';
|
|
6
|
+import type { StackScreenProps } from '@react-navigation/stack';
|
|
7
|
+
|
|
8
|
+type Routes = {
|
|
9
|
+ Home: undefined;
|
|
10
|
+ Details: undefined;
|
|
11
|
+ Settings: undefined;
|
|
12
|
+};
|
|
13
|
+
|
|
14
|
+function HomeScreen({ navigation }: StackScreenProps<Routes, 'Home'>) {
|
|
15
|
+ return (
|
|
16
|
+ <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
|
17
|
+ <Text>Home Screen</Text>
|
|
18
|
+ <Button
|
|
19
|
+ title="Go to Details"
|
|
20
|
+ onPress={() => navigation.navigate('Details')}
|
|
21
|
+ />
|
|
22
|
+ </View>
|
|
23
|
+ );
|
|
24
|
+}
|
|
25
|
+
|
|
26
|
+function SettingsScreen({ navigation }: StackScreenProps<Routes, 'Settings'>) {
|
|
27
|
+ return (
|
|
28
|
+ <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
|
29
|
+ <Text>Settings Screen</Text>
|
|
30
|
+ <Button
|
|
31
|
+ title="Go to Details"
|
|
32
|
+ onPress={() => navigation.navigate('Details')}
|
|
33
|
+ />
|
|
34
|
+ </View>
|
|
35
|
+ );
|
|
36
|
+}
|
|
37
|
+
|
|
38
|
+const Tab = createBottomTabNavigator();
|
|
39
|
+
|
|
40
|
+function TabsScreen() {
|
|
41
|
+ return (
|
|
42
|
+ <Tab.Navigator>
|
|
43
|
+ <Tab.Screen name="Home" component={HomeScreen} />
|
|
44
|
+ <Tab.Screen name="Settings" component={SettingsScreen} />
|
|
45
|
+ </Tab.Navigator>
|
|
46
|
+ );
|
|
47
|
+}
|
|
48
|
+
|
|
49
|
+function DetailsScreen({ navigation }: StackScreenProps<Routes, 'Details'>) {
|
|
50
|
+ return (
|
|
51
|
+ <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
|
52
|
+ <Text>Details Screen</Text>
|
|
53
|
+ <Button
|
|
54
|
+ title="Go to Details... again"
|
|
55
|
+ onPress={() => navigation.push('Details')}
|
|
56
|
+ />
|
|
57
|
+ <Button title="Go to Home" onPress={() => navigation.navigate('Home')} />
|
|
58
|
+ <Button title="Go back" onPress={() => navigation.goBack()} />
|
|
59
|
+ </View>
|
|
60
|
+ );
|
|
61
|
+}
|
|
62
|
+
|
|
63
|
+const Stack = createNativeStackNavigator();
|
|
64
|
+
|
|
65
|
+export default function NativeStackExample() {
|
|
66
|
+ return (
|
|
67
|
+ <NavigationContainer>
|
|
68
|
+ <Stack.Navigator>
|
|
69
|
+ <Stack.Screen name="Tabs" component={TabsScreen} />
|
|
70
|
+ <Stack.Screen name="Details" component={DetailsScreen} />
|
|
71
|
+ </Stack.Navigator>
|
|
72
|
+ </NavigationContainer>
|
|
73
|
+ );
|
|
74
|
+}
|