|
1 | | -/** |
2 | | - * Sample React Native App |
3 | | - * https://github.com/facebook/react-native |
4 | | - * @flow |
5 | | - */ |
6 | | - |
| 1 | +import 'src/config'; |
7 | 2 | import React, { Component } from 'react'; |
8 | | -import { |
9 | | - Platform, |
10 | | - StyleSheet, |
11 | | - Text, |
12 | | - View, |
13 | | - TextInput, |
14 | | -} from 'react-native'; |
15 | | - |
16 | | -import Child from './Child'; |
| 3 | +import { View, Image, StatusBar } from 'react-native'; |
| 4 | +import { Provider } from 'react-redux'; |
| 5 | +import { PersistGate } from 'redux-persist/es/integration/react'; |
17 | 6 |
|
18 | | -const instructions = Platform.select({ |
19 | | - ios: 'Press Cmd+R to reload,\n' + |
20 | | - 'Cmd+D or shake for dev menu', |
21 | | - android: 'Double tap R on your keyboard to reload,\n' + |
22 | | - 'Shake or press menu button for dev menu', |
23 | | -}); |
| 7 | +import { store, persistor } from 'src/state'; |
| 8 | +import { images, colors } from './theme'; |
| 9 | +import styles from './theme/styles'; |
| 10 | +import RootContainer from './containers/RootContainer'; |
| 11 | +import LoadingIndicator from './components/LoadingIndicator'; |
24 | 12 |
|
25 | | -export default class App extends Component<{}> { |
26 | | - constructor(props) { |
27 | | - super(props); |
28 | | - this.state = { text: '' }; |
29 | | - } |
30 | 13 |
|
31 | | - setText(text) { |
32 | | - this.setState({ text }); |
33 | | - } |
34 | | - |
35 | | - handleTextChange(text) { |
36 | | - this.setText(text); |
37 | | - } |
38 | | - |
39 | | - clearText() { |
40 | | - this.setText(''); |
| 14 | +class App extends Component { |
| 15 | + onBeforeLift = () => { |
| 16 | + // take some action before the gate lifts |
41 | 17 | } |
42 | 18 |
|
43 | 19 | render() { |
44 | | - const { text } = this.state; |
45 | | - |
46 | 20 | return ( |
47 | | - <View testID='Welcome' style={styles.container}> |
48 | | - <Text testID='WelcomeTitle' style={styles.welcome}> |
49 | | - Welcome to React Native! |
50 | | - </Text> |
51 | | - <Text testID='WelcomeInstruction' style={styles.instructions}> |
52 | | - To get started, edit App.js |
53 | | - </Text> |
54 | | - <Text testID='Instructions' style={styles.instructions}> |
55 | | - {instructions} |
56 | | - </Text> |
57 | | - <TextInput |
58 | | - value={text} |
59 | | - testID='TextInput' |
60 | | - style={styles.input} |
61 | | - placeholder={'Write something...'} |
62 | | - onChangeText={txt => this.handleTextChange(txt)} |
63 | | - /> |
64 | | - <Child text={text} onClear={() => this.clearText()} /> |
65 | | - </View> |
| 21 | + <Provider store={store}> |
| 22 | + <PersistGate |
| 23 | + loading={<LoadingIndicator />} |
| 24 | + onBeforeLift={this.onBeforeLift} |
| 25 | + persistor={persistor}> |
| 26 | + <View style={styles.mainContainer}> |
| 27 | + <StatusBar translucent barStyle="light-content" backgroundColor={colors.statusBarTranslucent} /> |
| 28 | + <Image source={images.background} style={styles.backgroundImage} /> |
| 29 | + <RootContainer /> |
| 30 | + </View> |
| 31 | + </PersistGate> |
| 32 | + </Provider> |
66 | 33 | ); |
67 | 34 | } |
68 | 35 | } |
69 | 36 |
|
70 | | -const styles = StyleSheet.create({ |
71 | | - container: { |
72 | | - flex: 1, |
73 | | - justifyContent: 'center', |
74 | | - alignItems: 'center', |
75 | | - backgroundColor: '#F5FCFF', |
76 | | - }, |
77 | | - welcome: { |
78 | | - fontSize: 20, |
79 | | - textAlign: 'center', |
80 | | - margin: 10, |
81 | | - }, |
82 | | - instructions: { |
83 | | - textAlign: 'center', |
84 | | - color: '#333333', |
85 | | - marginBottom: 5, |
86 | | - }, |
87 | | - input: { |
88 | | - width: '80%', |
89 | | - height: 60, |
90 | | - padding: 10, |
91 | | - marginTop: 30, |
92 | | - alignSelf: 'center', |
93 | | - }, |
94 | | -}); |
| 37 | +export default App; |
0 commit comments