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.
83 lines
2.7 KiB
83 lines
2.7 KiB
//
|
|
// TournamentOrganizerView.swift
|
|
// PadelClub
|
|
//
|
|
// Created by Razmig Sarkissian on 29/02/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct TournamentOrganizerView: View {
|
|
@State private var selectedTournamentId: String?
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0) {
|
|
ForEach(DataStore.fakeTournaments) { tournament in
|
|
if tournament.id == selectedTournamentId {
|
|
OrganizedTournamentView(tournament: tournament)
|
|
}
|
|
}
|
|
|
|
if selectedTournamentId == nil {
|
|
NavigationStack {
|
|
ContentUnavailableView("Aucun tournoi sélectionné", systemImage: "rectangle.slash", description: Text("Utilisez l'accès rapide ci-dessous pour éditer un tournoi et passer rapidement d'un tournoi à l'autre."))
|
|
.navigationTitle("Gestionnaire de tournois")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
}
|
|
}
|
|
Divider()
|
|
HStack {
|
|
ScrollView(.horizontal) {
|
|
HStack {
|
|
ForEach(DataStore.fakeTournaments) { tournament in
|
|
TournamentButtonView(tournament: tournament, selectedId: $selectedTournamentId)
|
|
}
|
|
}
|
|
.padding()
|
|
.buttonStyle(.plain)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct TournamentButtonView: View {
|
|
let tournament: Tournament
|
|
@Binding var selectedId: String?
|
|
|
|
var body: some View {
|
|
Button {
|
|
if selectedId == tournament.id {
|
|
tournament.navigationPath.removeAll()
|
|
selectedId = nil
|
|
// if tournament.navigationPath.isEmpty {
|
|
// selectedId = nil
|
|
// } else {
|
|
// tournament.navigationPath.removeLast()
|
|
// }
|
|
} else {
|
|
selectedId = tournament.id
|
|
}
|
|
} label: {
|
|
TournamentCellView(tournament: tournament)
|
|
.padding(8)
|
|
.overlay(
|
|
RoundedRectangle(cornerRadius: 20)
|
|
.stroke(Color.black, lineWidth: 2)
|
|
)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
}
|
|
.overlay(alignment: .top) {
|
|
if selectedId == tournament.id {
|
|
Image(systemName: "ellipsis")
|
|
.offset(y: -10)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#Preview {
|
|
TournamentOrganizerView()
|
|
}
|
|
|