//
//  MatchFormatRowView.swift
//  PadelClub
//
//  Created by Razmig Sarkissian on 02/04/2024.
//

import SwiftUI

struct MatchFormatRowView: View {
    let matchFormat: MatchFormat
    var headerLabel: String? = nil
    var hideExplanation: Bool = false
    var hideDuration: Bool = false
    var additionalEstimationDuration: Int?
    var displayStyle: DisplayStyle = .wide

    var body: some View {
        VStack(alignment: .leading) {
            if let headerLabel {
                HStack {
                    Text(headerLabel).font(.footnote)
                    if hideDuration == false {
                        Spacer()
                        Text("Durée").font(.footnote)
                    }
                }
            }
            HStack {
                Text(matchFormat.formatTitle(displayStyle))
                if hideDuration == false && displayStyle != .short {
                    Spacer()
                    Text("~" + matchFormat.formattedEstimatedDuration(additionalEstimationDuration ?? 0))
                }
            }
            .font(.headline)
            
            if hideExplanation == false {
                Text(matchFormat.longLabel)
                Text(matchFormat.formattedEstimatedBreakDuration()).font(.footnote)
                if matchFormat.isFederal == false {
                    Text("Non officiel").foregroundStyle(.logoRed).font(.footnote)
                }
            }
        }
    }
}
