-
Notifications
You must be signed in to change notification settings - Fork 3
/
App.js
executable file
·81 lines (70 loc) · 1.8 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
import './window/domElement';
import './window/resize';
import Expo from 'expo';
import { THREE } from 'expo-three';
import React from 'react';
import { View, StatusBar } from 'react-native';
import Assets from './Assets';
import Settings from './constants/Settings';
import AudioManager from './Manager/AudioManager';
import Gate from './rematch/Gate';
import AppNavigator from './navigation/AppNavigator';
import arrayFromObject from './utils/arrayFromObject';
import cacheAssetsAsync from './utils/cacheAssetsAsync';
export default class App extends React.Component {
state = { loading: true };
get loadingScreen() {
if (Settings.debug) {
return <View />;
} else {
return <Expo.AppLoading />;
}
}
get screen() {
return (
<Gate>
<AppNavigator />
</Gate>
);
}
componentWillMount() {
StatusBar.setBarStyle('light-content');
THREE.suppressExpoWarnings(true);
this._setupExperienceAsync();
}
componentWillUnmount() {
THREE.suppressExpoWarnings(false);
}
_setupExperienceAsync = async () => {
await Promise.all([
this._preloadAsync(),
AudioManager.sharedInstance.setupAsync(),
]);
this.setState({ loading: false });
};
get fonts() {
let items = {};
const keys = Object.keys(Assets.fonts || {});
for (let key of keys) {
const item = Assets.fonts[key];
const name = key.substr(0, key.lastIndexOf('.'));
items[name] = item;
}
return [items];
}
get files() {
return [
...arrayFromObject(Assets.images || {}),
...arrayFromObject(Assets.models || {}),
];
}
async _preloadAsync() {
await cacheAssetsAsync({
fonts: this.fonts,
files: this.files,
});
}
render() {
return this.state.loading ? this.loadingScreen : this.screen;
}
}