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.
67 lines
2.3 KiB
67 lines
2.3 KiB
//
|
|
// TeamHeaderView.swift
|
|
// PadelClub
|
|
//
|
|
// Created by Razmig Sarkissian on 18/04/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct TeamHeaderView: View {
|
|
var team: TeamRegistration
|
|
var teamIndex: Int?
|
|
var tournament: Tournament?
|
|
var teamCount: Int?
|
|
|
|
var body: some View {
|
|
HStack(spacing: 16.0) {
|
|
if let teamIndex {
|
|
VStack(alignment: .leading, spacing: 0) {
|
|
Text("Rang").font(.caption)
|
|
Text("#" + (teamIndex + 1).formatted())
|
|
}
|
|
}
|
|
|
|
if team.unsortedPlayers().isEmpty == false {
|
|
if tournament?.hideWeight() == false, team.weight > 0 {
|
|
VStack(alignment: .leading, spacing: 0) {
|
|
Text("Poids").font(.caption)
|
|
Text(team.weight.formatted())
|
|
}
|
|
}
|
|
if let name = team.name, name.isEmpty == false {
|
|
VStack(alignment: .leading, spacing: 0) {
|
|
Text("Nom de l'équipe").font(.caption)
|
|
Text(name).lineLimit(1).truncationMode(.tail)
|
|
}
|
|
}
|
|
}
|
|
Spacer()
|
|
VStack(alignment: .trailing, spacing: 0) {
|
|
if team.walkOut {
|
|
Text("").font(.caption)
|
|
Text("WO")
|
|
} else if let teamIndex, let tournament {
|
|
let positionLabel = team.positionLabel()
|
|
let cutLabel = tournament.cutLabel(index: teamIndex, teamCount: teamCount)
|
|
if team.isWildCard() {
|
|
Text("wildcard").foregroundStyle(.red).font(.caption).italic()
|
|
Text(positionLabel ?? cutLabel)
|
|
} else {
|
|
if let positionLabel {
|
|
Text("placée").font(.caption)
|
|
Text(positionLabel)
|
|
} else {
|
|
Text("estimée").font(.caption)
|
|
Text(cutLabel)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//#Preview {
|
|
// TeamHeaderView(team: TeamRegistration.mock(), teamIndex: 1, tournament: nil)
|
|
//}
|
|
|