1
|
import {createNativeStackNavigator} from "@react-navigation/native-stack"
|
2
|
import {NavigationContainer} from "@react-navigation/native"
|
3
|
import {HStack, IconButton, Stack, 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
|
|
16
|
export type RootStackParamList = {
|
17
|
Home: undefined,
|
18
|
Search: { inventoryId: string | null },
|
19
|
Logout: undefined,
|
20
|
Item: { itemId: string },
|
21
|
Login: undefined,
|
22
|
Notes: undefined,
|
23
|
}
|
24
|
|
25
|
const Navigation = () => {
|
26
|
const Stack = createNativeStackNavigator<RootStackParamList>()
|
27
|
const loggedIn = useSelector((state: RootState) => state.user.loggedIn)
|
28
|
|
29
|
return (
|
30
|
<NavigationContainer>
|
31
|
<Stack.Navigator initialRouteName="Home"
|
32
|
screenOptions={ ({ navigation }) => ( {
|
33
|
headerStyle: {
|
34
|
backgroundColor: nativeBaseTheme.colors.primary[800],
|
35
|
},
|
36
|
headerTintColor: '#fff',
|
37
|
headerTitleStyle: {
|
38
|
fontWeight: 'bold',
|
39
|
},
|
40
|
headerRight: () => (
|
41
|
<HStack space={ 0 } alignItems="end" marginRight={-3}>
|
42
|
<IconButton
|
43
|
onPress={() => navigation.navigate("Notes", {inventoryId: null})}
|
44
|
title="Info"
|
45
|
color="#fff"
|
46
|
_icon={{
|
47
|
as: AntDesign,
|
48
|
name: "message1",
|
49
|
color: "white"
|
50
|
}}
|
51
|
/>
|
52
|
<IconButton
|
53
|
onPress={ () => navigation.navigate("Search", { inventoryId: null }) }
|
54
|
title="Info"
|
55
|
color="#fff"
|
56
|
_icon={ {
|
57
|
as: AntDesign,
|
58
|
name: "search1",
|
59
|
color: "white"
|
60
|
} }
|
61
|
/>
|
62
|
<IconButton
|
63
|
onPress={() => navigation.navigate("Logout", {inventoryId: null})}
|
64
|
title="Info"
|
65
|
color="#fff"
|
66
|
_icon={{
|
67
|
as: AntDesign,
|
68
|
name: "logout",
|
69
|
color: "white"
|
70
|
}}
|
71
|
/>
|
72
|
</HStack>
|
73
|
),
|
74
|
} ) }
|
75
|
>
|
76
|
{ loggedIn ? (
|
77
|
<>
|
78
|
<Stack.Screen
|
79
|
name="Home"
|
80
|
component={ HomePage }
|
81
|
options={ {
|
82
|
title: 'My home'
|
83
|
} }
|
84
|
/>
|
85
|
<Stack.Screen
|
86
|
name="Search"
|
87
|
component={ SearchPage }
|
88
|
initialParams={ { inventoryId: null } }
|
89
|
/>
|
90
|
<Stack.Screen
|
91
|
name={ "Notes" }
|
92
|
component={ NotesViewPage }
|
93
|
/>
|
94
|
<Stack.Screen
|
95
|
name="Logout"
|
96
|
component={ Logout }
|
97
|
/>
|
98
|
<Stack.Screen
|
99
|
name={ "Item" }
|
100
|
component={ ItemViewPage }
|
101
|
/>
|
102
|
</>
|
103
|
) : (
|
104
|
<Stack.Screen
|
105
|
name="Login"
|
106
|
component={ LoginPage }
|
107
|
options={ ({ navigation }) => ( {
|
108
|
headerRight: () => (
|
109
|
<></>
|
110
|
)
|
111
|
} ) }
|
112
|
/>
|
113
|
) }
|
114
|
</Stack.Navigator>
|
115
|
</NavigationContainer>
|
116
|
)
|
117
|
|
118
|
}
|
119
|
|
120
|
export default Navigation
|