|
|
|
@ -11,10 +11,21 @@ struct PlanningView: View { |
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
@Environment(Tournament.self) var tournament: Tournament |
|
|
|
@Environment(Tournament.self) var tournament: Tournament |
|
|
|
@State private var selectedDay: Date? |
|
|
|
@State private var selectedDay: Date? |
|
|
|
|
|
|
|
|
|
|
|
let matches: [Match] |
|
|
|
|
|
|
|
@Binding var selectedScheduleDestination: ScheduleDestination? |
|
|
|
@Binding var selectedScheduleDestination: ScheduleDestination? |
|
|
|
|
|
|
|
@State private var filterOption: PlanningFilterOption = .byDefault |
|
|
|
|
|
|
|
@State private var showFinishedMatches: Bool = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let allMatches: [Match] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>) { |
|
|
|
|
|
|
|
self.allMatches = matches |
|
|
|
|
|
|
|
_selectedScheduleDestination = selectedScheduleDestination |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var matches: [Match] { |
|
|
|
|
|
|
|
allMatches.filter({ showFinishedMatches || $0.endDate == nil }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var timeSlots: [Date:[Match]] { |
|
|
|
var timeSlots: [Date:[Match]] { |
|
|
|
Dictionary(grouping: matches) { $0.startDate ?? .distantFuture } |
|
|
|
Dictionary(grouping: matches) { $0.startDate ?? .distantFuture } |
|
|
|
} |
|
|
|
} |
|
|
|
@ -27,8 +38,6 @@ struct PlanningView: View { |
|
|
|
timeSlots.keys.sorted() |
|
|
|
timeSlots.keys.sorted() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@State private var filterOption: PlanningFilterOption = .byDefault |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum PlanningFilterOption: Int, CaseIterable, Identifiable { |
|
|
|
enum PlanningFilterOption: Int, CaseIterable, Identifiable { |
|
|
|
var id: Int { self.rawValue } |
|
|
|
var id: Int { self.rawValue } |
|
|
|
|
|
|
|
|
|
|
|
@ -45,11 +54,6 @@ struct PlanningView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>) { |
|
|
|
|
|
|
|
self.matches = matches |
|
|
|
|
|
|
|
_selectedScheduleDestination = selectedScheduleDestination |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func _computedTitle() -> String { |
|
|
|
private func _computedTitle() -> String { |
|
|
|
if let selectedDay { |
|
|
|
if let selectedDay { |
|
|
|
return selectedDay.formatted(.dateTime.day().weekday().month()) |
|
|
|
return selectedDay.formatted(.dateTime.day().weekday().month()) |
|
|
|
@ -93,6 +97,15 @@ struct PlanningView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
.labelsHidden() |
|
|
|
.labelsHidden() |
|
|
|
.pickerStyle(.inline) |
|
|
|
.pickerStyle(.inline) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
Label("Filtrer", systemImage: "line.3.horizontal.decrease.circle") |
|
|
|
Label("Filtrer", systemImage: "line.3.horizontal.decrease.circle") |
|
|
|
.symbolVariant(filterOption == .byCourt ? .fill : .none) |
|
|
|
.symbolVariant(filterOption == .byCourt ? .fill : .none) |
|
|
|
|