Projekt

Obecné

Profil

Stáhnout (3.66 KB) Statistiky
| Větev: | Tag: | Revize:
1 7410d6c1 Michal Schwob
import {createNativeStackNavigator} from "@react-navigation/native-stack"
2
import {NavigationContainer} from "@react-navigation/native"
3 2365039d Michal Schwob
import {HamburgerIcon, HStack, IconButton, Menu, Pressable, Stack, View, VStack} from "native-base"
4 7410d6c1 Michal Schwob
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 2365039d Michal Schwob
import MenuComponent from "../components/navigation/MenuComponent"
16 04928342 Schwobik
17 7410d6c1 Michal Schwob
export type RootStackParamList = {
18 04928342 Schwobik
    Home: undefined,
19 8e95f9c8 Schwobik
    Search: { inventoryId: string | null },
20 04928342 Schwobik
    Logout: undefined,
21
    Item: { itemId: string },
22 3218402b Schwobik
    Login: undefined,
23
    Notes: undefined,
24 04928342 Schwobik
}
25 b7014ba2 Schwobik
26
const Navigation = () => {
27 7410d6c1 Michal Schwob
    const Stack = createNativeStackNavigator<RootStackParamList>()
28 b7014ba2 Schwobik
    const loggedIn = useSelector((state: RootState) => state.user.loggedIn)
29
30
    return (
31
        <NavigationContainer>
32 7410d6c1 Michal Schwob
            <Stack.Navigator initialRouteName="Home"
33 7bfa1542 Michal Schwob
                             screenOptions={ ({ navigation }) => ( {
34
                                 headerStyle: {
35 006d5d56 Michal Schwob
                                     backgroundColor: nativeBaseTheme.colors.primary[50],
36 7bfa1542 Michal Schwob
                                 },
37
                                 headerTitleStyle: {
38
                                     fontWeight: 'bold',
39 006d5d56 Michal Schwob
                                     color: nativeBaseTheme.colors.primary[500],
40 7bfa1542 Michal Schwob
                                 },
41 006d5d56 Michal Schwob
                                 headerTintColor: nativeBaseTheme.colors.primary[500],
42 7bfa1542 Michal Schwob
                                 headerRight: () => (
43 2365039d Michal Schwob
                                     <MenuComponent navigation={navigation}/>
44 7bfa1542 Michal Schwob
                                 ),
45 006d5d56 Michal Schwob
                                 contentStyle: {
46
                                     backgroundColor: nativeBaseTheme.colors.primary[50],
47
                                 },
48 7bfa1542 Michal Schwob
                             } ) }
49 b7014ba2 Schwobik
            >
50 7bfa1542 Michal Schwob
                { loggedIn ? (
51 b7014ba2 Schwobik
                    <>
52 7410d6c1 Michal Schwob
                        <Stack.Screen
53 b7014ba2 Schwobik
                            name="Home"
54 7bfa1542 Michal Schwob
                            component={ HomePage }
55
                            options={ {
56 b7014ba2 Schwobik
                                title: 'My home'
57 7bfa1542 Michal Schwob
                            } }
58 b7014ba2 Schwobik
                        />
59 7410d6c1 Michal Schwob
                        <Stack.Screen
60 b7014ba2 Schwobik
                            name="Search"
61 7bfa1542 Michal Schwob
                            component={ SearchPage }
62
                            initialParams={ { inventoryId: null } }
63 b7014ba2 Schwobik
                        />
64 7410d6c1 Michal Schwob
                        <Stack.Screen
65 7bfa1542 Michal Schwob
                            name={ "Notes" }
66
                            component={ NotesViewPage }
67 3218402b Schwobik
                        />
68 7410d6c1 Michal Schwob
                        <Stack.Screen
69 ddc84a2f Schwobik
                            name="Logout"
70 7bfa1542 Michal Schwob
                            component={ Logout }
71 ddc84a2f Schwobik
                        />
72 7410d6c1 Michal Schwob
                        <Stack.Screen
73 7bfa1542 Michal Schwob
                            name={ "Item" }
74
                            component={ ItemViewPage }
75 04928342 Schwobik
                        />
76 b7014ba2 Schwobik
                    </>
77
                ) : (
78 7410d6c1 Michal Schwob
                    <Stack.Screen
79 b7014ba2 Schwobik
                        name="Login"
80 7bfa1542 Michal Schwob
                        component={ LoginPage }
81
                        options={ ({ navigation }) => ( {
82 b7014ba2 Schwobik
                            headerRight: () => (
83
                                <></>
84
                            )
85 7bfa1542 Michal Schwob
                        } ) }
86 b7014ba2 Schwobik
                    />
87 7bfa1542 Michal Schwob
                ) }
88 7410d6c1 Michal Schwob
            </Stack.Navigator>
89 b7014ba2 Schwobik
        </NavigationContainer>
90
    )
91
92
}
93
94
export default Navigation