Projekt

Obecné

Profil

Stáhnout (3.74 KB) Statistiky
| Větev: | Tag: | Revize:
1 b7014ba2 Schwobik
import { createNativeStackNavigator } from "@react-navigation/native-stack"
2
import { NavigationContainer } from "@react-navigation/native"
3
import { IconButton } 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 ddc84a2f Schwobik
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 c2c8470e Fantič
import PlanViewPage from "./PlanViewPage"
16 04928342 Schwobik
17
export type RootDrawerParamList = {
18
    Home: undefined,
19 8e95f9c8 Schwobik
    Search: { inventoryId: string | null },
20 04928342 Schwobik
    Logout: undefined,
21
    Item: { itemId: string },
22 c2c8470e Fantič
    Plan: {  },
23 3218402b Schwobik
    Login: undefined,
24
    Notes: undefined,
25 04928342 Schwobik
}
26 b7014ba2 Schwobik
27
const Navigation = () => {
28 04928342 Schwobik
    const Drawer = createDrawerNavigator<RootDrawerParamList>()
29 b7014ba2 Schwobik
    const loggedIn = useSelector((state: RootState) => state.user.loggedIn)
30
31
    return (
32
        <NavigationContainer>
33 17d84a83 Michal Schwob
            <Drawer.Navigator
34 b7014ba2 Schwobik
                screenOptions={({ navigation }) => ({
35
                    headerStyle: {
36 e49b1f44 Schwobik
                        backgroundColor: nativeBaseTheme.colors.primary[800],
37 b7014ba2 Schwobik
                    },
38
                    headerTintColor: '#fff',
39
                    headerTitleStyle: {
40
                        fontWeight: 'bold',
41
                    },
42
                    headerRight: () => (
43
                        <IconButton
44 cbf81c55 Schwobik
                            onPress={() => navigation.navigate("Search", {inventoryId: null})}
45 b7014ba2 Schwobik
                            title="Info"
46
                            color="#fff"
47
                            _icon={{
48
                                as: AntDesign,
49
                                name: "search1",
50
                                color: "white"
51
                            }}
52
                        />
53
                    ),
54
                })}
55
            >
56
                {loggedIn ? (
57
                    <>
58
                        <Drawer.Screen
59
                            name="Home"
60
                            component={HomePage}
61
                            options={{
62
                                title: 'My home'
63
                            }}
64
                        />
65
                        <Drawer.Screen
66
                            name="Search"
67
                            component={SearchPage}
68 84cc4e49 Michal Schwob
                            initialParams={{inventoryId: null}}
69 b7014ba2 Schwobik
                        />
70 3218402b Schwobik
                        <Drawer.Screen
71
                            name={"Notes"}
72
                            component={NotesViewPage}
73
                        />
74 ddc84a2f Schwobik
                        <Drawer.Screen
75
                            name="Logout"
76
                            component={Logout}
77
                        />
78 04928342 Schwobik
                        <Drawer.Screen
79
                            name={"Item"}
80
                            component={ItemViewPage}
81
                            options={{ drawerItemStyle: { display: "none" } }}
82
                        />
83 c2c8470e Fantič
                        <Drawer.Screen
84
                            name={"Plan"}
85
                            component={PlanViewPage}
86
                        />
87 b7014ba2 Schwobik
                    </>
88
                ) : (
89
                    <Drawer.Screen
90
                        name="Login"
91
                        component={LoginPage}
92
                        options={({ navigation }) => ({
93
                            headerRight: () => (
94
                                <></>
95
                            )
96
                        })}
97
                    />
98
                )}
99
            </Drawer.Navigator>
100
        </NavigationContainer>
101
    )
102
103
}
104
105
export default Navigation