-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoutes.js
121 lines (107 loc) · 4.24 KB
/
Routes.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
import { StatusBar } from 'react-native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import { NavigationContainer, getFocusedRouteNameFromRoute } from '@react-navigation/native'
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Screens from './utils/Screens';
import Home from './screens/Home';
import Profile from './screens/Profile';
import Job from './screens/Job';
import Network from './screens/Network';
import Notification from './screens/Notification';
import Post from './screens/Post';
import Colors from './utils/Colors';
import CustomIcon from './components/CustomIcon';
import HeaderOptions from './components/HeaderOptions';
const Tab = createBottomTabNavigator();
const HomeStack = createNativeStackNavigator();
const JobStack = createNativeStackNavigator();
const NetworkStack = createNativeStackNavigator();
const NotificationStack = createNativeStackNavigator();
const PostStack = createNativeStackNavigator();
const HomeScreen = () => {
return (
<HomeStack.Navigator screenOptions={{ headerShown: false }}>
<HomeStack.Screen name={Screens.HOME} component={Home} />
<HomeStack.Screen name={Screens.PROFILE} component={Profile} />
</HomeStack.Navigator>
)
}
const JobScreen = () => {
return (
<JobStack.Navigator screenOptions={{ headerShown: false }}>
<HomeStack.Screen name={Screens.JOB} component={Job} />
</JobStack.Navigator>
)
}
const NetworkScreen = () => {
return (
<NetworkStack.Navigator screenOptions={{ headerShown: false }}>
<NetworkStack.Screen name={Screens.NETWORK} component={Network} />
</NetworkStack.Navigator>
)
}
const NotificationScreen = () => {
return (
<NotificationStack.Navigator screenOptions={{ headerShown: false }}>
<NotificationStack.Screen name={Screens.NOTIFICATION} component={Notification} />
</NotificationStack.Navigator>
)
}
const PostScreen = () => {
return (
<PostStack.Navigator screenOptions={{ headerShown: false }}>
<PostStack.Screen name={Screens.POST} component={Post} />
</PostStack.Navigator>
)
}
const showTabBar = (route) => {
const routeName = getFocusedRouteNameFromRoute(route)
return routeName == Screens.PROFILE ? "none" : "flex"
}
const header = (navigation, route, icon, title, iconLeft, isPostScreen, isNotificationScreen) => (
{
title: title,
tabBarStyle: { display: showTabBar(route), height: 70 },
tabBarBadge: isNotificationScreen ? 99 : null,
tabBarIcon: ({ focused }) => (
<CustomIcon
name={icon}
size={28}
color={focused ? Colors.BLACK : Colors.GRAY}
/>
),
header: () => <HeaderOptions iconLeft={iconLeft} navigation={navigation} isPostScreen={isPostScreen} />
}
)
const screenOptions = {
tabBarStyle: {
height: 70,
},
tabBarItemStyle: {
margin: 10,
},
tabBarActiveTintColor: Colors.BLACK,
tabBarInActiveTintColor: Colors.GRAY,
tabBarLabelStyle: { fontWeight: "bold", fontSize: 12 },
headerStyle: { elevation: 10 }
};
export default function Routes() {
return (
<NavigationContainer>
<StatusBar backgroundColor={Colors.WHITE} barStyle="dark-content" />
<Tab.Navigator {...{ screenOptions }}>
<Tab.Screen name={Screens.HOME_STACK} component={HomeScreen} options={({ navigation, route }) => header(navigation, route, 'home', 'Home')} />
<Tab.Screen name={Screens.NETWORK_STACK} component={NetworkScreen} options={({ navigation, route }) => header(navigation, route, 'people', 'Network')} />
<Tab.Screen name={Screens.POST_STACK} component={PostScreen} options={({ navigation, route }) => header(navigation, route, 'add-circle', 'Post', 'close', true)} />
<Tab.Screen name={Screens.NOTIFICATION_STACK} component={NotificationScreen} options={({ navigation, route }) => header(navigation,
route,
'notifications',
'Notifications',
'',
false,
true,)} />
<Tab.Screen name={Screens.JOB_STACK} component={JobScreen} options={({ navigation, route }) => header(navigation, route, 'briefcase', 'Jobs')} />
</Tab.Navigator>
</NavigationContainer>
)
}