|
|
|
@ -13,9 +13,19 @@ struct PlanningView: View { |
|
|
|
|
|
|
|
|
|
|
|
let matches: [Match] |
|
|
|
let matches: [Match] |
|
|
|
@Binding var selectedScheduleDestination: ScheduleDestination? |
|
|
|
@Binding var selectedScheduleDestination: ScheduleDestination? |
|
|
|
@State private var timeSlots: [Date:[Match]] |
|
|
|
|
|
|
|
@State private var days: [Date] |
|
|
|
var timeSlots: [Date:[Match]] { |
|
|
|
@State private var keys: [Date] |
|
|
|
Dictionary(grouping: matches) { $0.startDate ?? .distantFuture } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var days: [Date] { |
|
|
|
|
|
|
|
Set(timeSlots.keys.map { $0.startOfDay }).sorted() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var keys: [Date] { |
|
|
|
|
|
|
|
timeSlots.keys.sorted() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@State private var filterOption: PlanningFilterOption = .byDefault |
|
|
|
@State private var filterOption: PlanningFilterOption = .byDefault |
|
|
|
|
|
|
|
|
|
|
|
enum PlanningFilterOption: Int, CaseIterable, Identifiable { |
|
|
|
enum PlanningFilterOption: Int, CaseIterable, Identifiable { |
|
|
|
@ -37,10 +47,6 @@ struct PlanningView: View { |
|
|
|
init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>) { |
|
|
|
init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>) { |
|
|
|
self.matches = matches |
|
|
|
self.matches = matches |
|
|
|
_selectedScheduleDestination = selectedScheduleDestination |
|
|
|
_selectedScheduleDestination = selectedScheduleDestination |
|
|
|
let timeSlots = Dictionary(grouping: matches) { $0.startDate ?? .distantFuture } |
|
|
|
|
|
|
|
_timeSlots = State(wrappedValue: timeSlots) |
|
|
|
|
|
|
|
_days = State(wrappedValue: Set(timeSlots.keys.map { $0.startOfDay }).sorted()) |
|
|
|
|
|
|
|
_keys = State(wrappedValue: timeSlots.keys.sorted()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
var body: some View { |
|
|
|
|