//
//  GameResumeFrame.swift
//  DouShouQi_App
//
//  Created by Rémi REGNAULT on 21/05/2024.
//

import SwiftUI
#if DEBUG
import DouShouQiModel
#endif

struct GameResumeFrame: View {
    
    // Players Params
    let gameVM: GameVM
    
    var body: some View {
        ZStack {
            HStack(alignment: .center) {
                VStack(alignment: .leading) {
                    Text("\(gameVM.player1Name) vs \(gameVM.player2Name)")
                        .font(.headline)
                    
                    Text(gameVM.gameStatus)
                        .font(.subheadline)
                        .foregroundColor(.gray)
                }
                
                Spacer()
                
                Text("Detail    >")
                    .frame(width: 100)
                    .foregroundColor(.gray)
            }
            
            .padding(10)
            .overlay(
                RoundedRectangle(cornerRadius: 3)
                    .stroke(.gray, lineWidth: 2)
            )
        }.padding(2)
    }
}

struct GameResumeFrame_Previews: PreviewProvider {
    static var previews: some View {
        do {
            let game = try Game(withRules: VerySimpleRules(), andPlayer1: HumanPlayer(withName: "Rémi", andId: .player1)!, andPlayer2: HumanPlayer(withName: "Nathan", andId: .player2)!)
            return AnyView(GameResumeFrame(gameVM: GameVM(withGame: game)))
        } catch {
            return AnyView(Text("Erreur lors de la création du jeu : \(error.localizedDescription)"))
        }
    }
}
