forked from kb-dev-lab/UKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
91 lines (77 loc) · 2.09 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
import React from 'react';
import { Image } from 'react-native';
import AppLoading from 'expo-app-loading';
import { Asset } from 'expo-asset';
import * as Font from 'expo-font';
import Constants from 'expo-constants';
import {
Entypo,
Feather,
FontAwesome,
Ionicons,
MaterialCommunityIcons,
MaterialIcons,
SimpleLineIcons,
} from '@expo/vector-icons';
import { Montserrat_500Medium } from '@expo-google-fonts/montserrat';
import * as Sentry from 'sentry-expo';
import RootContainer from './containers/rootContainer';
import SettingsManager from './utils/SettingsManager';
import DataManager from './utils/DataManager';
if (Constants.manifest.extra.sentryDSN) {
Sentry.init({
dsn: Constants.manifest.extra.sentryDSN,
enableInExpoDevelopment: false,
debug: false, // Sentry will try to print out useful debugging information if something goes wrong with sending an event. Set this to `false` in production.
});
} else {
console.error('No Sentry URL provided.');
}
function cacheFonts(fonts) {
return fonts.map((font) => Font.loadAsync(font));
}
function cacheImages(images) {
return images.map((image) => {
if (typeof image === 'string') {
return Image.prefetch(image);
} else {
return Asset.fromModule(image).downloadAsync();
}
});
}
export default class App extends React.Component {
state = {
isSplashReady: false,
};
constructor(props) {
super(props);
}
render() {
if (!this.state.isSplashReady) {
return (
<AppLoading
startAsync={this._loadAssetsAsync}
onFinish={() => this.setState({ isSplashReady: true })}
onError={console.warn}
/>
);
}
return <RootContainer />;
}
_loadAssetsAsync = async () => {
await Font.loadAsync({ Montserrat_500Medium });
const imageAssets = cacheImages([require('./assets/icons/app.png')]);
const fontAssets = cacheFonts([
FontAwesome.font,
Feather.font,
Ionicons.font,
MaterialCommunityIcons.font,
MaterialIcons.font,
SimpleLineIcons.font,
Entypo.font,
]);
await DataManager.loadData();
await SettingsManager.loadSettings();
await Promise.all([...imageAssets, ...fontAssets]);
};
}