Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 7bfa1542

Přidáno uživatelem Michal Schwob před více než 1 rok

Added menu icons for pages for stack navigation
re #10820

Zobrazit rozdíly:

src/pages/Navigation.tsx
1 1
import {createNativeStackNavigator} from "@react-navigation/native-stack"
2 2
import {NavigationContainer} from "@react-navigation/native"
3
import {IconButton, Stack} from "native-base"
3
import {HStack, IconButton, Stack, VStack} from "native-base"
4 4
import {AntDesign} from "@expo/vector-icons"
5 5
import {createDrawerNavigator} from "@react-navigation/drawer"
6 6
import {useSelector} from "react-redux"
......
29 29
    return (
30 30
        <NavigationContainer>
31 31
            <Stack.Navigator initialRouteName="Home"
32
                              screenOptions={({navigation}) => ({
33
                                  headerStyle: {
34
                                      backgroundColor: nativeBaseTheme.colors.primary[800],
35
                                  },
36
                                  headerTintColor: '#fff',
37
                                  headerTitleStyle: {
38
                                      fontWeight: 'bold',
39
                                  },
40
                                  headerRight: () => (
41
                                      <IconButton
42
                                          onPress={() => navigation.navigate("Search", {inventoryId: null})}
43
                                          title="Info"
44
                                          color="#fff"
45
                                          _icon={{
46
                                              as: AntDesign,
47
                                              name: "search1",
48
                                              color: "white"
49
                                          }}
50
                                      />
51
                                  ),
52
                              })}
32
                             screenOptions={ ({ navigation }) => ( {
33
                                 headerStyle: {
34
                                     backgroundColor: nativeBaseTheme.colors.primary[800],
35
                                 },
36
                                 headerTintColor: '#fff',
37
                                 headerTitleStyle: {
38
                                     fontWeight: 'bold',
39
                                 },
40
                                 headerRight: () => (
41
                                     <HStack space={ 0 } alignItems="end" marginRight={-3}>
42
                                         <IconButton
43
                                             onPress={() => navigation.navigate("Notes", {inventoryId: null})}
44
                                             title="Info"
45
                                             color="#fff"
46
                                             _icon={{
47
                                                 as: AntDesign,
48
                                                 name: "message1",
49
                                                 color: "white"
50
                                             }}
51
                                         />
52
                                         <IconButton
53
                                             onPress={ () => navigation.navigate("Search", { inventoryId: null }) }
54
                                             title="Info"
55
                                             color="#fff"
56
                                             _icon={ {
57
                                                 as: AntDesign,
58
                                                 name: "search1",
59
                                                 color: "white"
60
                                             } }
61
                                         />
62
                                         <IconButton
63
                                             onPress={() => navigation.navigate("Logout", {inventoryId: null})}
64
                                             title="Info"
65
                                             color="#fff"
66
                                             _icon={{
67
                                                 as: AntDesign,
68
                                                 name: "logout",
69
                                                 color: "white"
70
                                             }}
71
                                         />
72
                                     </HStack>
73
                                 ),
74
                             } ) }
53 75
            >
54
                {loggedIn ? (
76
                { loggedIn ? (
55 77
                    <>
56 78
                        <Stack.Screen
57 79
                            name="Home"
58
                            component={HomePage}
59
                            options={{
80
                            component={ HomePage }
81
                            options={ {
60 82
                                title: 'My home'
61
                            }}
83
                            } }
62 84
                        />
63 85
                        <Stack.Screen
64 86
                            name="Search"
65
                            component={SearchPage}
66
                            initialParams={{inventoryId: null}}
87
                            component={ SearchPage }
88
                            initialParams={ { inventoryId: null } }
67 89
                        />
68 90
                        <Stack.Screen
69
                            name={"Notes"}
70
                            component={NotesViewPage}
91
                            name={ "Notes" }
92
                            component={ NotesViewPage }
71 93
                        />
72 94
                        <Stack.Screen
73 95
                            name="Logout"
74
                            component={Logout}
96
                            component={ Logout }
75 97
                        />
76 98
                        <Stack.Screen
77
                            name={"Item"}
78
                            component={ItemViewPage}
99
                            name={ "Item" }
100
                            component={ ItemViewPage }
79 101
                        />
80 102
                    </>
81 103
                ) : (
82 104
                    <Stack.Screen
83 105
                        name="Login"
84
                        component={LoginPage}
85
                        options={({navigation}) => ({
106
                        component={ LoginPage }
107
                        options={ ({ navigation }) => ( {
86 108
                            headerRight: () => (
87 109
                                <></>
88 110
                            )
89
                        })}
111
                        } ) }
90 112
                    />
91
                )}
113
                ) }
92 114
            </Stack.Navigator>
93 115
        </NavigationContainer>
94 116
    )

Také k dispozici: Unified diff