|
|
|
|
@ -43,13 +43,16 @@ struct PlanningByCourtView: View { |
|
|
|
|
_selectedDay = State(wrappedValue: startDate) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
var body: some View { |
|
|
|
|
let noStartDate = matches.allSatisfy({ $0.startDate == nil }) |
|
|
|
|
|
|
|
|
|
List { |
|
|
|
|
_byCourtView() |
|
|
|
|
_byCourtView(noStartDate: noStartDate) |
|
|
|
|
.id(selectedCourt) |
|
|
|
|
} |
|
|
|
|
.overlay { |
|
|
|
|
if matches.allSatisfy({ $0.startDate == nil }) { |
|
|
|
|
if noStartDate { |
|
|
|
|
ContentUnavailableView { |
|
|
|
|
Label("Aucun horaire défini", systemImage: "clock.badge.questionmark") |
|
|
|
|
} description: { |
|
|
|
|
@ -59,13 +62,6 @@ struct PlanningByCourtView: View { |
|
|
|
|
selectedScheduleDestination = nil |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if courtSlots.isEmpty == false { |
|
|
|
|
ContentUnavailableView { |
|
|
|
|
Label("Aucun match plannifié", systemImage: "clock.badge.questionmark") |
|
|
|
|
} description: { |
|
|
|
|
Text("Aucun match n'a été plannifié sur ce terrain et au jour sélectionné") |
|
|
|
|
} actions: { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.navigationTitle(Text(selectedDay.formatted(.dateTime.day().weekday().month()))) |
|
|
|
|
@ -87,7 +83,7 @@ struct PlanningByCourtView: View { |
|
|
|
|
Picker(selection: $selectedCourt) { |
|
|
|
|
ForEach(courts, id: \.self) { courtIndex in |
|
|
|
|
if courtIndex == Int.max { |
|
|
|
|
Image(systemName: "rectangle.slash").tag(Int.max) |
|
|
|
|
Label("Sans terrain", systemImage: "rectangle.slash").tag(Int.max) |
|
|
|
|
} else { |
|
|
|
|
Text(tournament.courtName(atIndex: courtIndex)).tag(courtIndex) |
|
|
|
|
} |
|
|
|
|
@ -102,9 +98,10 @@ struct PlanningByCourtView: View { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
func _byCourtView() -> some View { |
|
|
|
|
func _byCourtView(noStartDate: Bool) -> some View { |
|
|
|
|
if let _matches = courtSlots[selectedCourt]?.filter({ $0.startDate?.dayInt == selectedDay.dayInt }) { |
|
|
|
|
let _sortedMatches = _matches.sorted(by: \.computedStartDateForSorting) |
|
|
|
|
if _sortedMatches.isEmpty == false { |
|
|
|
|
ForEach(_sortedMatches.indices, id: \.self) { index in |
|
|
|
|
let match = _sortedMatches[index] |
|
|
|
|
Section { |
|
|
|
|
@ -126,6 +123,21 @@ struct PlanningByCourtView: View { |
|
|
|
|
} |
|
|
|
|
.headerProminence(.increased) |
|
|
|
|
} |
|
|
|
|
} else if noStartDate == false { |
|
|
|
|
ContentUnavailableView { |
|
|
|
|
Label("Aucun match plannifié", systemImage: "clock.badge.questionmark") |
|
|
|
|
} description: { |
|
|
|
|
Text("Aucun match n'a été plannifié sur ce terrain et au jour sélectionné") |
|
|
|
|
} actions: { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if noStartDate == false { |
|
|
|
|
ContentUnavailableView { |
|
|
|
|
Label("Aucun match plannifié", systemImage: "clock.badge.questionmark") |
|
|
|
|
} description: { |
|
|
|
|
Text("Aucun match n'a été plannifié sur ce terrain et au jour sélectionné") |
|
|
|
|
} actions: { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|