1 |
7410d6c1
|
Michal Schwob
|
import {createNativeStackNavigator} from "@react-navigation/native-stack"
|
2 |
|
|
import {NavigationContainer} from "@react-navigation/native"
|
3 |
|
|
import {IconButton, Stack} 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 |
8e95f9c8
|
Schwobik
|
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 |
3fb38666
|
Schwobik
|
import NotesViewPage from "./NotesViewPage"
|
15 |
04928342
|
Schwobik
|
|
16 |
7410d6c1
|
Michal Schwob
|
export type RootStackParamList = {
|
17 |
04928342
|
Schwobik
|
Home: undefined,
|
18 |
8e95f9c8
|
Schwobik
|
Search: { inventoryId: string | null },
|
19 |
04928342
|
Schwobik
|
Logout: undefined,
|
20 |
|
|
Item: { itemId: string },
|
21 |
3218402b
|
Schwobik
|
Login: undefined,
|
22 |
|
|
Notes: undefined,
|
23 |
04928342
|
Schwobik
|
}
|
24 |
b7014ba2
|
Schwobik
|
|
25 |
|
|
const Navigation = () => {
|
26 |
7410d6c1
|
Michal Schwob
|
const Stack = createNativeStackNavigator<RootStackParamList>()
|
27 |
b7014ba2
|
Schwobik
|
const loggedIn = useSelector((state: RootState) => state.user.loggedIn)
|
28 |
|
|
|
29 |
|
|
return (
|
30 |
|
|
<NavigationContainer>
|
31 |
7410d6c1
|
Michal Schwob
|
<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 |
|
|
<IconButton
|
42 |
|
|
onPress={() => navigation.navigate("Search", {inventoryId: null})}
|
43 |
|
|
title="Info"
|
44 |
|
|
color="#fff"
|
45 |
|
|
_icon={{
|
46 |
|
|
as: AntDesign,
|
47 |
|
|
name: "search1",
|
48 |
|
|
color: "white"
|
49 |
|
|
}}
|
50 |
|
|
/>
|
51 |
|
|
),
|
52 |
|
|
})}
|
53 |
b7014ba2
|
Schwobik
|
>
|
54 |
|
|
{loggedIn ? (
|
55 |
|
|
<>
|
56 |
7410d6c1
|
Michal Schwob
|
<Stack.Screen
|
57 |
b7014ba2
|
Schwobik
|
name="Home"
|
58 |
|
|
component={HomePage}
|
59 |
|
|
options={{
|
60 |
|
|
title: 'My home'
|
61 |
|
|
}}
|
62 |
|
|
/>
|
63 |
7410d6c1
|
Michal Schwob
|
<Stack.Screen
|
64 |
b7014ba2
|
Schwobik
|
name="Search"
|
65 |
|
|
component={SearchPage}
|
66 |
84cc4e49
|
Michal Schwob
|
initialParams={{inventoryId: null}}
|
67 |
b7014ba2
|
Schwobik
|
/>
|
68 |
7410d6c1
|
Michal Schwob
|
<Stack.Screen
|
69 |
3218402b
|
Schwobik
|
name={"Notes"}
|
70 |
|
|
component={NotesViewPage}
|
71 |
|
|
/>
|
72 |
7410d6c1
|
Michal Schwob
|
<Stack.Screen
|
73 |
ddc84a2f
|
Schwobik
|
name="Logout"
|
74 |
|
|
component={Logout}
|
75 |
|
|
/>
|
76 |
7410d6c1
|
Michal Schwob
|
<Stack.Screen
|
77 |
04928342
|
Schwobik
|
name={"Item"}
|
78 |
|
|
component={ItemViewPage}
|
79 |
|
|
/>
|
80 |
b7014ba2
|
Schwobik
|
</>
|
81 |
|
|
) : (
|
82 |
7410d6c1
|
Michal Schwob
|
<Stack.Screen
|
83 |
b7014ba2
|
Schwobik
|
name="Login"
|
84 |
|
|
component={LoginPage}
|
85 |
7410d6c1
|
Michal Schwob
|
options={({navigation}) => ({
|
86 |
b7014ba2
|
Schwobik
|
headerRight: () => (
|
87 |
|
|
<></>
|
88 |
|
|
)
|
89 |
|
|
})}
|
90 |
|
|
/>
|
91 |
|
|
)}
|
92 |
7410d6c1
|
Michal Schwob
|
</Stack.Navigator>
|
93 |
b7014ba2
|
Schwobik
|
</NavigationContainer>
|
94 |
|
|
)
|
95 |
|
|
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
export default Navigation
|