add stat for players

pull/13/head
Rayhân HASSOU 11 months ago
parent 7163a17723
commit 3c42f5c42a

@ -45,6 +45,7 @@
EC62C50D2C046D9E0048CD0B /* SplashScreenSound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */; }; EC62C50D2C046D9E0048CD0B /* SplashScreenSound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */; };
EC62C50F2C05D06A0048CD0B /* AddPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C50E2C05D06A0048CD0B /* AddPlayerView.swift */; }; EC62C50F2C05D06A0048CD0B /* AddPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C50E2C05D06A0048CD0B /* AddPlayerView.swift */; };
EC62C5172C0620C00048CD0B /* rap.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C5162C0620C00048CD0B /* rap.mp3 */; }; EC62C5172C0620C00048CD0B /* rap.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C5162C0620C00048CD0B /* rap.mp3 */; };
EC62C51B2C09D1790048CD0B /* PlayerStatView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C51A2C09D1790048CD0B /* PlayerStatView.swift */; };
ECB636552C047992007CD5E2 /* Image.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ECB636542C047992007CD5E2 /* Image.xcassets */; }; ECB636552C047992007CD5E2 /* Image.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ECB636542C047992007CD5E2 /* Image.xcassets */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -108,6 +109,7 @@
EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = SplashScreenSound.mp3; sourceTree = "<group>"; }; EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = SplashScreenSound.mp3; sourceTree = "<group>"; };
EC62C50E2C05D06A0048CD0B /* AddPlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddPlayerView.swift; sourceTree = "<group>"; }; EC62C50E2C05D06A0048CD0B /* AddPlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddPlayerView.swift; sourceTree = "<group>"; };
EC62C5162C0620C00048CD0B /* rap.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = rap.mp3; sourceTree = "<group>"; }; EC62C5162C0620C00048CD0B /* rap.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = rap.mp3; sourceTree = "<group>"; };
EC62C51A2C09D1790048CD0B /* PlayerStatView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerStatView.swift; sourceTree = "<group>"; };
ECB636542C047992007CD5E2 /* Image.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Image.xcassets; sourceTree = "<group>"; }; ECB636542C047992007CD5E2 /* Image.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Image.xcassets; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -231,6 +233,7 @@
647D565B2BFD0212008D02EA /* PlayerResumeFrame.swift */, 647D565B2BFD0212008D02EA /* PlayerResumeFrame.swift */,
EC62C4FC2C0391D30048CD0B /* PlayerRow.swift */, EC62C4FC2C0391D30048CD0B /* PlayerRow.swift */,
EC62C50E2C05D06A0048CD0B /* AddPlayerView.swift */, EC62C50E2C05D06A0048CD0B /* AddPlayerView.swift */,
EC62C51A2C09D1790048CD0B /* PlayerStatView.swift */,
); );
path = Player; path = Player;
sourceTree = "<group>"; sourceTree = "<group>";
@ -504,6 +507,7 @@
645B4C252BFCD3C600FD658A /* ScoreBoardView.swift in Sources */, 645B4C252BFCD3C600FD658A /* ScoreBoardView.swift in Sources */,
649B59AE2BF64EAB002BAE38 /* AppImages.swift in Sources */, 649B59AE2BF64EAB002BAE38 /* AppImages.swift in Sources */,
649ABF602BF60F2D002E8894 /* MainMenuButton.swift in Sources */, 649ABF602BF60F2D002E8894 /* MainMenuButton.swift in Sources */,
EC62C51B2C09D1790048CD0B /* PlayerStatView.swift in Sources */,
643AB6932BFCEFD00018DA73 /* GameResumeFrame.swift in Sources */, 643AB6932BFCEFD00018DA73 /* GameResumeFrame.swift in Sources */,
649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */, 649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */,
EC62C5092C0467240048CD0B /* SplashScreenView.swift in Sources */, EC62C5092C0467240048CD0B /* SplashScreenView.swift in Sources */,

@ -12,6 +12,8 @@ struct PlayerRow: View {
var player: Player var player: Player
@Binding var players: [Player] @Binding var players: [Player]
@State private var showDetailView = false
var body: some View { var body: some View {
HStack { HStack {
if let image = UIImage(contentsOfFile: player.photo) { if let image = UIImage(contentsOfFile: player.photo) {
@ -35,17 +37,13 @@ struct PlayerRow: View {
} }
Spacer() Spacer()
Button(action: { Button(action: {
// Action pour éditer le joueur showDetailView.toggle()
}) { }) {
Image(systemName: "pencil") Image(systemName: "info.circle")
.foregroundColor(.black) .foregroundColor(.blue)
} }
Button(action: { .sheet(isPresented: $showDetailView) {
PlayerStatView(player: player)
}) {
Image(systemName: "trash")
.foregroundColor(.red)
} }
} }
.padding() .padding()
@ -54,5 +52,3 @@ struct PlayerRow: View {
.shadow(radius: 1) .shadow(radius: 1)
} }
} }

@ -0,0 +1,61 @@
//
// PlayerStatView.swift
// DouShouQi_App
//
// Created by étudiant on 31/05/2024.
//
import SwiftUI
struct PlayerStatView: View {
var player: Player
var body: some View {
VStack {
if let image = UIImage(contentsOfFile: player.photo) {
Image(uiImage: image)
.resizable()
.frame(width: 100, height: 100)
.clipShape(Circle())
.padding(.top, 10)
} else {
Image(systemName: "person.circle.fill")
.resizable()
.frame(width: 100, height: 100)
.clipShape(Circle())
.foregroundColor(.gray)
.padding(.top, 10)
}
Text(player.name)
.font(.largeTitle)
.foregroundColor(.black)
.padding(.top, 10)
VStack(alignment: .leading, spacing: 10) {
HStack {
Image(systemName: "trophy.fill")
Text("Win : \(player.wins)")
.font(.title2)
}
HStack {
Image(systemName: "xmark.circle.fill")
Text("Loose : \(player.losses)")
.font(.title2)
}
HStack {
Image(systemName: "chart.line.uptrend.xyaxis")
Text("Win Rate : \(String(format: "%.2f", Double(player.wins) / Double(player.wins + player.losses) * 100))%")
.font(.title2)
}
HStack {
Image(systemName: "list.number")
Text("Rank : 3")
.font(.title2)
}
}
.padding()
Spacer()
}
}
}
Loading…
Cancel
Save