Skip to content

Commit d3e68c4

Browse files
committed
Add constants
1 parent 1e0fe68 commit d3e68c4

File tree

6 files changed

+42
-25
lines changed

6 files changed

+42
-25
lines changed

src/constants/index.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
const APP_HOME
1+
const APP_NAME = {
2+
SPLASH: 'Splash',
3+
ONBOARDING: 'Onboarding',
4+
AUTH: 'Auth',
5+
DASHBOARD: 'Dashboard',
6+
LOGIN: 'Login',
7+
REGISTER: 'Register',
8+
FORGOT: 'Forgot',
9+
DASHBOARD_TAB: 'DashboardTabNavigator',
10+
POST_MODAL: 'PostModal',
11+
HOME: 'Home',
12+
MESSAGE: 'Message',
13+
POST: 'Post',
14+
NOTIFICATION: 'Notification',
15+
PROFILE: 'Profile',
16+
};
17+
18+
module.exports = APP_NAME;

src/navigation/AppNavigator.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {useEffect, useState, useContext} from 'react';
22
import {createStackNavigator} from '@react-navigation/stack';
33

4+
import {SPLASH, ONBOARDING, AUTH, DASHBOARD} from '../constants';
45
import DrawerNavigator from './DrawerNavigator';
56
import AuthStackNavigator from './AuthNavigator';
67
import SplashScreen from '../screens/Splash';
@@ -30,19 +31,19 @@ export default function AppStackNavigator() {
3031

3132
return (
3233
<Stack.Navigator
33-
initialRouteName="Splash"
34+
initialRouteName={SPLASH}
3435
headerMode="none"
3536
screenOptions={{
3637
animationTypeForReplace: 'push',
3738
}}>
3839
{loading ? (
39-
<Stack.Screen name="Splash" component={SplashScreen} />
40+
<Stack.Screen name={SPLASH} component={SplashScreen} />
4041
) : !skip ? (
41-
<Stack.Screen name="Onboarding" component={OnBoardingScreen} />
42+
<Stack.Screen name={ONBOARDING} component={OnBoardingScreen} />
4243
) : !token ? (
43-
<Stack.Screen name="Auth" component={AuthStackNavigator} />
44+
<Stack.Screen name={AUTH} component={AuthStackNavigator} />
4445
) : (
45-
<Stack.Screen name="Dashboard" component={DrawerNavigator} />
46+
<Stack.Screen name={DASHBOARD} component={DrawerNavigator} />
4647
)}
4748
</Stack.Navigator>
4849
);

src/navigation/AuthNavigator.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import {createStackNavigator} from '@react-navigation/stack';
33

4+
import {LOGIN, REGISTER, FORGOT} from '../constants';
45
import LoginScreen from '../screens/Login';
56
import RegisterScreen from '../screens/Register';
67
import ForgotScreen from '../screens/Forgot';
@@ -10,25 +11,25 @@ const Stack = createStackNavigator();
1011
export default function AuthNavigator() {
1112
return (
1213
<Stack.Navigator
13-
initialRouteName="Login"
14+
initialRouteName={LOGIN}
1415
headerMode="none"
1516
screenOptions={{
1617
headerTintColor: 'red',
1718
}}>
1819
<Stack.Screen
19-
name="Login"
20+
name={LOGIN}
2021
component={LoginScreen}
2122
options={{
2223
title: 'Login',
2324
}}
2425
/>
2526
<Stack.Screen
26-
name="Register"
27+
name={REGISTER}
2728
component={RegisterScreen}
2829
options={{title: 'Register'}}
2930
/>
3031
<Stack.Screen
31-
name="Forgot"
32+
name={FORGOT}
3233
component={ForgotScreen}
3334
options={{title: 'Forgot'}}
3435
/>

src/navigation/DashboardNavigator.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
import React from 'react';
22
import {createStackNavigator} from '@react-navigation/stack';
33
// import FontAwesome5Icon from 'react-native-vector-icons/FontAwesome5';
4-
import {useNavigation} from '@react-navigation/native';
54

5+
import {DASHBOARD_TAB, POST_MODAL} from '../constants';
66
import TabNavigator from './TabNavigator';
77
import PostScreen from '../screens/Post';
88

99
const Stack = createStackNavigator();
1010

11-
export default function DashboardStackNavigator(props) {
12-
const navigation = useNavigation();
13-
const {toggleDrawer} = navigation;
14-
11+
export default function DashboardStackNavigator() {
1512
return (
16-
<Stack.Navigator mode="modal">
13+
<Stack.Navigator mode="modal" initialRouteName={DASHBOARD_TAB}>
1714
<Stack.Screen
1815
options={{
1916
headerShown: false,
2017
}}
21-
// name="DashboardTabNavigator"
18+
name={DASHBOARD_TAB}
2219
// options={{
2320
// title: 'Chnirt',
2421
// headerTitleAlign: 'left',
@@ -45,7 +42,7 @@ export default function DashboardStackNavigator(props) {
4542
component={TabNavigator}
4643
/>
4744
<Stack.Screen
48-
name="PostModal"
45+
name={POST_MODAL}
4946
options={{
5047
headerShown: false,
5148
}}

src/navigation/TabNavigator.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {TouchableOpacity} from 'react-native';
44
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
55
import {useNavigation} from '@react-navigation/native';
66

7+
import {HOME, MESSAGE, POST, NOTIFICATION, PROFILE} from '../constants';
78
import {primaryColor} from '../theme';
89
import HomeScreen from '../screens/Home';
910
import MessageScreen from '../screens/Message';
@@ -20,13 +21,13 @@ export default function TabNavigator(props) {
2021

2122
return (
2223
<Tab.Navigator
23-
initialRouteName="Message"
24+
initialRouteName={HOME}
2425
tabBarOptions={{
2526
activeTintColor: '#161F3D',
2627
showLabel: false,
2728
}}>
2829
<Tab.Screen
29-
name="Home"
30+
name={HOME}
3031
options={{
3132
tabBarIcon: ({color, size}) => (
3233
<FontAwesome5 name={'home'} color={color} size={size} />
@@ -35,7 +36,7 @@ export default function TabNavigator(props) {
3536
children={() => <HomeScreen {...props} />}
3637
/>
3738
<Tab.Screen
38-
name="Message"
39+
name={MESSAGE}
3940
options={{
4041
tabBarIcon: ({color, size}) => (
4142
<FontAwesome5 name={'comments'} color={color} size={size} />
@@ -44,7 +45,7 @@ export default function TabNavigator(props) {
4445
children={() => <MessageScreen {...props} />}
4546
/>
4647
<Tab.Screen
47-
name="Post"
48+
name={POST}
4849
options={{
4950
tabBarIcon: ({color, size}) => (
5051
// <AddButton />
@@ -73,7 +74,7 @@ export default function TabNavigator(props) {
7374
}}
7475
/>
7576
<Tab.Screen
76-
name="Notification"
77+
name={NOTIFICATION}
7778
options={{
7879
tabBarIcon: ({color, size}) => (
7980
<FontAwesome5 name={'bell'} color={color} size={size} />
@@ -82,7 +83,7 @@ export default function TabNavigator(props) {
8283
children={() => <NotificationScreen {...props} />}
8384
/>
8485
<Tab.Screen
85-
name="Profile"
86+
name={PROFILE}
8687
options={{
8788
tabBarIcon: ({color, size}) => (
8889
<FontAwesome5 name={'user'} color={color} size={size} />

src/screens/Home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default function HomeScreen() {
122122
return (
123123
<View style={styles.container}>
124124
<View style={styles.header}>
125-
<Text style={styles.headerTitle}>Feed</Text>
125+
<Text style={styles.headerTitle}>Home</Text>
126126
</View>
127127

128128
<FlatList

0 commit comments

Comments
 (0)