Merge branch 'main' of https://stax.alwaysdata.net/gitea/staxriver/PadelClub
commit
c2ca49e9f6
|
After Width: | Height: | Size: 73 KiB |
@ -0,0 +1,64 @@ |
||||
// |
||||
// EventClubSettingsView.swift |
||||
// PadelClub |
||||
// |
||||
// Created by Razmig Sarkissian on 18/04/2024. |
||||
// |
||||
|
||||
import SwiftUI |
||||
import LeStorage |
||||
|
||||
struct EventClubSettingsView: View { |
||||
@EnvironmentObject var dataStore: DataStore |
||||
@State private var selectedCourt: Court? |
||||
@State private var showClubDetail: Club? |
||||
var event: Event |
||||
|
||||
var body: some View { |
||||
List { |
||||
let selectedClub = event.clubObject() |
||||
|
||||
Section { |
||||
NavigationLink { |
||||
ClubsView() { club in |
||||
event.club = club.id |
||||
do { |
||||
try dataStore.events.addOrUpdate(instance: event) |
||||
} catch { |
||||
Logger.error(error) |
||||
} |
||||
} |
||||
} label: { |
||||
if let selectedClub = event.clubObject() { |
||||
ClubRowView(club: selectedClub) |
||||
} else { |
||||
Text("Choisir un club") |
||||
} |
||||
} |
||||
} header: { |
||||
Text("Lieu de l'événement") |
||||
} footer: { |
||||
HStack { |
||||
Spacer() |
||||
FooterButtonView("détails du club") { |
||||
showClubDetail = selectedClub |
||||
} |
||||
} |
||||
} |
||||
|
||||
if let selectedClub { |
||||
ClubCourtSetupView(club: selectedClub, displayContext: selectedClub.hasBeenCreated(by: StoreCenter.main.userId) ? .edition : .lockedForEditing, selectedCourt: $selectedCourt) |
||||
} |
||||
} |
||||
.navigationDestination(item: $showClubDetail) { club in |
||||
ClubDetailView(club: club, displayContext: club.hasBeenCreated(by: StoreCenter.main.userId) ? .edition : .lockedForEditing) |
||||
} |
||||
.navigationDestination(item: $selectedCourt) { court in |
||||
CourtView(court: court) |
||||
} |
||||
} |
||||
} |
||||
|
||||
//#Preview { |
||||
// TournamentClubSettingsView() |
||||
//} |
||||
Loading…
Reference in new issue