-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathApp.js
56 lines (51 loc) · 1.37 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
import React from 'react';
import {
StyleSheet, Text, View, TouchableOpacity, Image,
} from 'react-native';
import { connect } from 'react-redux';
import Heartbeat from './Heartbeat';
import heart from './heart.png';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
},
view: {
flex: 0.5,
justifyContent: 'center',
alignItems: 'center',
},
button: {
backgroundColor: 'gray',
padding: 10,
margin: 10,
},
text: {
fontSize: 20,
color: 'white',
},
});
const App = ({ heartBeat }) => {
const imageSize = heartBeat ? 150 : 100;
return (
<View style={styles.container}>
<View style={styles.view}>
<Image source={heart} style={{ width: imageSize, height: imageSize }} resizeMode="contain" />
</View>
<View style={styles.view}>
<TouchableOpacity style={styles.button} onPress={() => Heartbeat.startService()}>
<Text style={styles.instructions}>Start</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.button} onPress={() => Heartbeat.stopService()}>
<Text style={styles.instructions}>Stop</Text>
</TouchableOpacity>
</View>
</View>
);
};
const mapStateToProps = store => ({
heartBeat: store.App.heartBeat,
});
export default connect(mapStateToProps)(App);