|
|
|
|
@ -9,37 +9,55 @@ import SwiftUI |
|
|
|
|
import LeStorage |
|
|
|
|
|
|
|
|
|
struct TournamentStatusView: View { |
|
|
|
|
@Environment(\.dismiss) private var dismiss |
|
|
|
|
@Environment(Tournament.self) private var tournament: Tournament |
|
|
|
|
@Environment(NavigationViewModel.self) private var navigation: NavigationViewModel |
|
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
@Bindable var tournament = tournament |
|
|
|
|
Form { |
|
|
|
|
RowButtonView("debug: Un-delete le tournoi") { |
|
|
|
|
tournament.endDate = nil |
|
|
|
|
tournament.isDeleted.toggle() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Supprimer le tournoi", role: .destructive) { |
|
|
|
|
tournament.isDeleted.toggle() |
|
|
|
|
if tournament.endDate == nil { |
|
|
|
|
RowButtonView("Terminer le tournoi", role: .destructive) { |
|
|
|
|
tournament.endDate = Date() |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
RowButtonView("Ré-ouvrir le tournoi", role: .destructive) { |
|
|
|
|
tournament.endDate = nil |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} footer: { |
|
|
|
|
Text("todo: expliquer ce que ca fait") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
if tournament.hasEnded() == false { |
|
|
|
|
if tournament.currentCanceled == false { |
|
|
|
|
RowButtonView("Annuler le tournoi", role: .destructive) { |
|
|
|
|
tournament.setCanceled(true) |
|
|
|
|
self._save() |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
RowButtonView("Reprendre le tournoi", role: .destructive) { |
|
|
|
|
tournament.setCanceled(false) |
|
|
|
|
self._save() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
RowButtonView("Supprimer le tournoi", role: .destructive) { |
|
|
|
|
tournament.endDate = Date() |
|
|
|
|
tournament.isDeleted.toggle() |
|
|
|
|
tournament.navigationPath.removeAll() |
|
|
|
|
navigation.path = NavigationPath() |
|
|
|
|
} |
|
|
|
|
} footer: { |
|
|
|
|
Text("todo: expliquer ce que ca fait") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if tournament.hasEnded() == false && tournament.isCanceled == false { |
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Annuler le tournoi", role: .destructive) { |
|
|
|
|
tournament.isCanceled.toggle() |
|
|
|
|
dismiss() |
|
|
|
|
} |
|
|
|
|
} footer: { |
|
|
|
|
Text("todo: expliquer ce que ca fait") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
Toggle(isOn: $tournament.isPrivate) { |
|
|
|
|
Text("Tournoi privée") |
|
|
|
|
@ -49,7 +67,10 @@ struct TournamentStatusView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.toolbarBackground(.visible, for: .navigationBar) |
|
|
|
|
.onChange(of: [tournament.isDeleted, tournament.isPrivate]) { |
|
|
|
|
.onChange(of: tournament.endDate) { |
|
|
|
|
_save() |
|
|
|
|
} |
|
|
|
|
.onChange(of: [tournament.isDeleted, tournament.isCanceled, tournament.isPrivate]) { |
|
|
|
|
_save() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|