diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 40bb823..b5f19d5 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3399,7 +3399,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -3441,7 +3441,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/Data/Match.swift b/PadelClub/Data/Match.swift index f0584c6..9a92f61 100644 --- a/PadelClub/Data/Match.swift +++ b/PadelClub/Data/Match.swift @@ -864,7 +864,7 @@ defer { func hasStarted() -> Bool { // meaning at least one match is over if let startDate { - return startDate.timeIntervalSinceNow < 0 + return startDate.timeIntervalSinceNow < 0 && confirmed } if hasEnded() { return true diff --git a/PadelClub/Views/Planning/PlanningByCourtView.swift b/PadelClub/Views/Planning/PlanningByCourtView.swift index 9b0744a..2ed79c0 100644 --- a/PadelClub/Views/Planning/PlanningByCourtView.swift +++ b/PadelClub/Views/Planning/PlanningByCourtView.swift @@ -38,7 +38,7 @@ struct PlanningByCourtView: View { } init(matches: [Match], selectedScheduleDestination: Binding, startDate: Date) { - self.matches = matches + self.matches = matches.filter({ $0.endDate == nil }) _selectedScheduleDestination = selectedScheduleDestination _selectedDay = State(wrappedValue: startDate) } diff --git a/PadelClub/Views/Planning/PlanningView.swift b/PadelClub/Views/Planning/PlanningView.swift index a20841b..ab6131d 100644 --- a/PadelClub/Views/Planning/PlanningView.swift +++ b/PadelClub/Views/Planning/PlanningView.swift @@ -11,10 +11,21 @@ struct PlanningView: View { @EnvironmentObject var dataStore: DataStore @Environment(Tournament.self) var tournament: Tournament @State private var selectedDay: Date? - - let matches: [Match] @Binding var selectedScheduleDestination: ScheduleDestination? + @State private var filterOption: PlanningFilterOption = .byDefault + @State private var showFinishedMatches: Bool = false + + let allMatches: [Match] + + init(matches: [Match], selectedScheduleDestination: Binding) { + self.allMatches = matches + _selectedScheduleDestination = selectedScheduleDestination + } + var matches: [Match] { + allMatches.filter({ showFinishedMatches || $0.endDate == nil }) + } + var timeSlots: [Date:[Match]] { Dictionary(grouping: matches) { $0.startDate ?? .distantFuture } } @@ -27,8 +38,6 @@ struct PlanningView: View { timeSlots.keys.sorted() } - @State private var filterOption: PlanningFilterOption = .byDefault - enum PlanningFilterOption: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } @@ -45,11 +54,6 @@ struct PlanningView: View { } } - init(matches: [Match], selectedScheduleDestination: Binding) { - self.matches = matches - _selectedScheduleDestination = selectedScheduleDestination - } - private func _computedTitle() -> String { if let selectedDay { return selectedDay.formatted(.dateTime.day().weekday().month()) @@ -93,6 +97,15 @@ struct PlanningView: View { } .labelsHidden() .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("Filtrer", systemImage: "line.3.horizontal.decrease.circle") .symbolVariant(filterOption == .byCourt ? .fill : .none)