-
Notifications
You must be signed in to change notification settings - Fork 788
/
App.js
115 lines (96 loc) · 2.62 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
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import styled from 'styled-components';
import {
AppRegistry,
LayoutAnimation,
StatusBar,
Platform,
} from 'react-native';
import codePush from 'react-native-code-push';
import { PersistGate } from 'redux-persist/integration/react';
import { SafeAreaProvider } from 'react-native-safe-area-context'; // eslint-disable-line
import { colors, getStatusBarConfig } from 'config';
import { getCurrentLocale, configureLocale } from 'utils';
import { GitPoint } from './routes';
import { configureStore, persistor } from './root.store';
const Container = styled.View`
align-items: center;
background-color: ${colors.white};
flex: 1;
justify-content: center;
`;
const Logo = styled.Image`
height: 100;
width: 100;
`;
if (console) {
console.disableYellowBox = true; // eslint-disable-line no-console
}
class App extends Component {
static async initLocale() {
const locale = await getCurrentLocale();
configureLocale(locale);
}
constructor() {
super();
this.state = {
rehydrated: false,
};
this.statusBarHandler = this.statusBarHandler.bind(this);
}
componentWillMount() {
this.constructor.initLocale();
}
componentDidMount() {
if (!__DEV__) {
codePush.sync({
updateDialog: false,
installMode: codePush.InstallMode.IMMEDIATE,
});
}
}
componentWillUpdate() {
LayoutAnimation.spring();
}
getCurrentRouteName(navigationState) {
if (!navigationState) {
return null;
}
const route = navigationState.routes[navigationState.index];
if (route.routes) {
return this.getCurrentRouteName(route);
}
return route.routeName;
}
statusBarHandler(prev, next) {
const routeName = this.getCurrentRouteName(next);
const { translucent, backgroundColor, barStyle } = getStatusBarConfig(
routeName
);
if (Platform.OS === 'android') {
StatusBar.setTranslucent(translucent);
StatusBar.setBackgroundColor(backgroundColor);
}
StatusBar.setBarStyle(barStyle);
}
renderLogo = () => (
<Container>
<Logo source={require('./src/assets/logo-black.png')} />
</Container>
);
render() {
return (
<Provider store={configureStore}>
<PersistGate loading={this.renderLogo} persistor={persistor}>
<SafeAreaProvider>
<GitPoint onNavigationStateChange={this.statusBarHandler}>
<StatusBar />
</GitPoint>
</SafeAreaProvider>
</PersistGate>
</Provider>
);
}
}
AppRegistry.registerComponent('GitPoint', () => App);