Projekt

Obecné

Profil

Stáhnout (4.1 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 c2c8470e Fantič
import PlanViewPage from "./PlanViewPage"
17 d5dd3956 Michal Schwob
import {gestureHandlerRootHOC} from "react-native-gesture-handler"
18 04928342 Schwobik
19 7410d6c1 Michal Schwob
export type RootStackParamList = {
20 04928342 Schwobik
    Home: undefined,
21 8e95f9c8 Schwobik
    Search: { inventoryId: string | null },
22 04928342 Schwobik
    Logout: undefined,
23
    Item: { itemId: string },
24 723e4dda Michal Schwob
    Plan: { roomId: number | undefined, placeId: number | undefined },
25 3218402b Schwobik
    Login: undefined,
26
    Notes: undefined,
27 04928342 Schwobik
}
28 b7014ba2 Schwobik
29
const Navigation = () => {
30 7410d6c1 Michal Schwob
    const Stack = createNativeStackNavigator<RootStackParamList>()
31 b7014ba2 Schwobik
    const loggedIn = useSelector((state: RootState) => state.user.loggedIn)
32
33
    return (
34
        <NavigationContainer>
35 7410d6c1 Michal Schwob
            <Stack.Navigator initialRouteName="Home"
36 7bfa1542 Michal Schwob
                             screenOptions={ ({ navigation }) => ( {
37
                                 headerStyle: {
38 006d5d56 Michal Schwob
                                     backgroundColor: nativeBaseTheme.colors.primary[50],
39 7bfa1542 Michal Schwob
                                 },
40
                                 headerTitleStyle: {
41
                                     fontWeight: 'bold',
42 006d5d56 Michal Schwob
                                     color: nativeBaseTheme.colors.primary[500],
43 7bfa1542 Michal Schwob
                                 },
44 006d5d56 Michal Schwob
                                 headerTintColor: nativeBaseTheme.colors.primary[500],
45 7bfa1542 Michal Schwob
                                 headerRight: () => (
46 2365039d Michal Schwob
                                     <MenuComponent navigation={navigation}/>
47 7bfa1542 Michal Schwob
                                 ),
48 006d5d56 Michal Schwob
                                 contentStyle: {
49
                                     backgroundColor: nativeBaseTheme.colors.primary[50],
50
                                 },
51 7bfa1542 Michal Schwob
                             } ) }
52 b7014ba2 Schwobik
            >
53 7bfa1542 Michal Schwob
                { loggedIn ? (
54 b7014ba2 Schwobik
                    <>
55 7410d6c1 Michal Schwob
                        <Stack.Screen
56 b7014ba2 Schwobik
                            name="Home"
57 7bfa1542 Michal Schwob
                            component={ HomePage }
58
                            options={ {
59 b7014ba2 Schwobik
                                title: 'My home'
60 7bfa1542 Michal Schwob
                            } }
61 b7014ba2 Schwobik
                        />
62 7410d6c1 Michal Schwob
                        <Stack.Screen
63 b7014ba2 Schwobik
                            name="Search"
64 7bfa1542 Michal Schwob
                            component={ SearchPage }
65
                            initialParams={ { inventoryId: null } }
66 b7014ba2 Schwobik
                        />
67 7410d6c1 Michal Schwob
                        <Stack.Screen
68 7bfa1542 Michal Schwob
                            name={ "Notes" }
69
                            component={ NotesViewPage }
70 3218402b Schwobik
                        />
71 7410d6c1 Michal Schwob
                        <Stack.Screen
72 ddc84a2f Schwobik
                            name="Logout"
73 7bfa1542 Michal Schwob
                            component={ Logout }
74 ddc84a2f Schwobik
                        />
75 7410d6c1 Michal Schwob
                        <Stack.Screen
76 7bfa1542 Michal Schwob
                            name={ "Item" }
77
                            component={ ItemViewPage }
78 04928342 Schwobik
                        />
79 8e5880b0 Michal Schwob
                        <Stack.Screen
80 c2c8470e Fantič
                            name={"Plan"}
81 d5dd3956 Michal Schwob
                            component={gestureHandlerRootHOC(PlanViewPage)}
82 8e5880b0 Michal Schwob
                            initialParams={ { placeId: undefined, roomId: undefined } }
83 c2c8470e Fantič
                        />
84 b7014ba2 Schwobik
                    </>
85
                ) : (
86 7410d6c1 Michal Schwob
                    <Stack.Screen
87 b7014ba2 Schwobik
                        name="Login"
88 7bfa1542 Michal Schwob
                        component={ LoginPage }
89
                        options={ ({ navigation }) => ( {
90 b7014ba2 Schwobik
                            headerRight: () => (
91
                                <></>
92
                            )
93 7bfa1542 Michal Schwob
                        } ) }
94 b7014ba2 Schwobik
                    />
95 7bfa1542 Michal Schwob
                ) }
96 7410d6c1 Michal Schwob
            </Stack.Navigator>
97 b7014ba2 Schwobik
        </NavigationContainer>
98
    )
99
100
}
101
102
export default Navigation