paca_championship
Raz 1 year ago
parent a7af5c6b1c
commit 5d2a52dce7
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 2
      PadelClub/Data/Match.swift
  3. 2
      PadelClub/Views/Planning/PlanningByCourtView.swift
  4. 31
      PadelClub/Views/Planning/PlanningView.swift

@ -3399,7 +3399,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2; CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
@ -3441,7 +3441,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2; CURRENT_PROJECT_VERSION = 3;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6; DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -864,7 +864,7 @@ defer {
func hasStarted() -> Bool { // meaning at least one match is over func hasStarted() -> Bool { // meaning at least one match is over
if let startDate { if let startDate {
return startDate.timeIntervalSinceNow < 0 return startDate.timeIntervalSinceNow < 0 && confirmed
} }
if hasEnded() { if hasEnded() {
return true return true

@ -38,7 +38,7 @@ struct PlanningByCourtView: View {
} }
init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>, startDate: Date) { init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>, startDate: Date) {
self.matches = matches self.matches = matches.filter({ $0.endDate == nil })
_selectedScheduleDestination = selectedScheduleDestination _selectedScheduleDestination = selectedScheduleDestination
_selectedDay = State(wrappedValue: startDate) _selectedDay = State(wrappedValue: startDate)
} }

@ -11,9 +11,20 @@ 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)

Loading…
Cancel
Save