-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainApp.js
109 lines (102 loc) · 3.6 KB
/
MainApp.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
import React, { Component } from 'react'
import { createBottomTabNavigator, createAppContainer, createSwitchNavigator, createStackNavigator } from "react-navigation";
import { Icon } from 'native-base';
import { fromRight, fromBottom, fromLeft } from 'react-navigation-transitions';
import HomeScreen from "./apps/user/components/pages/HomeScreen";
import ProfileScreen from "./apps/user/components/pages/ProfileScreen";
import LoginScreen from './apps/global/components/pages/LoginScreen';
import AuthLoadingScreen from './apps/global/components/pages/AuthLoadingScreen';
import RegisterScreen from './apps/global/components/pages/RegisterScreen';
import { mainColor } from './apps/global/components/assets/Styles';
import { UserAuthService } from './apps/global/services/AuthService';
import CreatePostScreen from './apps/user/components/pages/posts/CreatePostScreen';
import UserPostScreen from './apps/user/components/pages/posts/UserPostScreen';
import ViewPostScreen from './apps/user/components/pages/posts/ViewPostScreen';
import EditPostScreen from './apps/user/components/pages/posts/EditPostScreen';
import CustomImageViewer from './apps/global/components/layouts/CustomImageViewer';
class LogOutScreen extends Component {
componentWillMount = () => {
UserAuthService.signOut().then(
() => {
this.props.navigation.navigate('Auth')
}
)
}
render() {
return null
}
}
const AuthStack = createStackNavigator(
{
Login: LoginScreen,
Register: RegisterScreen
},
{
initialRouteName: 'Login',
transitionConfig: () => fromRight(),
defaultNavigationOptions: {
headerStyle: {
backgroundColor: 'white',
},
headerTintColor: mainColor
},
}
);
const UserDashboardStack = createBottomTabNavigator(
{
Home: { screen: HomeScreen, params: { icon: 'home', type: 'MaterialIcons' } },
Profile: { screen: ProfileScreen, params: { icon: 'person', type: 'MaterialIcons' } },
Exit: { screen: LogOutScreen, params: { icon: 'log-out', type: 'Ionicons' } }
}, {
initialRouteName: 'Home',
defaultNavigationOptions: ({ navigation }) => ({
tabBarIcon: ({ tintColor }) => {
const { params } = navigation.state;
return <Icon type={params.type} name={params.icon} style={{ color: tintColor, fontSize: 25, marginTop: 5 }} />
}
}),
tabBarOptions: {
activeTintColor: 'tomato',
inactiveTintColor: 'gray'
},
}
);
const UserPageStack = createStackNavigator(
{
CreatePost: CreatePostScreen,
EditPost: EditPostScreen,
UserPosts: UserPostScreen,
ViewPost: ViewPostScreen,
ImageViewer: CustomImageViewer
},
{
// initialRouteName: 'UserPosts',
headerMode: 'none',
transitionConfig: () => fromBottom(),
defaultNavigationOptions: {
headerStyle: {
backgroundColor: 'white',
},
headerTintColor: mainColor
},
}
)
export default MainApp = createAppContainer(createSwitchNavigator(
{
AuthLoading: AuthLoadingScreen,
User: createStackNavigator(
{
Dashboard: UserDashboardStack,
Pages: UserPageStack
}, {
initialRouteName: 'Dashboard',
headerMode: 'none',
transitionConfig: () => fromBottom(),
}
),
Auth: AuthStack,
},
{
initialRouteName: 'AuthLoading'
}
));