//
//  PlayerListView.swift
//  DouShouQiIOS
//
//  Created by Pierre FERREIRA on 13/05/2024.
//

import SwiftUI

struct PlayerListView: View {
    var body: some View {
        //NavigationStack {
            ZStack {
                Rectangle().fill(Color.bgColor).ignoresSafeArea()
                VStack {
                    /*Text("Classement des joueurs")
                        .scaleEffect(1.75)*/
                    
                    List {
                        NavigationLink{
                            PlayerView(name: "Billy", age: 18, winLossRatio: 1.0, gamesPlayed: 10, wins: 5, losses: 5, histoMatches: [
                                                            Match(gameEndScreen: "opponent1", opponent: "Opponent 1", score: "3-2", result: "Victoire"),
                                                            Match(gameEndScreen: "opponent2", opponent: "Opponent 2", score: "1-3", result: "Défaite"),
                                                            Match(gameEndScreen: "opponent3", opponent: "Opponent 3", score: "2-2", result: "Nul")
                                                        ]) //mettre player plus tard

                        } label:{Text("pif")}
                        
                        NavigationLink("Billy", value: "Billyname")
                        NavigationLink("Bob", value: "Bob")
                        NavigationLink("Bromingo", value: "Bromingo")
                    }
                    .navigationDestination(for: String.self) { name in
                        PlayerView(name: name, age: 18, winLossRatio: 1.0, gamesPlayed: 10, wins: 5, losses: 5, histoMatches: [
                                                        Match(gameEndScreen: "opponent1", opponent: "Opponent 1", score: "3-2", result: "Victoire"),
                                                        Match(gameEndScreen: "opponent2", opponent: "Opponent 2", score: "1-3", result: "Défaite"),
                                                        Match(gameEndScreen: "opponent3", opponent: "Opponent 3", score: "2-2", result: "Nul")
                                                    ]) //mettre player plus tard
                    }
                    .navigationTitle("Leaderboard")
                }

                VStack {
                    Spacer()
                    NavButton("Menu", destinationView: {MainMenuView()}, hideBackButton: true)
                    .padding(.bottom, 20)
                }
            }
        //}
    }
}

struct PlayerListView_Previews: PreviewProvider {
    static var previews: some View {
        PlayerListView()
    }
}
