parent
efe43894a8
commit
686df2250b
|
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