|
|
|
@ -16,6 +16,15 @@ class OngoingViewModel { |
|
|
|
var destination: OngoingDestination? = .running |
|
|
|
var destination: OngoingDestination? = .running |
|
|
|
var hideUnconfirmedMatches: Bool = false |
|
|
|
var hideUnconfirmedMatches: Bool = false |
|
|
|
var hideNotReadyMatches: Bool = false |
|
|
|
var hideNotReadyMatches: Bool = false |
|
|
|
|
|
|
|
var selectedTournaments: Set<String> = Set() { |
|
|
|
|
|
|
|
didSet { |
|
|
|
|
|
|
|
DataStore.shared.resetOngoingCache() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func tournaments() -> [Tournament] { |
|
|
|
|
|
|
|
Set(DataStore.shared.runningAndNextMatches().compactMap({ $0.currentTournament() })).sorted(by: \.startDate) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func areFiltersEnabled() -> Bool { |
|
|
|
func areFiltersEnabled() -> Bool { |
|
|
|
hideUnconfirmedMatches || hideNotReadyMatches |
|
|
|
hideUnconfirmedMatches || hideNotReadyMatches |
|
|
|
@ -24,7 +33,7 @@ class OngoingViewModel { |
|
|
|
let defaultSorting : [MySortDescriptor<Match>] = [.keyPath(\Match.startDate!), .keyPath(\Match.index), .keyPath(\Match.courtIndexForSorting)] |
|
|
|
let defaultSorting : [MySortDescriptor<Match>] = [.keyPath(\Match.startDate!), .keyPath(\Match.index), .keyPath(\Match.courtIndexForSorting)] |
|
|
|
|
|
|
|
|
|
|
|
var runningAndNextMatches: [Match] { |
|
|
|
var runningAndNextMatches: [Match] { |
|
|
|
DataStore.shared.runningAndNextMatches().sorted(using: defaultSorting, order: .ascending) |
|
|
|
DataStore.shared.runningAndNextMatches(selectedTournaments).sorted(using: defaultSorting, order: .ascending) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var filteredRunningAndNextMatches: [Match] { |
|
|
|
var filteredRunningAndNextMatches: [Match] { |
|
|
|
@ -57,32 +66,33 @@ struct OngoingContainerView: View { |
|
|
|
.toolbarBackground(.visible, for: .navigationBar) |
|
|
|
.toolbarBackground(.visible, for: .navigationBar) |
|
|
|
.navigationTitle("Programmation") |
|
|
|
.navigationTitle("Programmation") |
|
|
|
.toolbar { |
|
|
|
.toolbar { |
|
|
|
if ongoingViewModel.destination == .followUp { |
|
|
|
ToolbarItem(placement: .topBarLeading) { |
|
|
|
ToolbarItem(placement: .topBarLeading) { |
|
|
|
Menu { |
|
|
|
Menu { |
|
|
|
NavigationLink { |
|
|
|
|
|
|
|
List(selection: $ongoingViewModel.selectedTournaments) { |
|
|
|
|
|
|
|
ForEach(ongoingViewModel.tournaments()) { tournament in |
|
|
|
|
|
|
|
TournamentCellView(tournament: tournament) |
|
|
|
|
|
|
|
.tag(tournament.id) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.environment(\.editMode, Binding.constant(EditMode.active)) |
|
|
|
|
|
|
|
.navigationTitle("Tournois visibles") |
|
|
|
|
|
|
|
.navigationBarTitleDisplayMode(.inline) |
|
|
|
|
|
|
|
.toolbarBackground(.visible, for: .navigationBar) |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
Label("Tournois visibles", systemImage: "circle.grid.2x2.topleft.checkmark.filled") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ongoingViewModel.destination == .followUp { |
|
|
|
|
|
|
|
Divider() |
|
|
|
Toggle(isOn: $ongoingViewModel.hideUnconfirmedMatches) { |
|
|
|
Toggle(isOn: $ongoingViewModel.hideUnconfirmedMatches) { |
|
|
|
Text("masquer non confirmés") |
|
|
|
Text("masquer non confirmés") |
|
|
|
} |
|
|
|
} |
|
|
|
Toggle(isOn: $ongoingViewModel.hideNotReadyMatches) { |
|
|
|
Toggle(isOn: $ongoingViewModel.hideNotReadyMatches) { |
|
|
|
Text("masquer incomplets") |
|
|
|
Text("masquer incomplets") |
|
|
|
} |
|
|
|
} |
|
|
|
} label: { |
|
|
|
|
|
|
|
Image(systemName: "line.3.horizontal.decrease.circle") |
|
|
|
|
|
|
|
.resizable() |
|
|
|
|
|
|
|
.scaledToFit() |
|
|
|
|
|
|
|
.frame(minHeight: 32) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
.symbolVariant(ongoingViewModel.areFiltersEnabled() ? .fill : .none) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ToolbarItem(placement: .topBarTrailing) { |
|
|
|
|
|
|
|
Button { |
|
|
|
|
|
|
|
showMatchPicker = true |
|
|
|
|
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
Image(systemName: "rectangle.stack.badge.plus") |
|
|
|
Image(systemName: "line.3.horizontal.decrease") |
|
|
|
.resizable() |
|
|
|
|
|
|
|
.scaledToFit() |
|
|
|
|
|
|
|
.frame(minHeight: 32) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|