-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
87 lines (73 loc) · 2.27 KB
/
App.js
File metadata and controls
87 lines (73 loc) · 2.27 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
import { AppLoading, Asset, Font } from 'expo';
import React from 'react';
import { Platform, StatusBar, StyleSheet, View, AsyncStorage } from 'react-native';
import { NavigationProvider, StackNavigation } from '@expo/ex-navigation';
import { ActionSheetProvider } from '@expo/react-native-action-sheet';
import { Ionicons, MaterialIcons } from '@expo/vector-icons';
import Parse from 'parse/react-native';
import I18n from './js/i18n/i18n';
import customNavigationContext from './js/navigation/customNavigationContext';
import ParseConstants from "./js/parse/ParseConstants";
function cacheImages(images) {
return images.map(image => Asset.fromModule(image).downloadAsync());
}
export default class App extends React.Component {
state = {
isReady: false,
};
componentDidMount() {
this._initializeStateAsync().then();
}
_initializeStateAsync = async () => {
try {
if (Platform.OS === 'ios') {
await Promise.all([Font.loadAsync(Ionicons.font)]);
} else {
await Promise.all([Font.loadAsync(Ionicons.font), Font.loadAsync(MaterialIcons.font)]);
}
// Init I18n
await I18n.initAsync();
await this._initializeParse();
} catch (e) {
// ..
} finally {
this.setState({ isReady: true });
}
};
_initializeParse = async () => {
Parse.setAsyncStorage(AsyncStorage);
Parse.initialize(ParseConstants.appId);
Parse.serverURL = ParseConstants.serverURL;
Parse.User.enableUnsafeCurrentUser();
};
render() {
if (!this.state.isReady) {
return (<AppLoading />);
}
return (
<View style={styles.container}>
<ActionSheetProvider>
<NavigationProvider context={customNavigationContext}>
{this.state.isReady && <StackNavigation id="root" initialRoute="rootNavigation" />}
</NavigationProvider>
</ActionSheetProvider>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
{Platform.OS === 'android' && <View style={styles.statusBarUnderlay} />}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
statusBarUnderlay: {
height: 24,
backgroundColor: 'rgba(0,0,0,0.2)',
position: 'absolute',
top: 0,
left: 0,
right: 0,
},
});