-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
122 lines (114 loc) · 3.04 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import React, { useState, useEffect } from 'react';
import { Asset } from 'expo-asset';
import * as Font from 'expo-font';
import AppContainer from './src/navigation/AppNavigator';
import * as Notifications from 'expo-notifications';
import * as Updates from 'expo-updates';
import {
StyleSheet,
View,
ImageBackground,
Dimensions,
LogBox
} from "react-native";
import { Provider } from "react-redux";
import {
language
} from 'config';
import {
FirebaseProvider,
store
} from 'common/src';
import AppCommon from './AppCommon';
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: false,
}),
});
export default function App() {
const [assetsLoaded, setAssetsLoaded] = useState(false);
const [updateMsg, setUpdateMsg] = useState('');
useEffect(() => {
LogBox.ignoreAllLogs(true);
LogBox.ignoreLogs(['Setting a timer']);
onLoad();
}, []);
const _loadResourcesAsync = async () => {
return Promise.all([
Asset.loadAsync([
require('./assets/images/background.jpg'),
require('./assets/images/logo165x90white.png'),
require('./assets/images/bg.jpg'),
require('./assets/images/intro.jpg'),
]),
Font.loadAsync({
'Ubuntu-Bold': require('./assets/fonts/Ubuntu-Bold.ttf'),
'Ubuntu-Regular': require('./assets/fonts/Ubuntu-Regular.ttf'),
'Ubuntu-Medium': require('./assets/fonts/Ubuntu-Medium.ttf'),
'Ubuntu-Light': require('./assets/fonts/Ubuntu-Light.ttf'),
}),
]);
};
const onLoad = async () => {
if (__DEV__) {
setUpdateMsg(language.loading_assets);
_loadResourcesAsync().then(() => {
setAssetsLoaded(true);
});
} else {
try {
setUpdateMsg(language.checking_updates);
const update = await Updates.checkForUpdateAsync();
if (update.isAvailable) {
setUpdateMsg(language.downloading_updates);
await Updates.fetchUpdateAsync();
await Updates.reloadAsync();
} else {
setUpdateMsg(language.loading_assets);
_loadResourcesAsync().then(() => {
setAssetsLoaded(true);
});
}
} catch (e) {
console.log(e);
}
}
}
return (
assetsLoaded ?
<Provider store={store}>
<FirebaseProvider>
<AppCommon>
<AppContainer />
</AppCommon>
</FirebaseProvider>
</Provider>
:
<View style={styles.container}>
<ImageBackground
source={require('./assets/images/intro.jpg')}
resizeMode="stretch"
style={styles.imagebg}
>
</ImageBackground>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: 'center'
},
imagebg: {
position: 'absolute',
left: 0,
top: 0,
width: Dimensions.get('window').width,
height: Dimensions.get('window').height,
justifyContent: "flex-end",
alignItems: 'center'
}
});