This repository has been archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
App.js
executable file
·117 lines (111 loc) · 3.2 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
116
117
import React, { Component } from 'react';
import { StyleSheet, View, StatusBar } from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import I18n from './src/i18n/i18n';
import HeaderRight from './src/components/HeaderRight';
import HomePage from './src/components/HomePage';
import ResultPage from './src/components/ResultPage';
import SettingsPage from './src/components/SettingsPage';
import AboutPage from './src/components/AboutPage';
import ContactPage from './src/components/ContactPage';
import SettingsOptionSelectorPage from './src/components/SettingsOptionSelectorPage';
import ShareResultPage from './src/components/ShareResultPage';
import { colourPrimary, colourPrimaryDark } from './src/styles/colours';
const headerStyle = {
backgroundColor: colourPrimary,
borderBottomWidth: 0,
// elevation: 0
// shadowColor: 'transparent'
};
class App extends Component {
async componentDidMount() {
try {
const language = await AsyncStorage.getItem('Settings:Language');
if (language) {
I18n.locale = language;
this.forceUpdate();
}
} catch (error) {
// Error retrieving data
console.error('AsyncStorage not working right');
}
}
render() {
const AppNavigator = createStackNavigator({
Home: {
screen: HomePage,
navigationOptions: ({ navigation }) => ({
headerRight: <HeaderRight navigation={navigation} onChangeTranslation={() => {}} />,
headerStyle,
headerTintColor: 'white',
}),
},
Results: {
screen: ResultPage,
navigationOptions: {
headerStyle,
headerTintColor: 'white',
},
},
Settings: {
screen: SettingsPage,
navigationOptions: {
headerTitle: I18n.t('settingsTitle'),
headerStyle,
headerTintColor: 'white',
},
},
About: {
screen: AboutPage,
navigationOptions: {
headerTitle: I18n.t('aboutTitle'),
headerStyle,
headerTintColor: 'white',
},
},
Contact: {
screen: ContactPage,
navigationOptions: {
headerTitle: I18n.t('contactTitle'),
headerStyle,
headerTintColor: 'white',
},
},
SettingsOptionSelector: {
screen: SettingsOptionSelectorPage,
navigationOptions: ({ navigation }) => ({
headerTitle: navigation.state.params.headerTitle,
headerStyle,
headerTintColor: 'white',
}),
},
ShareResult: {
screen: ShareResultPage,
navigationOptions: {
headerTitle: I18n.t('actionShare'),
headerStyle,
headerTintColor: 'white',
},
},
},
{
cardStyle: {
backgroundColor: '#eee',
},
});
const AppContainer = createAppContainer(AppNavigator);
return (
<View style={styles.root}>
<StatusBar barStyle="light-content" backgroundColor={colourPrimaryDark} />
<AppContainer />
</View>
);
}
}
const styles = StyleSheet.create({
root: {
flex: 1,
},
});
export default App;