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.
59 lines
1.6 KiB
59 lines
1.6 KiB
//
|
|
// MatchTeamDetailView.swift
|
|
// PadelClub
|
|
//
|
|
// Created by Razmig Sarkissian on 18/04/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct MatchTeamDetailView: View {
|
|
@EnvironmentObject var tournamentStore: TournamentStore
|
|
let match: Match
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
let tournament = match.currentTournament()
|
|
List {
|
|
if let teamOne = match.team(.one) {
|
|
_teamDetailView(teamOne, inTournament: tournament)
|
|
}
|
|
if let teamTwo = match.team(.two) {
|
|
_teamDetailView(teamTwo, inTournament: tournament)
|
|
}
|
|
}
|
|
.headerProminence(.increased)
|
|
.tint(.master)
|
|
}
|
|
.presentationDetents([.fraction(0.66)])
|
|
}
|
|
|
|
@ViewBuilder
|
|
private func _teamDetailView(_ team: TeamRegistration, inTournament tournament: Tournament?) -> some View {
|
|
Section {
|
|
ForEach(team.players()) { player in
|
|
EditablePlayerView(player: player, editingOptions: _editingOptions())
|
|
}
|
|
} header: {
|
|
TeamHeaderView(team: team, teamIndex: tournament?.indexOf(team: team))
|
|
}
|
|
}
|
|
|
|
private func _isFree() -> Bool {
|
|
let tournament = match.currentTournament()
|
|
return tournament?.isFree() == true
|
|
}
|
|
|
|
private func _editingOptions() -> [EditablePlayerView.PlayerEditingOption] {
|
|
if _isFree() {
|
|
return [.licenceId, .name, .presence]
|
|
} else {
|
|
return [.licenceId, .name, .payment]
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
//#Preview {
|
|
// MatchTeamDetailView(match: Match.mock())
|
|
//}
|
|
|