-
Notifications
You must be signed in to change notification settings - Fork 1
/
Router.js
163 lines (155 loc) · 4.95 KB
/
Router.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import React from 'react';
import {TouchableOpacity} from 'react-native';
import {NavigationNativeContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs';
import {createDrawerNavigator} from '@react-navigation/drawer';
import Icon from 'react-native-vector-icons/FontAwesome5';
import Home from './src/Home';
import NearBy from './src/NearBy';
import Settings from './src/Settings';
import Products from './src/Products';
import Categories from './src/Categories';
import PlaceDetail from './src/PlaceDetail';
const CategoriesStack = createStackNavigator();
const CategoriesStackNavigator = () => {
return (
<CategoriesStack.Navigator initialRouteName="Categories">
<CategoriesStack.Screen
name="Categories"
component={Categories}
options={({navigation}) => {
return {
headerLeft: ({tintColor}) => (
<TouchableOpacity
style={{paddingHorizontal: 10}}
onPress={() => navigation.openDrawer()}>
<Icon name="bars" size={24} color={tintColor} />
</TouchableOpacity>
),
};
}}
/>
</CategoriesStack.Navigator>
);
};
const SettingStack = createStackNavigator();
const SettingsStackNavigator = () => {
return (
<SettingStack.Navigator initialRouteName="Settings">
<SettingStack.Screen
name="Settings"
component={Settings}
options={({navigation}) => {
return {
headerLeft: ({tintColor, canGoBack}) => (
<TouchableOpacity
style={{paddingHorizontal: 10}}
onPress={() => navigation.openDrawer()}>
<Icon
name={canGoBack ? 'arrow-back' : 'bars'}
size={24}
color={tintColor}
/>
</TouchableOpacity>
),
};
}}
/>
<SettingStack.Screen name="Categories" component={Categories} />
</SettingStack.Navigator>
);
};
const HomeStack = createStackNavigator();
const HomeStackNavigator = () => {
return (
<HomeStack.Navigator headerMode="none" initialRouteName="Home">
<HomeStack.Screen name="Home" component={Home} />
<HomeStack.Screen name="Products" component={Products} />
</HomeStack.Navigator>
);
};
const NearByStack = createStackNavigator();
const NearByStackNavigator = () => {
return (
<NearByStack.Navigator headerMode="none" initialRouteName="NearBy">
<NearByStack.Screen name="NearBy" component={NearBy} />
</NearByStack.Navigator>
);
};
const Tab = createMaterialTopTabNavigator();
const DashboardTabNavigator = () => {
return (
<Tab.Navigator
tabBarPosition="bottom"
initialRouteName="Home"
tabBarOptions={{
showIcon: true,
}}>
<Tab.Screen
name="Home"
component={HomeStackNavigator}
options={{
tabBarIcon: ({color, focused}) => (
<Icon name="home" color={color} size={24} />
),
}}
/>
<Tab.Screen
name="Near By"
component={NearByStackNavigator}
options={{
tabBarIcon: ({color, focused}) => (
<Icon name="map" color={color} size={24} />
),
}}
/>
</Tab.Navigator>
);
};
const Stack = createStackNavigator();
const DashboardStackNavigator = () => {
return (
<Stack.Navigator initialRouteName="Dashboard">
<Stack.Screen
name="Dashboard"
component={DashboardTabNavigator}
options={({navigation}) => {
return {
headerLeft: ({tintColor}) => (
<TouchableOpacity
style={{paddingHorizontal: 10}}
onPress={() => navigation.openDrawer()}>
<Icon name="bars" size={24} color={tintColor} />
</TouchableOpacity>
),
headerRight: ({tintColor}) => (
<TouchableOpacity
style={{marginHorizontal: 10}}
onPress={() => {
navigation.navigate('Settings');
}}>
<Icon name="cog" size={22} color={tintColor} />
</TouchableOpacity>
),
};
}}
/>
<Stack.Screen name="Categories" component={CategoriesStackNavigator} />
<Stack.Screen name="PlaceDetail" component={PlaceDetail} />
</Stack.Navigator>
);
};
const Drawer = createDrawerNavigator();
const Router = () => {
return (
<NavigationNativeContainer>
<Drawer.Navigator initialRouteName="Dashboard">
<Drawer.Screen name="Dashboard" component={DashboardStackNavigator} />
<Drawer.Screen name="Settings" component={SettingsStackNavigator} />
<Drawer.Screen name="Categories" component={CategoriesStackNavigator} />
</Drawer.Navigator>
</NavigationNativeContainer>
);
};
export default Router;