-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
77 lines (68 loc) · 2.11 KB
/
main.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
import Expo, { AppLoading, Asset } from 'expo';
import React from 'react';
import Image from 'react-native';
import { Drawer, Root, StyleProvider } from 'native-base';
import Sentry from '@mpetrunic/sentry-expo';
import { ApolloProvider } from 'react-apollo';
import Router from './navigation/Router';
import getTheme from './native-base-theme/components';
import Sidebar from './screens/Home/SideBar';
import JobFairApiClient from './services/JobFairApiClient';
// Remove this once Sentry is correctly setup.
Sentry.enableInExpoDevelopment = false;
Sentry.config('https://[email protected]/1207215').install();
function cacheImages(images) {
return images.map((image) => {
if (typeof image === 'string') {
return Image.prefetch(image);
}
return Asset.fromModule(image).downloadAsync();
});
}
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isReady: false,
initialRoute: null,
};
}
async initApp() {
this.setState({ isReady: true });
}
async loadAssets() {
const imageAssets = cacheImages([
require('./assets/jobfair.png'),
require('./assets/jobfair-negative.png'),
require('./assets/icons/app-water-icon.png'),
require('./assets/icons/app-qr-icon.png'),
require('./assets/icons/app-assistance-icon.png'),
require('./assets/icons/app-coffee-icon.png'),
]);
await Promise.all([...imageAssets]);
await Expo.Font.loadAsync({
Roboto: require('native-base/Fonts/Roboto.ttf'),
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
Ionicons: require('@expo/vector-icons/fonts/Ionicons.ttf'),
});
}
render() {
if (!this.state.isReady) {
return (<AppLoading
startAsync={this.loadAssets}
onFinish={() => this.initApp()}
onError={console.warn}
/>);
}
return (
<Root>
<StyleProvider style={getTheme()}>
<ApolloProvider client={JobFairApiClient}>
<Router />
</ApolloProvider>
</StyleProvider>
</Root>
);
}
}
Expo.registerRootComponent(App);