Skip to content

Commit 17425c4

Browse files
committed
Fix
1 parent 1ea5977 commit 17425c4

File tree

8 files changed

+86
-53
lines changed

8 files changed

+86
-53
lines changed

src/navigation/AppNavigator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import AuthStackNavigator from './AuthNavigator';
77
export default createSwitchNavigator(
88
{
99
AuthLoading: AuthLoadingScreen,
10-
Home: DrawerNavigator,
10+
Dashboard: DrawerNavigator,
1111
Auth: AuthStackNavigator,
1212
},
1313
{

src/navigation/AuthLoadingNavigator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function AuthLoadingScreen(props) {
1515
});
1616

1717
function _bootstrapAsync() {
18-
navigate(token ? 'Home' : 'Auth');
18+
navigate(token ? 'Dashboard' : 'Auth');
1919
}
2020

2121
return (

src/navigation/ContentDrawer.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React, {useContext} from 'react';
2+
import Animated from 'react-native-reanimated';
3+
import {Text, Button} from 'react-native';
4+
5+
import {CTX} from '../tools/context';
6+
7+
export default function CustomDrawerContent({progress, ...rest}) {
8+
const {navigation} = rest;
9+
const {navigate} = navigation;
10+
11+
const authContext = useContext(CTX);
12+
const {_logout} = authContext;
13+
14+
// const {loading, error, data} = useQuery(GET_GREETING);
15+
16+
function _onLogout() {
17+
_logout();
18+
console.log(navigate);
19+
navigate('Login');
20+
}
21+
const translateX = Animated.interpolate(progress, {
22+
inputRange: [0, 1],
23+
outputRange: [-100, 0],
24+
});
25+
26+
return (
27+
<Animated.View
28+
style={{
29+
flex: 1,
30+
alignItems: 'center',
31+
justifyContent: 'center',
32+
transform: [{translateX}],
33+
}}>
34+
<Text>Hello</Text>
35+
<Button onPress={_onLogout} title="Log out" color="#841584" />
36+
</Animated.View>
37+
);
38+
}
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
import {createStackNavigator} from 'react-navigation-stack';
1+
import React from 'react';
2+
import {createStackNavigator} from '@react-navigation/stack';
23

34
import TabNavigator from './TabNavigator';
45

5-
export default createStackNavigator({
6-
DashboardTabNavigator: TabNavigator,
7-
});
6+
const Stack = createStackNavigator();
7+
8+
export default function DashboardStackNavigator(props) {
9+
return (
10+
<Stack.Navigator>
11+
<Stack.Screen
12+
name="DashboardTabNavigator"
13+
children={() => <TabNavigator {...props} />}
14+
/>
15+
</Stack.Navigator>
16+
);
17+
}

src/navigation/DrawerNavigator.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,35 @@
1-
// export default createDrawerNavigator(
2-
// {
3-
// CustomNavigator,
4-
// SettingsScreen,
5-
// LegalScreen,
6-
// FeedbackScreen,
7-
// VersionScreen,
8-
// },
9-
// {
10-
// drawerType: 'slide',
11-
// drawerWidth: 260,
12-
// },
13-
// );
14-
151
import React from 'react';
162
import {createDrawerNavigator} from '@react-navigation/drawer';
3+
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
174

18-
import TabNavigator from './TabNavigator';
19-
import {primaryColor} from '../theme';
5+
import DashboardNavigator from './DashboardNavigator';
6+
import CustomDrawerContent from './ContentDrawer';
207

218
const Drawer = createDrawerNavigator();
229

23-
export default function DrawerNavigator() {
10+
export default function DrawerNavigator(props) {
2411
return (
2512
<Drawer.Navigator
26-
drawerStyle={{
27-
backgroundColor: '#c6cbef',
28-
width: 240,
29-
}}
30-
drawerContentOptions={{
31-
activeTintColor: primaryColor,
32-
itemStyle: {marginVertical: 0},
33-
}}>
34-
<Drawer.Screen name="Dashboard" component={TabNavigator} />
13+
// drawerStyle={{
14+
// backgroundColor: '#c6cbef',
15+
// width: 240,
16+
// }}
17+
// drawerContentOptions={{
18+
// activeTintColor: primaryColor,
19+
// itemStyle: {marginVertical: 0},
20+
// }}
21+
// navigationOptions={{
22+
// headerStyle: {
23+
// backgroundColor: 'red',
24+
// },
25+
// headerRight: <FontAwesome5 name={'user'} color={'red'} size={24} />,
26+
// }}
27+
headerRight={() => <FontAwesome5 name={'user'} color={'red'} size={24} />}
28+
drawerContent={() => <CustomDrawerContent {...props} />}>
29+
<Drawer.Screen
30+
name="Dashboard"
31+
children={() => <DashboardNavigator {...props} />}
32+
/>
3533
</Drawer.Navigator>
3634
);
3735
}

src/navigation/TabNavigator.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React, {useContext} from 'react';
22
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
3-
import {View, Text, StyleSheet, Button} from 'react-native';
3+
import {View, Text, StyleSheet} from 'react-native';
44
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
55

66
import {primaryColor} from '../theme';
7-
import {CTX} from '../tools/context';
87

98
const styles = StyleSheet.create({
109
container: {
@@ -32,22 +31,9 @@ function Notifications() {
3231
);
3332
}
3433

35-
function Profile(props) {
36-
console.log(props);
37-
38-
const authContext = useContext(CTX);
39-
const {_logout} = authContext;
40-
41-
// const {loading, error, data} = useQuery(GET_GREETING);
42-
43-
function _onLogout() {
44-
_logout();
45-
navigate('Login');
46-
}
47-
34+
function Profile() {
4835
return (
4936
<View style={styles.container}>
50-
<Button onPress={_onLogout} title="Log out" color="#841584" />
5137
<Text>Profile</Text>
5238
</View>
5339
);
@@ -62,23 +48,23 @@ export default function TabNavigator(props) {
6248
}}>
6349
<Tab.Screen
6450
name="Feed"
65-
component={Feed}
6651
options={{
6752
tabBarLabel: 'Home',
6853
tabBarIcon: ({color, size}) => (
6954
<FontAwesome5 name={'home'} color={color} size={size} />
7055
),
7156
}}
57+
children={() => <Feed {...props} />}
7258
/>
7359
<Tab.Screen
7460
name="Notifications"
75-
component={Notifications}
7661
options={{
7762
tabBarLabel: 'Notifications',
7863
tabBarIcon: ({color, size}) => (
7964
<FontAwesome5 name={'bell'} color={color} size={size} />
8065
),
8166
}}
67+
children={() => <Notifications {...props} />}
8268
/>
8369
<Tab.Screen
8470
name="Profile"
@@ -89,6 +75,7 @@ export default function TabNavigator(props) {
8975
<FontAwesome5 name={'user'} color={color} size={size} />
9076
),
9177
}}
78+
children={props => <Profile {...props} />}
9279
/>
9380
</Tab.Navigator>
9481
);

src/screens/Login.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function LoginScreen(props) {
2727

2828
if (email === 'trinhchinchin@gmail.com' && password === '123') {
2929
_authenticate(accessToken);
30-
navigate('Home');
30+
navigate('Dashboard');
3131
} else {
3232
setErrorMessage('Email or Password is not correct.');
3333
}

src/screens/Register.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export default function RegisterScreen(props) {
2222

2323
if (phone !== '0704498756') {
2424
navigate('Login');
25+
} else {
26+
setErrorMessage('Phone has already existed.');
2527
}
26-
27-
setErrorMessage('Phone has already existed.');
2828
}
2929

3030
function _navigateLogin() {

0 commit comments

Comments
 (0)