Projekt

Obecné

Profil

Stáhnout (2.73 KB) Statistiky
| Větev: | Tag: | Revize:
1
import {HamburgerIcon, Pressable, Menu, Text, Icon, ChevronRightIcon, HStack} from "native-base"
2
import {useRoute} from "@react-navigation/native"
3

    
4
type MenuComponentProps = {
5
    navigation: any
6
}
7

    
8
const MenuComponent = (props: MenuComponentProps) => {
9
    const route = useRoute().name
10

    
11
    return (
12
        <>
13
            <Menu w="190" color={"primary.500"} trigger={ triggerProps => {
14
                return <Pressable accessibilityLabel="More options menu" { ...triggerProps }>
15
                    <HamburgerIcon color={"primary.500"}/>
16
                </Pressable>
17

    
18
            } }>
19
                <Menu.Item
20
                    onPress={ () => props.navigation.navigate("Home") }
21
                    _text={ { color: "primary.500" } }
22
                    _pressed={ { bg: "secondary.500" } }
23
                    bg={ route === "Home" ? "secondary.500" : "white" }
24
                >
25
                    <HStack justifyContent={ "space-between" } flex={ 1 }>
26
                        <Text>Home</Text>
27
                        <ChevronRightIcon/>
28
                    </HStack>
29
                </Menu.Item>
30
                <Menu.Item
31
                    onPress={ () => props.navigation.navigate("Notes") }
32
                    _text={ { color: "primary.500" } }
33
                    _pressed={ { bg: "secondary.500" } }
34
                    bg={ route === "Notes" ? "secondary.500" : "white" }
35
                >
36
                    <HStack justifyContent={ "space-between" } flex={ 1 }>
37
                        <Text>Notes</Text>
38
                        <ChevronRightIcon/>
39
                    </HStack>
40
                </Menu.Item>
41
                <Menu.Item
42
                    onPress={ () => props.navigation.navigate("Search", { inventoryId: null }) }
43
                    _text={ { color: "primary.500" } }
44
                    _pressed={ { bg: "secondary.500" } }
45
                    bg={ route === "Search" ? "secondary.500" : "white" }
46
                >
47
                    <HStack justifyContent={ "space-between" } flex={ 1 }>
48
                        <Text>Search</Text>
49
                        <ChevronRightIcon/>
50
                    </HStack>
51
                </Menu.Item>
52
                <Menu.Item
53
                    onPress={ () => props.navigation.navigate("Logout") }
54
                    _text={ { color: "primary.500" } }
55
                    _pressed={ { bg: "secondary.500" } }
56
                    justifyContent={ "space-between" }
57
                    flex={ 1 }
58
                >
59
                    <HStack justifyContent={ "space-between" } flex={ 1 }>
60
                        <Text>Logout</Text>
61
                        <ChevronRightIcon/>
62
                    </HStack>
63
                </Menu.Item>
64

    
65
            </Menu>
66
        </>
67
    )
68
}
69

    
70
export default MenuComponent
    (1-1/1)