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/Tournament/Screen/TournamentSettingsView.swift

75 lines
1.8 KiB

//
// TournamentSettingsView.swift
// PadelClub
//
// Created by Razmig Sarkissian on 22/03/2024.
//
import SwiftUI
enum TournamentSettings: Identifiable, Selectable {
case general
case club(Tournament)
case matchFormats
var id: String { String(describing: self) }
func selectionLabel() -> String {
switch self {
case .matchFormats:
return "Formats de jeu"
case .general:
return "Général"
case .club:
return "Club"
}
}
func badgeValue() -> Int? {
nil
}
func badgeImage() -> Badge? {
switch self {
case .club(let tournament):
if tournament.club() != nil {
return .checkmark
} else {
return .xmark
}
default:
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 .matchFormats:
TournamentMatchFormatsSettingsView()
case .general:
TournamentGeneralSettingsView()
case .club:
TournamentClubSettingsView()
}
}
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
.navigationTitle("Réglages")
}
}
#Preview {
TournamentSettingsView()
}