-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
98 lines (88 loc) · 2.46 KB
/
App.js
File metadata and controls
98 lines (88 loc) · 2.46 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
90
91
92
93
94
95
96
97
98
import Expo, { AppLoading, Asset } from 'expo';
import React from 'react';
import { I18nextProvider, translate } from 'react-i18next';
import { createStackNavigator, createSwitchNavigator } from 'react-navigation';
import { verticalScale } from 'react-native-size-matters';
import { Provider } from 'react-redux';
import config from './config';
import i18n from './i18n';
import Loading from './screens/Loading';
import SignIn from './screens/SignIn';
import configureStore from './store';
import { baseFontSize, colors, fonts } from './misc/styles';
if (config.env === 'dev') {
require('./reactotron-config');
}
const AuthStack = createStackNavigator(
{ SignIn },
{
navigationOptions: {
headerStyle: {
height: verticalScale(baseFontSize * 4),
backgroundColor: colors.primary
},
headerTintColor: '#fff',
headerTitleStyle: {
fontFamily: fonts.bold,
fontSize: verticalScale(baseFontSize),
fontWeight: 'normal'
}
}
}
);
const RootStack = createSwitchNavigator(
{
Auth: AuthStack,
Loading
},
{
initialRouteName: 'Loading'
}
);
const WrappedStack = () => <RootStack screenProps={{ t: i18n.getFixedT() }} />;
const ReloadAppOnLanguageChange = translate('translation', {
bindI18n: 'languageChanged',
bindStore: false
})(WrappedStack);
export default class App extends React.Component {
state = {
isSplashReady: false,
isStoreReady: false,
store: configureStore(() => {
this.setState({ isStoreReady: true });
})
};
cacheResources = async () => {
await Expo.Font.loadAsync({
CatamaranBold: require('./fonts/Catamaran-Bold.ttf'),
CatamaranRegular: require('./fonts/Catamaran-Regular.ttf')
});
const images = [
require('./assets/icon.png'),
require('./assets/logo.png'),
require('./assets/splash.png')
];
const cacheImages = images.map(image =>
Asset.fromModule(image).downloadAsync()
);
await Promise.all(cacheImages);
};
render() {
if (!this.state.isSplashReady || !this.state.isStoreReady) {
return (
<AppLoading
onError={console.warn} // eslint-disable-line
onFinish={() => this.setState({ isSplashReady: true })}
startAsync={this.cacheResources}
/>
);
}
return (
<Provider store={this.state.store}>
<I18nextProvider i18n={i18n}>
<ReloadAppOnLanguageChange />
</I18nextProvider>
</Provider>
);
}
}