-
Notifications
You must be signed in to change notification settings - Fork 773
Expand file tree
/
Copy pathApp.js
More file actions
97 lines (81 loc) · 2.06 KB
/
Copy pathApp.js
File metadata and controls
97 lines (81 loc) · 2.06 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
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import styled from 'styled-components/native';
import { AppRegistry, AsyncStorage, LayoutAnimation } from 'react-native';
import { persistStore } from 'redux-persist';
import createEncryptor from 'redux-persist-transform-encrypt';
import DeviceInfo from 'react-native-device-info';
import md5 from 'md5';
import codePush from 'react-native-code-push';
import { colors } from 'config';
import { getCurrentLocale, configureLocale } from 'utils';
import { GitPoint } from './routes';
import { configureStore } 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,
};
}
componentWillMount() {
const encryptor = createEncryptor({
secretKey: md5(DeviceInfo.getUniqueID()),
});
persistStore(
configureStore,
{
storage: AsyncStorage,
transforms: [encryptor],
blacklist: ['user'],
},
() => {
this.setState({ rehydrated: true });
}
);
this.constructor.initLocale();
}
componentDidMount() {
if (!__DEV__) {
codePush.sync({
updateDialog: false,
installMode: codePush.InstallMode.IMMEDIATE,
});
}
}
componentWillUpdate() {
LayoutAnimation.spring();
}
render() {
if (!this.state.rehydrated) {
return (
<Container>
<Logo source={require('./src/assets/logo-black.png')} />
</Container>
);
}
return (
<Provider store={configureStore}>
<GitPoint onNavigationStateChange={null} />
</Provider>
);
}
}
AppRegistry.registerComponent('GitPoint', () => App);