-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHome.js
71 lines (63 loc) · 1.84 KB
/
Home.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
// @flow
import React, { Component } from 'react';
import { Modal, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { StackNavigator } from 'react-navigation';
import ExampleStatistics from './ExampleStatistics';
type Props = {
navigation: typeof StackNavigator,
};
type State = {
modalVisible: boolean,
};
export default class Home extends Component<Props, State> {
props: Props;
state: State = {
modalVisible: false,
};
static navigationOptions = {
title: 'Home',
};
render() {
return (
<View style={styles.container}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('ExampleCalculator')} style={styles.button}>
<Text style={styles.buttonText}>Example 1</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.props.navigation.navigate('ExampleTouch')} style={styles.button}>
<Text style={styles.buttonText}>Example 2</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.setState({ modalVisible: true })} style={styles.button}>
<Text style={styles.buttonText}>Example 3</Text>
</TouchableOpacity>
<Modal
animationType={'slide'}
transparent={false}
visible={this.state.modalVisible}
onRequestClose={() => this.setState({ modalVisible: false })}
>
<ExampleStatistics onPressExit={() => this.setState({ modalVisible: false })} />
</Modal>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
backgroundColor: '#F5FCFF',
paddingTop: 80,
},
button: {
backgroundColor: 'lightgray',
borderRadius: 6,
width: 300,
height: 60,
justifyContent: 'center',
alignItems: 'center',
margin: 10,
},
buttonText: {
fontSize: 40,
},
});