-
Notifications
You must be signed in to change notification settings - Fork 4
/
App.js
102 lines (92 loc) · 3.38 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
import AppLoading from 'expo-app-loading';
import { Asset } from 'expo-asset';
import * as Font from 'expo-font';
import React, { useState } from 'react';
import {Platform, StatusBar, StyleSheet, View, NativeModules} from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage'
import { Ionicons } from '@expo/vector-icons';
import AppNavigator from './navigation/AppNavigator';
import I18n from './locales';
import { NativeBaseProvider } from 'native-base';
import * as Permissions from 'expo-permissions';
export default function App(props) {
const [isLoadingComplete, setLoadingComplete] = useState(false);
console.log(AppNavigator);
if (!isLoadingComplete && !props.skipLoadingScreen) {
return (
<NativeBaseProvider>
<AppLoading
startAsync={loadResourcesAsync}
onError={handleLoadingError}
onFinish={() => handleFinishLoading(setLoadingComplete)}
/>
</NativeBaseProvider>
);
} else {
return (
<NativeBaseProvider>
<View style={styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
<AppNavigator />
</View>
</NativeBaseProvider>
);
}
}
async function loadResourcesAsync() {
await AsyncStorage.getItem('lang').then((value) => {
if (value != null) {
console.log("inside - "+value)
I18n.changeLanguage(value);
} else {
let locale;
if(Platform.OS === "ios"){
locale = NativeModules.SettingsManager.settings.AppleLocale ||
NativeModules.SettingsManager.settings.AppleLanguages[0];
} else {
locale = NativeModules.I18nManager.localeIdentifier;
}
I18n.changeLanguage(locale.slice(0, 2));
console.log("phone lang - "+locale.slice(0, 2))
}
})
await Promise.all([
Asset.loadAsync([
require('./assets/images/home/learn_more.png'),
require('./assets/images/home/applied-sciences-icon-2.png'),
require('./assets/images/home/arts-and-humanities-icon.png'),
require('./assets/images/home/business-and-communication-icon.png'),
require('./assets/images/home/career-and-technical-education-icon.png'),
require('./assets/images/home/earth-sciences-icon.png'),
require('./assets/images/home/education-icon.png'),
require('./assets/images/home/history-icon.png'),
require('./assets/images/home/language-arts-icon.png'),
require('./assets/images/home/life-sciences-icon.png'),
require('./assets/images/home/mathematics-icon.png'),
require('./assets/images/home/MO-Website_Red-Quotation-Mark-Icon.png'),
require('./assets/images/home/physical-sciences-icon.png'),
require('./assets/images/home/social-sciences-icon.png'),
]),
Font.loadAsync({
// This is the font that we are using for our tab bar
...Ionicons.font,
// We include SpaceMono because we use it in HomeScreen.js. Feel free to
// remove this if you are not using it in your app
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
}),
]);
}
function handleLoadingError(error) {
// In this case, you might want to report the error to your error reporting
// service, for example Sentry
console.warn(error);
}
function handleFinishLoading(setLoadingComplete) {
setLoadingComplete(true);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
});