fix planning stuff

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

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

Loading…
Cancel
Save