-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
76 lines (67 loc) · 1.88 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
import React from 'react';
import { createStackNavigator, createDrawerNavigator,createAppContainer } from "react-navigation";
import { StyleSheet } from "react-native";
import LoadingScreen from "./components/LoadingScreen/LoadingScreen";
import Login from "./pages/Login/Login";
import cacheAssetsAsync from "./helpers/cacheAssetsAsync";
import assets from "./assets/index";
import NavigationService from "./components/Navigation/NavigationService";
import routes from "./routes/index";
import SideMenu from "./components/SideMenu/SideMenu";
import { AuthProvider } from "./components/Auth/AuthProvider";
import moment from "moment";
import 'moment/min/locales'
moment.locale('pt-br');
export default class App extends React.Component {
constructor() {
super();
this.state = {
assetsLoaded: false
};
this.loadAssetsAsync = async () => {
try {
await cacheAssetsAsync(assets);
} finally {
this.setState({ assetsLoaded: true });
}
};
}
componentDidMount() {
this.loadAssetsAsync();
}
render() {
const { assetsLoaded } = this.state;
if (assetsLoaded) {
const Root = createStackNavigator({
Login: {
screen: Login,
navigationOptions: {
header: null,
headerMode: "none"
}
},
Drawer: {
screen: createDrawerNavigator(routes, {
contentComponent: SideMenu
}),
navigationOptions: {
title: "Events",
header: null,
headerMode: "none"
}
}
});
const Apps = createAppContainer(Root)
return (
<AuthProvider>
<Apps
ref={navigatorRef => {
NavigationService.setTopLevelNavigator(navigatorRef);
}}
/>
</AuthProvider>
);
}
return <LoadingScreen />;
}
}