-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
64 lines (56 loc) · 1.43 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
import React from 'react';
import
{
ActivityIndicator,
AsyncStorage,
StatusBar,
StyleSheet,
View,
} from 'react-native';
import { createSwitchNavigator, createAppContainer } from 'react-navigation';
class AppLoadingScreen extends React.Component
{
constructor()
{
super();
this._bootstrapAsync();
}
// Fetch the token from storage then navigate to our appropriate place
_bootstrapAsync = async () =>
{
const userToken = await AsyncStorage.getItem('userToken');
const startingUpForFirstTime = await AsyncStorage.getItem('startingUpForFirstTime');
if (!startingUpForFirstTime)
this.props.navigation.navigate('Walkthrough');
else
this.props.navigation.navigate(userToken ? 'Home' : 'SignIn');
};
render()
{
return (
<View style={styles.container}>
<ActivityIndicator />
<StatusBar barStyle="default" />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});
import AuthStack from './auth/stack';
import AppStack from './app/stack';
export default createAppContainer(createSwitchNavigator(
{
AppLoading: AppLoadingScreen,
App: AppStack,
Auth: AuthStack
},
{
initialRouteName: 'AppLoading'
}
));