//
//  PlayerRow.swift
//  DouShouQi_App
//
//  Created by étudiant on 26/05/2024.
//

import Foundation
import SwiftUI

struct PlayerRow: View {
    var player: Player
    @Binding var players: [Player]
    
    var body: some View {
        HStack {
            if let image = UIImage(contentsOfFile: player.photo) {
                Image(uiImage: image)
                    .resizable()
                    .frame(width: 50, height: 50)
                    .clipShape(Circle())
            } else {
                Image(systemName: "person.circle.fill")
                    .resizable()
                    .frame(width: 50, height: 50)
                    .clipShape(Circle())
                    .foregroundColor(.gray)
            }
            
            VStack(alignment: .leading) {
                Text(player.name)
                    .font(.headline)
                Text("Victoires : \(player.wins)  Défaites : \(player.losses)")
                    .font(.subheadline)
            }
            Spacer()
            Button(action: {
                // Action pour éditer le joueur
            }) {
                Image(systemName: "pencil")
                    .foregroundColor(.black)
            }
            Button(action: {
            
                
            }) {
                Image(systemName: "trash")
                    .foregroundColor(.red)
            }
        }
        .padding()
        .background(Color.white)
        .cornerRadius(10)
        .shadow(radius: 1)
    }
}


