fix planning stuff

main
Razmig Sarkissian 3 weeks ago
parent 9fb5ed889e
commit aaeebd6d75
  1. 41
      PadelClub/Views/Planning/PlanningView.swift

@ -27,10 +27,14 @@ struct PlanningView: View {
init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>, event: Event? = nil) { init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>, event: Event? = nil) {
self.event = event self.event = event
if let event { if let event {
self.allMatches = event.confirmedTournaments().flatMap { $0.allMatches() } let allMatches = event.confirmedTournaments().flatMap { $0.allMatches() }
self.allMatches = allMatches
_showFinishedMatches = .init(wrappedValue: !allMatches.anySatisfy({ $0.hasEnded() == false && $0.plannedStartDate != nil }))
} else { } else {
self.allMatches = matches self.allMatches = matches
_showFinishedMatches = .init(wrappedValue: !matches.anySatisfy({ $0.hasEnded() == false && $0.plannedStartDate != nil }))
} }
_selectedScheduleDestination = selectedScheduleDestination _selectedScheduleDestination = selectedScheduleDestination
} }
@ -84,7 +88,7 @@ struct PlanningView: View {
let keys = self.keys(timeSlots: timeSlots) let keys = self.keys(timeSlots: timeSlots)
let days = self.days(timeSlots: timeSlots) let days = self.days(timeSlots: timeSlots)
let matches = matches let matches = matches
let notSlots = matches.allSatisfy({ $0.startDate == nil }) let notSlots = matches.allSatisfy({ $0.plannedStartDate == nil })
BySlotView( BySlotView(
days: days, keys: keys, timeSlots: timeSlots, matches: matches, selectedDay: selectedDay days: days, keys: keys, timeSlots: timeSlots, matches: matches, selectedDay: selectedDay
) )
@ -150,7 +154,7 @@ struct PlanningView: View {
Button { Button {
_planEvent(event: event) _planEvent(event: event)
} label: { } label: {
Text("Planifier") Text("Tout planifier")
} }
} label: { } label: {
Text("Planifier l'événement") Text("Planifier l'événement")
@ -168,18 +172,17 @@ struct PlanningView: View {
.popoverTip(timeSlotMoveOptionTip) .popoverTip(timeSlotMoveOptionTip)
.disabled(_confirmationMode()) .disabled(_confirmationMode())
Toggle(isOn: enableEditionBinding) { Toggle(isOn: enableEditionBinding) {
Text("Modifier un horaire") Label("Modifier un horaire", systemImage: "clock.arrow.trianglehead.2.counterclockwise.rotate.90")
} }
.disabled(_confirmationMode()) .disabled(_confirmationMode())
} }
Divider() Divider()
Menu {
Section { Section {
Picker(selection: $showFinishedMatches) { Picker(selection: $showFinishedMatches) {
Text("Afficher tous les matchs").tag(true) Label("Afficher tous les matchs", systemImage: "eye").tag(true)
Text("Masquer les matchs terminés").tag(false) Label("Masquer les matchs terminés", systemImage: "eye.slash").tag(false)
} label: { } label: {
Text("Option de filtrage") Text("Option de filtrage")
} }
@ -188,9 +191,9 @@ struct PlanningView: View {
} header: { } header: {
Text("Option de filtrage") Text("Option de filtrage")
} }
Divider() Divider()
Menu {
Section { Section {
Picker(selection: $filterOption) { Picker(selection: $filterOption) {
ForEach(PlanningFilterOption.allCases) { ForEach(PlanningFilterOption.allCases) {
@ -206,14 +209,14 @@ struct PlanningView: View {
} }
} label: { } label: {
Label("Trier", systemImage: "line.3.horizontal.decrease.circle") Label("Trier", systemImage: "line.3.horizontal.decrease")
.symbolVariant( .symbolVariant(
filterOption == .byCourt || showFinishedMatches ? .fill : .none) filterOption == .byCourt || showFinishedMatches ? .fill : .none)
} }
Divider() Divider()
Button("Mettre à jour", systemImage: "arrow.trianglehead.2.clockwise.rotate.90.circle") { Button("Mettre à jour", systemImage: "arrow.trianglehead.2.clockwise.rotate.90.icloud") {
let now = Date() let now = Date()
matches.forEach { matches.forEach {
if let startDate = $0.startDate, startDate > now { if let startDate = $0.startDate, startDate > now {
@ -238,7 +241,20 @@ struct PlanningView: View {
} }
}) })
.overlay { .overlay {
if notSlots { if notSlots, showFinishedMatches == false, self.allMatches.isEmpty == false {
ContentUnavailableView {
Label("Aucun match à jouer", systemImage: "clock.badge.checkmark")
} description: {
Text(
"Tous les matchs plannifiés sont terminés."
)
} actions: {
RowButtonView("Afficher tous les matchs") {
showFinishedMatches = true
}
}
} else if notSlots {
ContentUnavailableView { ContentUnavailableView {
Label("Aucun horaire défini", systemImage: "clock.badge.questionmark") Label("Aucun horaire défini", systemImage: "clock.badge.questionmark")
} description: { } description: {
@ -501,6 +517,7 @@ struct PlanningView: View {
} }
CourtOptionsView(timeSlots: timeSlots, underlined: true) CourtOptionsView(timeSlots: timeSlots, underlined: true)
.labelStyle(.titleOnly)
} }
} }
.onChange(of: selectAll, { oldValue, newValue in .onChange(of: selectAll, { oldValue, newValue in
@ -803,7 +820,7 @@ struct PlanningView: View {
_save() _save()
} }
} label: { } label: {
Text("Pistes") Label("Pistes", systemImage: "123.rectangle")
.underline(underlined) .underline(underlined)
} }

Loading…
Cancel
Save