Projekt

Obecné

Profil

Stáhnout (2.53 KB) Statistiky
| Větev: | Tag: | Revize:
1
import { createNativeStackNavigator } from "@react-navigation/native-stack"
2
import { NavigationContainer } from "@react-navigation/native"
3
import HomePage from "../pages/HomePage"
4
import LoginPage from "../pages/LoginPage"
5
import { IconButton } from "native-base"
6
import { AntDesign } from "@expo/vector-icons"
7
import SearchPage from "../pages/SearchPage"
8
import { createDrawerNavigator } from "@react-navigation/drawer"
9
import { useSelector } from "react-redux"
10
import { RootState } from "../stores/store"
11

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

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

    
70
}
71

    
72
export default Navigation
(2-2/2)