-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathApp.js
More file actions
87 lines (79 loc) · 2.31 KB
/
Copy pathApp.js
File metadata and controls
87 lines (79 loc) · 2.31 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 React from 'react';
import { StyleSheet, Text } from 'react-native';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { composeWithDevTools } from 'redux-devtools-extension';
import { ScreenOrientation } from 'expo';
import 'react-native-gesture-handler';
import colourUtils from './src/utils/styles/colours';
import Search from './src/modules/search/search-container';
import Profile from './src/modules/profile/profile-container';
import rootReducer from './src/reducers';
import { getPersistantData } from './src/utils/storage-utils';
import { Loading } from './src/modules/loading/loading';
export default class App extends React.Component {
state = {
loading: true,
initialState: [],
}
componentWillMount() {
getPersistantData('@favourites').then((favourites) => {
this.setState({
loading: false,
initialState: {
favouriteReducer: {
favourites
}
}
});
});
}
componentDidMount() {
ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.DEFAULT);
}
renderLoading = () => (
<Loading />
)
renderPage(initialState) {
this.mainNavigatior = createStackNavigator(
{
Search: { screen: Search },
Profile: { screen: Profile }
},
{
initialRouteName: 'Search',
defaultNavigationOptions: {
headerStyle: {
backgroundColor: colourUtils.navy,
},
headerTintColor: colourUtils.white,
headerTitle: <Text style={styles.headerTitle}>Leaguéu</Text>
}
}
);
const store = createStore(
rootReducer, initialState, composeWithDevTools(applyMiddleware(thunk))
);
const AppContainer = createAppContainer(this.mainNavigatior);
return (
<Provider store={store}>
<AppContainer style={styles.container} />
</Provider>
);
}
render() {
const { loading, initialState } = this.state;
return loading ? this.renderLoading() : this.renderPage(initialState);
}
}
const styles = StyleSheet.create({
container: {
fontFamily: 'san-serif'
},
headerTitle: {
fontSize: 18,
color: colourUtils.linkWater
}
});