forked from scorelab/BT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
98 lines (86 loc) · 2.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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
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';
import BusScreen from './app/screens/busListingScreen/busListingScreen';
import TrainScreen from './app/screens/trainListingScreen/trainListingScreen';
import ProfileScreen from './app/screens/profileScreen/profileScreen';
import LoginScreen from './app/screens/loginScreen/loginScreen';
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',
},
});
const AuthStack = createStackNavigator(
{
Login:{
screen:LoginScreen
}
},{
initialRouteName:"Login",
headerMode:"none"
}
)
const AppStack = createBottomTabNavigator(
{
Bus: { screen: BusScreen },
Train: { screen: TrainScreen },
Profile: { screen: ProfileScreen },
},
{
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, tintColor }) => {
const { routeName } = navigation.state;
let iconName;
if (routeName === 'Bus') {
iconName = 'bus';
} else if (routeName === 'Train') {
iconName = 'train';
} 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'
}
)