This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
102 lines (100 loc) · 2.49 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
import React from "react";
import {
createStackNavigator,
createAppContainer,
createSwitchNavigator,
createBottomTabNavigator
} from "react-navigation";
import { AsyncStorage, Platform } from "react-native";
import { AppLoading, Asset } from "expo";
import ChatScreen from "./Screens/Chatscreen";
import Rooms from "./Screens/Rooms";
import JoinRooms from "./Screens/JoinRooms";
import SignUpScreen from "./Screens/SignUpScreen";
import SignInScreen from "./Screens/SignInScreen";
const Screens = createStackNavigator(
{
Rooms: { screen: Rooms },
JoinRooms: { screen: JoinRooms },
ChatScreen: { screen: ChatScreen }
},
{
initialRouteName: "Rooms",
headerMode: "float",
defaultNavigationOptions: {
headerTitleStyle: {
height: 40,
marginTop: 5
},
headerStyle: {
height: Platform.OS === 'ios' ? 35 : 50,
backgroundColor: "#227",
marginTop: Platform.OS === 'ios' ? 5 : -25,
},
headerTintColor: "#fff"
}
}
);
const login = createBottomTabNavigator(
{
SignUpScreen: SignUpScreen,
SignInScreen: SignInScreen
},
{
initialRouteName: "SignUpScreen",
tabBarOptions: {
lazy: true,
activeTintColor: "#237",
labelStyle: {
fontSize: 15,
fontWeight: "bold"
},
activeBackgroundColor: "#ccf",
inactiveTintColor: "#ccc"
}
}
);
export default class App extends React.Component {
scroll = null;
state = {
AppContainer: null
};
_loadResourcesAsync = async () => {
return Promise.all([Asset.loadAsync([require("./assets/icon.png")])]);
};
_handleLoadingError = error => {
console.warn(error);
};
_handleFinishLoading = async () => {
const loggedIn = await AsyncStorage.getItem("user-auth");
let initialScreen = "login";
if (loggedIn) {
initialScreen = "Screens";
}
const SignUp = createSwitchNavigator(
{
login: login,
Screens: Screens
},
{
initialRouteName: initialScreen
}
);
this.setState({ AppContainer: createAppContainer(SignUp) });
};
componentDidMount = async () => {
const loggedIn = await AsyncStorage.getItem("user-auth");
this.setState({ loggedIn });
};
render() {
return this.state.AppContainer ? (
<this.state.AppContainer />
) : (
<AppLoading
startAsync={this._loadResourcesAsync}
onError={this._handleLoadingError}
onFinish={this._handleFinishLoading}
/>
);
}
}