You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.5 KiB
83 lines
2.5 KiB
//
|
|
// HistoryView.swift
|
|
// DouShouQiIOS
|
|
//
|
|
// Created by Pierre FERREIRA on 21/05/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
|
|
struct HistoryView: View {
|
|
var playerName: String
|
|
var matches: [Match] // Modèle des parties du joueur
|
|
|
|
var body: some View {
|
|
|
|
VStack{
|
|
Text("Historique du joueur").font(.largeTitle)
|
|
|
|
HStack{
|
|
Spacer()
|
|
DoubleTextDisplay(textL: "Ratio", textR: "0,3")
|
|
Spacer()
|
|
DoubleTextDisplay(textL: "Total", textR: "3")
|
|
Spacer()
|
|
}
|
|
|
|
|
|
List(matches) { match in
|
|
HStack {
|
|
Image(match.gameEndScreen)
|
|
.resizable()
|
|
.aspectRatio(contentMode: .fit)
|
|
.frame(width: 50, height: 50)
|
|
.cornerRadius(8)
|
|
|
|
VStack(alignment: .leading) {
|
|
Text(match.opponent)
|
|
.font(.headline)
|
|
Text("Score: \(match.score)")
|
|
.font(.subheadline)
|
|
}
|
|
.padding(.leading, 10)
|
|
|
|
Spacer()
|
|
|
|
Text(match.result)
|
|
.foregroundColor(match.result == "Victoire" ? .green : .red)
|
|
.padding(.trailing, 10)
|
|
}.listRowBackground(Color.yellow.opacity(0.1))
|
|
.padding()
|
|
.background(match.result == "Victoire" ? Color.green.opacity(0.3) : Color.red.opacity(0.3))
|
|
.cornerRadius(10)
|
|
|
|
|
|
|
|
}
|
|
.padding()
|
|
.navigationTitle("Historique de \(playerName)")
|
|
|
|
}.background(Color.gray.opacity(0.1))
|
|
}
|
|
}
|
|
|
|
struct Match: Identifiable {
|
|
var id = UUID()
|
|
var gameEndScreen: String
|
|
var opponent: String
|
|
var score: String
|
|
var result: String
|
|
}
|
|
|
|
struct HistoryView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
let sampleMatches = [
|
|
Match(gameEndScreen: "DouShouQi", opponent: "Opponent 1", score: "3-0", result: "Victoire"),
|
|
Match(gameEndScreen: "DouShouQi", opponent: "Opponent 2", score: "0-3", result: "Défaite"),
|
|
Match(gameEndScreen: "DouShouQi", opponent: "Opponent 3", score: "2-2", result: "Nul")
|
|
]
|
|
HistoryView(playerName: "bro", matches: sampleMatches)
|
|
}
|
|
}
|