Projekt

Obecné

Profil

Stáhnout (3.48 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 04928342 Schwobik
16
export type RootDrawerParamList = {
17
    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 04928342 Schwobik
    const Drawer = createDrawerNavigator<RootDrawerParamList>()
27 b7014ba2 Schwobik
    const loggedIn = useSelector((state: RootState) => state.user.loggedIn)
28
29
    return (
30
        <NavigationContainer>
31
            <Drawer.Navigator useLegacyImplementation
32
                screenOptions={({ navigation }) => ({
33
                    headerStyle: {
34 e49b1f44 Schwobik
                        backgroundColor: nativeBaseTheme.colors.primary[800],
35 b7014ba2 Schwobik
                    },
36
                    headerTintColor: '#fff',
37
                    headerTitleStyle: {
38
                        fontWeight: 'bold',
39
                    },
40
                    headerRight: () => (
41
                        <IconButton
42 cbf81c55 Schwobik
                            onPress={() => navigation.navigate("Search", {inventoryId: null})}
43 b7014ba2 Schwobik
                            title="Info"
44
                            color="#fff"
45
                            _icon={{
46
                                as: AntDesign,
47
                                name: "search1",
48
                                color: "white"
49
                            }}
50
                        />
51
                    ),
52
                })}
53
            >
54
                {loggedIn ? (
55
                    <>
56
                        <Drawer.Screen
57
                            name="Home"
58
                            component={HomePage}
59
                            options={{
60
                                title: 'My home'
61
                            }}
62
                        />
63
                        <Drawer.Screen
64
                            name="Search"
65
                            component={SearchPage}
66
                        />
67 3218402b Schwobik
                        <Drawer.Screen
68
                            name={"Notes"}
69
                            component={NotesViewPage}
70
                        />
71 ddc84a2f Schwobik
                        <Drawer.Screen
72
                            name="Logout"
73
                            component={Logout}
74
                        />
75 04928342 Schwobik
                        <Drawer.Screen
76
                            name={"Item"}
77
                            component={ItemViewPage}
78
                            options={{ drawerItemStyle: { display: "none" } }}
79
                        />
80 b7014ba2 Schwobik
                    </>
81
                ) : (
82
                    <Drawer.Screen
83
                        name="Login"
84
                        component={LoginPage}
85
                        options={({ navigation }) => ({
86
                            headerRight: () => (
87
                                <></>
88
                            )
89
                        })}
90
                    />
91
                )}
92
            </Drawer.Navigator>
93
        </NavigationContainer>
94
    )
95
96
}
97
98
export default Navigation