From 86912bf1fff9fe3217b1dd1385e843072916124e Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 17 Jun 2024 15:17:14 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Update:=20Show=20button=20and=20aff?= =?UTF-8?q?iche=20all=20player?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Player/ShowAllPlayer.swift | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/DouShouQi_App/DouShouQi_App/Components/Player/ShowAllPlayer.swift b/DouShouQi_App/DouShouQi_App/Components/Player/ShowAllPlayer.swift index b0173ae..cf706fc 100644 --- a/DouShouQi_App/DouShouQi_App/Components/Player/ShowAllPlayer.swift +++ b/DouShouQi_App/DouShouQi_App/Components/Player/ShowAllPlayer.swift @@ -6,29 +6,45 @@ // import SwiftUI -import UIKit struct ShowAllPlayer: View { - @State var isShowingSheet = false - @Binding var players: [Player] + @State private var isShowingSheet = false + @ObservedObject var playersVM: PlayersVM + var body: some View { - VStack { - Button(action: { - }) { - Text("Afficher les joueurs") - } + VStack(alignment: .leading) { + Text("Liste des joueurs actuelle :") + List { + ForEach($playersVM.players, id: \.self) { playerVM in + Button(action: { + + }) { + HStack { + Image(systemName: "person.fill") + .resizable() + .frame(width: 30, height: 30) + Text(playerVM.player.name.wrappedValue) + } + } + } + } Button(action: { self.isShowingSheet = true }) { - Text("Add Player") + Text("Add a player") + .font(.headline) .foregroundColor(.white) .padding() + .frame(maxWidth: .infinity) .background(Color.red) .cornerRadius(10) - .sheet(isPresented: $isShowingSheet) { - AddPlayerView(isPresented: $isShowingSheet, players: $players) - } + .padding(.horizontal) + } + .padding(.bottom) + .sheet(isPresented: $isShowingSheet) { + AddPlayerView(isPresented: $isShowingSheet, playersVM: playersVM) } } } } +