forked from scorelab/Go-social
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
132 lines (115 loc) · 3.29 KB
/
App.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
import React, { Component } from "react"
import { AppRegistry, Dimensions, ActivityIndicator, AsyncStorage, View, StyleSheet, StatusBar } from 'react-native';
import { StackNavigator, DrawerNavigator, createStackNavigator, createSwitchNavigator, TabNavigator, TabBarBottom, createBottomTabNavigator } from 'react-navigation';
import Ionicons from 'react-native-vector-icons/FontAwesome';
//Components
import HomeScreen from './app/screens/HomeScreen/homeScreen';
import MapScreen from './app/screens/MapScreen/mapScreen';
import ProfileScreen from './app/screens/ProfileScreen/profileScreen';
import LoginScreen from './app/screens/LoginScreen/loginScreen';
import ChatListScreen from './app/screens/ChatListScreen/chatListScreen';
import SignupScreen from './app/screens/SignupScreen/signupScreen';
import NotificationScreen from './app/screens/NotificationScreen/notificationScreen';
//Screen names
import { Home, Info, DetailView, Login } from './app/screens/index';
//Screen size
var {height, width} = Dimensions.get('window');
class AuthLoadingScreen extends Component {
constructor() {
super();
this._bootstrapAsync();
}
_bootstrapAsync = async () => {
const userToken = await AsyncStorage.getItem('userToken');
this.props.navigation.navigate(userToken ? 'App' : 'Auth');
};
render() {
return (
<View style={styles.container}>
<ActivityIndicator />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});
let routeConfigs = {
Home: {
path: '/',
screen: HomeScreen,
},
Info: {
path: '/info',
screen: MapScreen,
}
};
let drawerNavigatorConfig = {
initialRouteName: Home,
drawerWidth: width / 2,
drawerPosition: 'left'
};
const Drawer = DrawerNavigator(
routeConfigs,
drawerNavigatorConfig
)
const AuthStack = createStackNavigator(
{
Login:{
screen:LoginScreen
},
Signup:{
screen:SignupScreen
}
},{
initialRouteName:"Login",
headerMode:"none"
}
)
const AppStack = createBottomTabNavigator(
{
Home: { screen: HomeScreen },
Messages : { screen: ChatListScreen },
Map : { screen: MapScreen },
Notifications : { screen: NotificationScreen },
Profile: { screen: ProfileScreen },
},
{
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, tintColor }) => {
const { routeName } = navigation.state;
let iconName;
if (routeName === 'Home') {
iconName = 'home';
} else if (routeName === 'Messages') {
iconName = 'comment';
} else if (routeName === 'Map') {
iconName = 'map';
} else if (routeName === 'Notifications') {
iconName = 'bell';
} else if (routeName === 'Profile') {
iconName = 'user';
}
return <Ionicons name={iconName} size={25} color={tintColor} />;
},
}),
tabBarOptions: {
activeTintColor: '#3d9bf9',
inactiveTintColor: 'gray',
},
}
);
export default createSwitchNavigator (
{
AuthLoading:AuthLoadingScreen,
App: AppStack,
Auth : AuthStack,
},
{
initialRouteName:'AuthLoading'
}
)