You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
//
|
|
// 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)
|
|
//}
|
|
|