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.
84 lines
2.1 KiB
84 lines
2.1 KiB
//
|
|
// TournamentSettingsView.swift
|
|
// PadelClub
|
|
//
|
|
// Created by Razmig Sarkissian on 22/03/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
enum TournamentSettings: Identifiable, Selectable, Equatable {
|
|
static func == (lhs: TournamentSettings, rhs: TournamentSettings) -> Bool {
|
|
return lhs.id == rhs.id
|
|
}
|
|
|
|
case status
|
|
case general
|
|
case club(Tournament)
|
|
case matchFormats
|
|
|
|
var id: String { String(describing: self) }
|
|
|
|
func selectionLabel(index: Int) -> String {
|
|
switch self {
|
|
case .status:
|
|
return "Statut"
|
|
case .matchFormats:
|
|
return "Formats"
|
|
case .general:
|
|
return "Général"
|
|
case .club:
|
|
return "Terrains"
|
|
}
|
|
}
|
|
|
|
func badgeValue() -> Int? {
|
|
switch self {
|
|
case .club(let tournament):
|
|
return tournament.courtCount
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func badgeValueColor() -> Color? {
|
|
return .logoBackground
|
|
}
|
|
|
|
func badgeImage() -> Badge? {
|
|
return nil
|
|
}
|
|
}
|
|
|
|
struct TournamentSettingsView: View {
|
|
@State private var selectedDestination: TournamentSettings? = .general
|
|
@Environment(Tournament.self) var tournament: Tournament
|
|
|
|
private func destinations() -> [TournamentSettings] {
|
|
[.general, .club(tournament), .matchFormats]
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0) {
|
|
GenericDestinationPickerView(selectedDestination: $selectedDestination, destinations: destinations(), nilDestinationIsValid: false)
|
|
switch selectedDestination! {
|
|
case .status:
|
|
TournamentStatusView(tournament: tournament)
|
|
case .matchFormats:
|
|
TournamentMatchFormatsSettingsView()
|
|
case .general:
|
|
TournamentGeneralSettingsView(tournament: tournament)
|
|
case .club:
|
|
TournamentClubSettingsView()
|
|
}
|
|
}
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbarBackground(.visible, for: .navigationBar)
|
|
.navigationTitle("Réglages du tournoi")
|
|
}
|
|
|
|
}
|
|
|
|
//#Preview {
|
|
// TournamentSettingsView()
|
|
//}
|
|
|