From 276ec87bc7969263155b3892bcdebae6a84f8515 Mon Sep 17 00:00:00 2001 From: Raz Date: Sat, 5 Oct 2024 21:09:57 +0200 Subject: [PATCH] fix datepicker with label ios18 glitches fix refresh in planning view --- PadelClub/Views/Match/MatchDetailView.swift | 12 ++++-------- PadelClub/Views/Planning/PlanningView.swift | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/PadelClub/Views/Match/MatchDetailView.swift b/PadelClub/Views/Match/MatchDetailView.swift index 0e61b10..300a5fa 100644 --- a/PadelClub/Views/Match/MatchDetailView.swift +++ b/PadelClub/Views/Match/MatchDetailView.swift @@ -448,17 +448,13 @@ struct MatchDetailView: View { } if match.startDate != nil || startDateSetup == .customDate { - DatePicker(selection: $startDate) { - Label("Début", systemImage: "calendar").labelStyle(.titleOnly) - } - .datePickerStyle(.compact) + DatePicker("Début", selection: $startDate) + .datePickerStyle(.compact) } if match.endDate != nil { - DatePicker(selection: $endDate) { - Label("Fin", systemImage: "calendar").labelStyle(.titleOnly) - } - .datePickerStyle(.compact) + DatePicker("Fin", selection: $endDate) + .datePickerStyle(.compact) } diff --git a/PadelClub/Views/Planning/PlanningView.swift b/PadelClub/Views/Planning/PlanningView.swift index 903ec08..f2b0348 100644 --- a/PadelClub/Views/Planning/PlanningView.swift +++ b/PadelClub/Views/Planning/PlanningView.swift @@ -13,9 +13,19 @@ struct PlanningView: View { let matches: [Match] @Binding var selectedScheduleDestination: ScheduleDestination? - @State private var timeSlots: [Date:[Match]] - @State private var days: [Date] - @State private var keys: [Date] + + var timeSlots: [Date:[Match]] { + 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 enum PlanningFilterOption: Int, CaseIterable, Identifiable { @@ -37,10 +47,6 @@ struct PlanningView: View { init(matches: [Match], selectedScheduleDestination: Binding) { self.matches = matches _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 {