1
|
import {createNativeStackNavigator} from "@react-navigation/native-stack"
|
2
|
import {NavigationContainer} from "@react-navigation/native"
|
3
|
import {HamburgerIcon, HStack, IconButton, Menu, Pressable, Stack, View, VStack} from "native-base"
|
4
|
import {AntDesign} from "@expo/vector-icons"
|
5
|
import {createDrawerNavigator} from "@react-navigation/drawer"
|
6
|
import {useSelector} from "react-redux"
|
7
|
import {RootState} from "../stores/store"
|
8
|
import {nativeBaseTheme} from "../theme/nativeBaseTheme"
|
9
|
import HomePage from "./HomePage"
|
10
|
import LoginPage from "./LoginPage"
|
11
|
import SearchPage from "./SearchPage"
|
12
|
import Logout from "./Logout"
|
13
|
import ItemViewPage from "./ItemViewPage"
|
14
|
import NotesViewPage from "./NotesViewPage"
|
15
|
import MenuComponent from "../components/navigation/MenuComponent"
|
16
|
import PlanViewPage from "./PlanViewPage"
|
17
|
import {gestureHandlerRootHOC} from "react-native-gesture-handler"
|
18
|
|
19
|
export type RootStackParamList = {
|
20
|
Home: undefined,
|
21
|
Search: { inventoryId: string | null },
|
22
|
Logout: undefined,
|
23
|
Item: { itemId: string },
|
24
|
Plan: { roomId: number | undefined, placeId: number | undefined },
|
25
|
Login: undefined,
|
26
|
Notes: undefined,
|
27
|
}
|
28
|
|
29
|
const Navigation = () => {
|
30
|
const Stack = createNativeStackNavigator<RootStackParamList>()
|
31
|
const loggedIn = useSelector((state: RootState) => state.user.loggedIn)
|
32
|
|
33
|
return (
|
34
|
<NavigationContainer>
|
35
|
<Stack.Navigator initialRouteName="Home"
|
36
|
screenOptions={ ({ navigation }) => ( {
|
37
|
headerStyle: {
|
38
|
backgroundColor: nativeBaseTheme.colors.primary[50],
|
39
|
},
|
40
|
headerTitleStyle: {
|
41
|
fontWeight: 'bold',
|
42
|
color: nativeBaseTheme.colors.primary[500],
|
43
|
},
|
44
|
headerTintColor: nativeBaseTheme.colors.primary[500],
|
45
|
headerRight: () => (
|
46
|
<MenuComponent navigation={navigation}/>
|
47
|
),
|
48
|
contentStyle: {
|
49
|
backgroundColor: nativeBaseTheme.colors.primary[50],
|
50
|
},
|
51
|
} ) }
|
52
|
>
|
53
|
{ loggedIn ? (
|
54
|
<>
|
55
|
<Stack.Screen
|
56
|
name="Home"
|
57
|
component={ HomePage }
|
58
|
options={ {
|
59
|
title: 'My home'
|
60
|
} }
|
61
|
/>
|
62
|
<Stack.Screen
|
63
|
name="Search"
|
64
|
component={ SearchPage }
|
65
|
initialParams={ { inventoryId: null } }
|
66
|
/>
|
67
|
<Stack.Screen
|
68
|
name={ "Notes" }
|
69
|
component={ NotesViewPage }
|
70
|
/>
|
71
|
<Stack.Screen
|
72
|
name="Logout"
|
73
|
component={ Logout }
|
74
|
/>
|
75
|
<Stack.Screen
|
76
|
name={ "Item" }
|
77
|
component={ ItemViewPage }
|
78
|
/>
|
79
|
<Stack.Screen
|
80
|
name={"Plan"}
|
81
|
component={gestureHandlerRootHOC(PlanViewPage)}
|
82
|
initialParams={ { placeId: undefined, roomId: undefined } }
|
83
|
/>
|
84
|
</>
|
85
|
) : (
|
86
|
<Stack.Screen
|
87
|
name="Login"
|
88
|
component={ LoginPage }
|
89
|
options={ ({ navigation }) => ( {
|
90
|
headerRight: () => (
|
91
|
<></>
|
92
|
)
|
93
|
} ) }
|
94
|
/>
|
95
|
) }
|
96
|
</Stack.Navigator>
|
97
|
</NavigationContainer>
|
98
|
)
|
99
|
|
100
|
}
|
101
|
|
102
|
export default Navigation
|