//
//  MatchRowView.swift
//  Padel Tournament
//
//  Created by Razmig Sarkissian on 25/11/2023.
//

import SwiftUI

struct MatchRowView: View {
    var match: Match
    let matchViewStyle: MatchViewStyle
    @Environment(\.isEditingTournamentSeed) private var isEditingTournamentSeed

    @ViewBuilder
    var body: some View {
        if isEditingTournamentSeed.wrappedValue == true && match.isGroupStage() == false && match.isLoserBracket == false {
            MatchSetupView(match: match)
        } else {
//            MatchSummaryView(match: match, matchViewStyle: matchViewStyle)
//                .overlay {
//                    if match.disabled {
//                        Image(systemName: "xmark")
//                            .resizable()
//                            .scaledToFit()
//                            .opacity(0.8)
//                    }
//                }
//                .contextMenu(menuItems: {
//                    Text("index: \(match.index)")
//                    Text("bye state : \(match.byeState)")
//                    Text("disable state : \(match.disabled)")
//                    Button("enable") {
//                        match._toggleMatchDisableState(false)
//                    }
//                    Button("disable") {
//                        match._toggleMatchDisableState(true)
//                    }
//                    Button("bye") {
//                        match.byeState = true
//                    }
//                    Button("not bye") {
//                        match.byeState = false
//                    }
//                    Button("solo toggle") {
//                        match.disabled.toggle()
//                    }
//                    Button("toggle fwrd match") {
//                        match._toggleForwardMatchDisableState(true)
//                    }
//                    Button("toggle loser match") {
//                        match._toggleLoserMatchDisableState(true)
//                    }
//                })

            NavigationLink {
                MatchDetailView(match: match, matchViewStyle: matchViewStyle)
            } label: {
                MatchSummaryView(match: match, matchViewStyle: matchViewStyle)
            }
            //.modifier(BroadcastViewModifier(isBroadcasted: match.isBroadcasted()))
        }
    }
}


//#Preview {
//    MatchRowView(match: Match.mock(), matchViewStyle: .standardStyle)
//}
