This repository has been archived by the owner on Jun 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
App.js
60 lines (49 loc) · 1.61 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
import { Updates } from 'expo';
import React, { Component } from 'react';
import {
View,
StyleSheet,
ActivityIndicator,
I18nManager as RNI18nManager,
} from 'react-native';
import { createAppContainer } from 'react-navigation';
import i18n from './src/services/i18n';
import AppNavigator from './src/navigation/AppNavigator';
const AppNavigatorContainer = createAppContainer(AppNavigator);
export default class App extends Component {
state = { isI18nInitialized: false }
componentDidMount() {
i18n.init()
.then(() => {
const RNDir = RNI18nManager.isRTL ? 'RTL' : 'LTR';
// RN doesn't always correctly identify native
// locale direction, so we force it here.
if (i18n.dir !== RNDir) {
const isLocaleRTL = i18n.dir === 'RTL';
RNI18nManager.forceRTL(isLocaleRTL);
// RN won't set the layout direction if we
// don't restart the app's JavaScript.
Updates.reloadFromCache();
}
this.setState({ isI18nInitialized: true });
})
.catch((error) => console.warn(error));
}
render() {
if (this.state.isI18nInitialized) {
return <AppNavigatorContainer />;
}
return (
<View style={styles.loadingScreen}>
<ActivityIndicator />
</View>
);
}
}
const styles = StyleSheet.create({
loadingScreen: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}
});