Projekt

Obecné

Profil

Stáhnout (2.8 KB) Statistiky
| Větev: | Tag: | Revize:
1
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
import { nativeBaseTheme } from "../theme/nativeBaseTheme"
9
import HomePage from "../pages/HomePage"
10
import LoginPage from "../pages/LoginPage"
11
import SearchPage from "../pages/SearchPage"
12
import Logout from "../pages/Logout"
13

    
14
const Navigation = () => {
15
    const Drawer = createDrawerNavigator()
16
    const loggedIn = useSelector((state: RootState) => state.user.loggedIn)
17

    
18
    return (
19
        <NavigationContainer>
20
            <Drawer.Navigator useLegacyImplementation
21
                screenOptions={({ navigation }) => ({
22
                    headerStyle: {
23
                        backgroundColor: nativeBaseTheme.colors.primary[50],
24
                    },
25
                    headerTintColor: '#fff',
26
                    headerTitleStyle: {
27
                        fontWeight: 'bold',
28
                    },
29
                    headerRight: () => (
30
                        <IconButton
31
                            onPress={() => navigation.navigate("Search")}
32
                            title="Info"
33
                            color="#fff"
34
                            _icon={{
35
                                as: AntDesign,
36
                                name: "search1",
37
                                color: "white"
38
                            }}
39
                        />
40
                    ),
41
                })}
42
            >
43
                {loggedIn ? (
44
                    <>
45
                        <Drawer.Screen
46
                            name="Home"
47
                            component={HomePage}
48
                            options={{
49
                                title: 'My home'
50
                            }}
51
                        />
52
                        <Drawer.Screen
53
                            name="Search"
54
                            component={SearchPage}
55
                        />
56
                        <Drawer.Screen
57
                            name="Logout"
58
                            component={Logout}
59
                        />
60
                    </>
61
                ) : (
62
                    <Drawer.Screen
63
                        name="Login"
64
                        component={LoginPage}
65
                        options={({ navigation }) => ({
66
                            headerRight: () => (
67
                                <></>
68
                            )
69
                        })}
70
                    />
71
                )}
72
            </Drawer.Navigator>
73
        </NavigationContainer>
74
    )
75

    
76
}
77

    
78
export default Navigation
(2-2/2)