-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
89 lines (80 loc) · 2.82 KB
/
App.js
File metadata and controls
89 lines (80 loc) · 2.82 KB
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
import React from 'react';
import {StyleSheet, View} from 'react-native';
import AppLoading from 'expo-app-loading';
import * as Icon from '@expo/vector-icons';
import * as Font from 'expo-font';
import AppNavigator from './navigation/AppNavigator';
import {AudioModel} from "./models/AudioModel";
import AudioLibrary from "./constants/AudioLibrary";
import DropdownAlert from "react-native-dropdownalert";
import {DropdownSingleton} from "./models/DropdownSingleton";
import * as Network from "expo-network";
import * as Updates from 'expo-updates';
import {NetworkModel} from "./models/NetworkModel";
export default class App extends React.Component {
state = {
isLoadingComplete: false,
storedItems: false
};
render() {
if (!this.state.isLoadingComplete) {
return (
<AppLoading
startAsync={this._loadResourcesAsync}
onError={this._handleLoadingError}
onFinish={this._handleFinishLoading}
autoHideSplash={false}
/>
);
}
return (
<View style={styles.container}>
<DropdownAlert ref={ref => DropdownSingleton.set(ref)} updateStatusBar={true} translucent={true} zIndex={100}/>
<AppNavigator/>
</View>
);
}
/**
* @function _statAsync
* Not used, dead code, because I don't trust myself
* If one of these promises would fail, the app may never
* finish loading
* */
_startAsync = async () => {
await this._loadResourcesAsync();
const isInternetReachable = await NetworkModel.isInternetReachable();
if (isInternetReachable) {
const hasUpdates = await Updates.checkForUpdateAsync();
if (hasUpdates.isAvailable) {
const update = await Updates.fetchUpdateAsync();
if (update.isNew) {
await Updates.reloadAsync();
}
}
}
}
_loadResourcesAsync = async () => {
const sounds = AudioModel.load(AudioLibrary);
return Promise.all([
Font.loadAsync({
// This is the font that we are using for our tab bar
...Icon.Ionicons.font,
...sounds
}),
]);
};
_handleLoadingError = error => {
// In this case, you might want to report the error to your error
// reporting service, for example Sentry
console.warn('App Loading Error:', error);
};
_handleFinishLoading = () => {
this.setState({isLoadingComplete: true});
};
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
});