// // TeamWeightView.swift // PadelClub // // Created by Razmig Sarkissian on 18/04/2024. // import SwiftUI struct TeamWeightView: View { @EnvironmentObject var dataStore: DataStore let team: TeamRegistration var teamPosition: TeamPosition? = nil var teamIndex: Int? private var _teamIndex: Int? { teamIndex ?? team.tournamentObject()?.indexOf(team: team) } var displayWeight: Bool { team.tournamentObject()?.hideWeight() == false } var body: some View { VStack(alignment: .trailing, spacing: 0) { if (teamPosition == .one || teamPosition == nil) && displayWeight { Text(team.weight.formatted()) .monospacedDigit() .font(.caption) } if let _teamIndex { Text("#" + (_teamIndex + 1).formatted(.number.precision(.integerLength(2...3)))) .monospacedDigit() } if teamPosition == .two && displayWeight { Text(team.weight.formatted()) .monospacedDigit() .font(.caption) } } } } //#Preview { // TeamWeightView(team: TeamRegistration.mock(), teamPosition: .one) //}