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.
 
 
PadelClub/PadelClub/Views/Calling/TeamsCallingView.swift

75 lines
2.3 KiB

//
// TeamsCallingView.swift
// PadelClub
//
// Created by razmig on 10/07/2024.
//
import SwiftUI
import LeStorage
struct TeamsCallingView: View {
@Environment(Tournament.self) var tournament: Tournament
var body: some View {
List {
let teams = tournament.selectedSortedTeams()
Section {
ForEach(teams) { team in
Menu {
_menuOptions(team: team)
} label: {
HStack {
TeamRowView(team: team, displayCallDate: true)
if team.called() {
Spacer()
Menu {
_menuOptions(team: team)
} label: {
LabelOptions().labelStyle(.iconOnly)
}
}
}
}
.buttonStyle(.plain)
.listRowView(isActive: team.didConfirmSummon(), color: .green, hideColorVariation: true)
}
}
}
.headerProminence(.increased)
.navigationTitle("Statut des équipes")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
}
@ViewBuilder
func _menuOptions(team: TeamRegistration) -> some View {
Button {
team.toggleSummonConfirmation()
do {
try self.tournament.tournamentStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
} label: {
if team.didConfirmSummon() {
Label("Confirmation reçue", systemImage: "checkmark.circle.fill").foregroundStyle(.green)
} else {
Label("Confirmation reçue", systemImage: "circle").foregroundStyle(.logoRed)
}
}
Divider()
Button(role: .destructive) {
team.callDate = nil
do {
try self.tournament.tournamentStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
} label: {
Text("Effacer la date de convocation")
}
}
}