-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
79 lines (71 loc) · 1.7 KB
/
App.tsx
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
import React, { Component } from "react";
import {
AsyncStorage,
ActivityIndicator,
StatusBar,
StyleSheet,
View,
TextInput,
Button,
Text
} from "react-native";
import { createAppContainer, createSwitchNavigator } from "react-navigation";
import { createStackNavigator } from "react-navigation-stack";
import { createBottomTabNavigator } from "react-navigation-tabs";
import LoginScreen from "./src/components/LoginScreen";
import RegisterScreen from "./src/components/RegisterScreen";
import Feed from "./src/components/Feed";
import HomePage from "./src/tabs/Home";
const skipLogin = true;
interface Props { navigation: { navigate: Function }; }
class AuthLoadingScreen extends Component<Props> {
styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center"
},
horizontal: {
flexDirection: "row",
justifyContent: "space-around",
padding: 0
}
});
constructor(props: Props) {
super(props);
AsyncStorage.getItem("auth").then(auth =>
this.props.navigation.navigate(auth || skipLogin ? "App" : "Auth")
);
}
// Render any loading content that you like here
render() {
return (
<View style={this.styles.container}>
<ActivityIndicator />
<StatusBar barStyle="default" />
</View>
);
}
}
const authStack = createStackNavigator({
Login: {
screen: LoginScreen
},
Register: {
screen: RegisterScreen
}
});
export default createAppContainer(
createSwitchNavigator(
{
AuthLoading: AuthLoadingScreen,
App: createBottomTabNavigator({
Feed: Feed,
Home: HomePage
}),
Auth: authStack
},
{
initialRouteName: "AuthLoading"
}
)
);