-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScorePanel.js
More file actions
89 lines (85 loc) · 2.52 KB
/
ScorePanel.js
File metadata and controls
89 lines (85 loc) · 2.52 KB
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
import React from 'react';
import { Image, StyleSheet, Text, View, TouchableOpacity, Dimensions } from 'react-native';
export default class ScorePanel extends React.Component {
constructor(props){
super(props);
this.state = {score :0};
this.styles = this.createStyles(props.color);
}
createStyles(competitor) {
let h = Dimensions.get('window').height
let color = "black";
let background = "white";
if (competitor=="red" )
{
color ="white";
background="red"
}
return StyleSheet.create({
score: {
borderWidth: 1,
// borderRadius: 2,
// borderColor: "pink",
flex: 1,
// width: "50%",
// height: "100%",
backgroundColor: background,
alignItems: "center",
justifyContent: "center",
},
detail: {
fontSize: h*0.4,
fontWeight: "bold",
color: color,
// borderStyle: "dashed",
// borderColor: "grey",
// borderWidth: 1,
textAlign: "center",
// justifyContent: "space-evenly",
flex: 3,
// padding: 32,
margin:48
},
buttoncontainer: {
flex:1,
width: "100%",
flexDirection: "row",
justifyContent: "space-evenly",
borderWidth: 1,
borderColor:"black",
},
button: {
fontSize: h*0.1,
fontWeight:"bold",
flex: 1,
color: "black",
width: "100%",
height: "100%",
// borderStyle:"solid",
// borderWidth:1,
// borderColor:"orange",
textAlign:"center",
}
}
)
}
addPoint = () => {
this.setState({ score: this.state.score +1})
}
subPoint = () => {
if (this.state.score >0){
this.setState({ score: this.state.score -1})
}
}
render() {
return (
<View style={this.styles.score}>
<Text style={this.styles.detail} >{this.state.score}</Text>
<View style={this.styles.buttoncontainer}>
<TouchableOpacity onPress={ this.addPoint} ><Text style={this.styles.button}>+1</Text></TouchableOpacity>
<TouchableOpacity onPress={ this.subPoint} ><Text style={this.styles.button}>-1</Text></TouchableOpacity>
</View>
</View>
)
}
}