-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
123 lines (120 loc) · 3.01 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
118
119
120
121
122
123
import React from 'react'
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native'
import enhancer from './components/appLogic'
import numeral from 'numeral'
const App = props => (
<View style={styles.container}>
<View style={styles.scores}>
<View style={styles.score}>
<Text style={styles.scoreText}>Player 1: {props.playerOneCounter}</Text>
</View>
<View style={styles.score}>
<Text style={styles.scoreText}>Player 2: {props.playerTwoCounter}</Text>
</View>
</View>
<View style={styles.playZone}>
<TouchableOpacity
style={[styles.tap, styles.playerOne]}
onPress={() => props.onTap('playerOne')}
>
<Text>{props.playerOneTap ? 'TAPPED !' : 'TAP'}</Text>
</TouchableOpacity>
<TouchableOpacity
style={[styles.tap, styles.playerTwo]}
onPress={props.onTap.bind(this, 'playerTwo')}
>
<Text>{props.playerTwoTap ? 'TAPPED !' : 'TAP'}</Text>
</TouchableOpacity>
</View>
<View style={styles.footer}>
{props.status === 'stopped' && (
<TouchableOpacity
onPress={props.onStartClick}
style={[styles.footerArea, styles.newRoundButton]}
>
<Text>New Round</Text>
</TouchableOpacity>
)}
{props.status === 'stopped' &&
(props.playerOneCounter > 0 || props.playerTwoCounter > 0) && (
<TouchableOpacity
onPress={props.onRestartClick}
style={[styles.footerArea, styles.restartButton]}
>
<Text>Restart</Text>
</TouchableOpacity>
)}
{props.status === 'running' && (
<View style={styles.footerArea}>
{!props.hideTime && (
<Text>Time left: {numeral(props.time / 1000).format('0.00')}</Text>
)}
</View>
)}
{props.status === 'showResult' && (
<View style={styles.footerArea}>
<Text>{props.message}</Text>
</View>
)}
</View>
</View>
)
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#ddd',
alignItems: 'center',
justifyContent: 'center'
},
scores: {
flex: 20,
flexDirection: 'row',
backgroundColor: 'blue'
},
score: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
scoreText: {
fontSize: 20,
color: 'white'
},
playZone: {
flex: 70,
flexDirection: 'row',
width: null,
backgroundColor: 'red'
},
tap: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
playerOne: {
backgroundColor: 'green'
},
playerTwo: {
backgroundColor: 'pink'
},
footer: {
flex: 10,
flexDirection: 'row',
width: null,
backgroundColor: 'purple',
justifyContent: 'center'
},
footerArea: {
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'green',
flex: 1
},
newRoundButton: {
backgroundColor: 'green'
},
restartButton: {
backgroundColor: 'red'
}
})
export default enhancer(App)