import SwiftUI
|
|
|
|
struct ContentView: View {
|
|
@StateObject private var scoreManager = PadelScoreManager()
|
|
|
|
var body: some View {
|
|
VStack {
|
|
Text("Pádel Score Tracker")
|
|
.font(.headline)
|
|
.padding(.bottom)
|
|
|
|
HStack {
|
|
VStack {
|
|
Text("Jugador 1")
|
|
Text("Score: \(scoreManager.player1Score)")
|
|
Text("Games: \(scoreManager.player1Games)")
|
|
Text("Sets: \(scoreManager.player1Sets)")
|
|
Button("Agregar Punto") {
|
|
scoreManager.addPoint(to: &scoreManager.player1Score, opponentScore: &scoreManager.player2Score, playerGames: &scoreManager.player1Games, opponentGames: &scoreManager.player2Games)
|
|
}
|
|
}
|
|
VStack {
|
|
Text("Jugador 2")
|
|
Text("Score: \(scoreManager.player2Score)")
|
|
Text("Games: \(scoreManager.player2Games)")
|
|
Text("Sets: \(scoreManager.player2Sets)")
|
|
Button("Agregar Punto") {
|
|
scoreManager.addPoint(to: &scoreManager.player2Score, opponentScore: &scoreManager.player1Score, playerGames: &scoreManager.player2Games, opponentGames: &scoreManager.player1Games)
|
|
}
|
|
}
|
|
}
|
|
.padding(.bottom)
|
|
|
|
HStack {
|
|
Button("Reiniciar") {
|
|
scoreManager.resetScores()
|
|
}
|
|
Spacer()
|
|
Text(scoreManager.isPlayer1Serving ? "Jugador 1 Sirve" : "Jugador 2 Sirve")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct ContentView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
ContentView()
|
|
}
|
|
}
|