-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStartGame.js
182 lines (176 loc) · 4.64 KB
/
StartGame.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import React, { useState } from "react";
import {
View,
Text,
TextInput,
TouchableOpacity,
StyleSheet,
ImageBackground,
ScrollView,
} from "react-native";
import NavigationBar from "./component/NavigationBar";
const AddPlayerScreen = () => {
const [team1Players, setTeam1Players] = useState([]);
const [team2Players, setTeam2Players] = useState([]);
const [playerName1, setPlayerName1] = useState("");
const [playerName2, setPlayerName2] = useState("");
const addPlayerToTeam1 = () => {
setTeam1Players([...team1Players, playerName1]);
setPlayerName1("");
};
const addPlayerToTeam2 = () => {
setTeam2Players([...team2Players, playerName2]);
setPlayerName2("");
};
return (
<View style={styles.container}>
<ImageBackground
source={require("./backgroundImage.jpg")}
style={styles.backgroundImage}
resizeMode="cover"
>
<ScrollView>
<View style={styles.teamContainer}>
<Text style={[styles.title, { color: "green" }]}>Team 1</Text>
{team1Players.map((player, index) => (
<Text
key={index}
style={[styles.player, { backgroundColor: "green" }]}
>
{player}
</Text>
))}
<View style={styles.inputContainer}>
<TextInput
style={styles.input}
value={playerName1}
onChangeText={setPlayerName1}
placeholder="Player name"
placeholderTextColor="#d10000"
/>
<TouchableOpacity
style={[styles.addButton, { backgroundColor: "green" }]}
onPress={addPlayerToTeam1}
>
<Text style={styles.addButtonText}>+</Text>
</TouchableOpacity>
</View>
</View>
<View style={styles.teamContainer}>
<Text style={[styles.title, { color: "green" }]}>Team 2</Text>
{team2Players.map((player, index) => (
<Text
key={index}
style={[styles.player, { backgroundColor: "green" }]}
>
{player}
</Text>
))}
<View style={styles.inputContainer}>
<TextInput
style={styles.input}
value={playerName2}
onChangeText={setPlayerName2}
placeholder="Player name"
placeholderTextColor="#d10000"
/>
<TouchableOpacity
style={[styles.addButton, { backgroundColor: "green" }]}
onPress={addPlayerToTeam2}
>
<Text style={styles.addButtonText}>+</Text>
</TouchableOpacity>
</View>
</View>
<TouchableOpacity style={styles.startButton} onPress={() => alert("Coming Soon")}>
{/* TODO: Add screen with court and players inputted */}
<Text style={styles.startButtonText}>Start a game</Text>
</TouchableOpacity>
</ScrollView>
</ImageBackground>
<NavigationBar />
</View>
);
};
const styles = StyleSheet.create({
container: {
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
alignItems: "center",
justifyContent: "center",
},
backgroundImage: {
flex: 1,
resizeMode: "cover",
position: "absolute",
top: 0,
left: 0,
width: "100%",
height: "100%",
},
teamContainer: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
title: {
fontSize: 24,
fontWeight: "bold",
marginBottom: 10,
color: "#fff",
},
player: {
fontSize: 18,
paddingVertical: 10,
paddingHorizontal: 20,
marginBottom: 10,
borderRadius: 10,
alignSelf: "stretch",
textAlign: "center",
color: "#fff",
},
inputContainer: {
flexDirection: "row",
alignItems: "center",
marginBottom: 20,
},
input: {
flex: 1,
height: 50,
borderWidth: 1,
borderColor: "#ccc",
borderRadius: 10,
paddingHorizontal: 20,
marginRight: 10,
backgroundColor: "#fff",
backgroundColor: "#ffe795"
},
addButton: {
width: 50,
height: 50,
backgroundColor: "#ccc",
borderRadius: 10,
alignItems: "center",
justifyContent: "center",
},
addButtonText: {
fontSize: 24,
fontWeight: "bold",
},
startButton: {
backgroundColor: "orange",
borderRadius: 10,
padding: 15,
marginTop: 30,
},
startButtonText: {
color: "#fff",
fontSize: 20,
fontWeight: "bold",
textAlign: "center",
},
});
export default AddPlayerScreen;