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.5 KiB
47 lines
1.5 KiB
//
|
|
// RoundsView.swift
|
|
// PadelClub
|
|
//
|
|
// Created by Razmig Sarkissian on 30/03/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct RoundsView: View {
|
|
var tournament: Tournament
|
|
@State private var selectedRound: Round?
|
|
@State private var isEditingTournamentSeed = false
|
|
|
|
init(tournament: Tournament) {
|
|
self.tournament = tournament
|
|
if tournament.shouldVerifyBracket {
|
|
_selectedRound = State(wrappedValue: nil)
|
|
} else {
|
|
_selectedRound = State(wrappedValue: tournament.getActiveRound())
|
|
}
|
|
if tournament.availableSeeds().isEmpty == false || tournament.availableQualifiedTeams().isEmpty == false {
|
|
_isEditingTournamentSeed = State(wrappedValue: true)
|
|
}
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0) {
|
|
GenericDestinationPickerView(selectedDestination: $selectedRound, destinations: tournament.rounds(), nilDestinationIsValid: true)
|
|
switch selectedRound {
|
|
case .none:
|
|
RoundSettingsView()
|
|
.navigationTitle("Réglages")
|
|
case .some(let selectedRound):
|
|
RoundView(round: selectedRound)
|
|
.navigationTitle(selectedRound.roundTitle())
|
|
}
|
|
}
|
|
.environment(\.isEditingTournamentSeed, $isEditingTournamentSeed)
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbarBackground(.visible, for: .navigationBar)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
RoundsView(tournament: Tournament.mock())
|
|
}
|
|
|