diff --git a/PadelClub/Data/GroupStage.swift b/PadelClub/Data/GroupStage.swift index b8093f2..4738c2c 100644 --- a/PadelClub/Data/GroupStage.swift +++ b/PadelClub/Data/GroupStage.swift @@ -304,7 +304,7 @@ final class GroupStage: ModelObject, Storable { print("func group stage availableToStart", id, duration.formatted(.units(allowed: [.seconds, .milliseconds]))) } #endif - return playedMatches.filter({ $0.isRunning() == false && $0.canBeStarted(inMatches: runningMatches, checkCanPlay: checkCanPlay) }) + return playedMatches.filter({ $0.isRunning() == false && $0.canBeStarted(inMatches: runningMatches, checkCanPlay: checkCanPlay) }).sorted(by: \.computedStartDateForSorting) } func runningMatches(playedMatches: [Match]) -> [Match] { diff --git a/PadelClub/Views/GroupStage/GroupStageView.swift b/PadelClub/Views/GroupStage/GroupStageView.swift index dd5007a..9fc489f 100644 --- a/PadelClub/Views/GroupStage/GroupStageView.swift +++ b/PadelClub/Views/GroupStage/GroupStageView.swift @@ -58,12 +58,24 @@ struct GroupStageView: View { } let runningMatches = groupStage.runningMatches(playedMatches: playedMatches) - MatchListView(section: "en cours", matches: groupStage.runningMatches(playedMatches: playedMatches), hideWhenEmpty: true) + Section { + MatchListView(section: "en cours", matches: groupStage.runningMatches(playedMatches: playedMatches), hideWhenEmpty: true) + } + let availableToStart = groupStage.availableToStart(playedMatches: playedMatches, in: runningMatches) - MatchListView(section: "prêt à démarrer", matches: availableToStart, hideWhenEmpty: true) - .listRowView(isActive: availableToStart.isEmpty == false, color: .green, hideColorVariation: true) - MatchListView(section: "à lancer", matches: groupStage.readyMatches(playedMatches: playedMatches), hideWhenEmpty: true) - MatchListView(section: "terminés", matches: groupStage.finishedMatches(playedMatches: playedMatches), hideWhenEmpty: playedMatches.isEmpty || playedMatches.flatMap({ $0.teamScores }).isEmpty, isExpanded: false) + Section { + MatchListView(section: "prêt à démarrer", matches: availableToStart, hideWhenEmpty: true) + .listRowView(isActive: availableToStart.isEmpty == false, color: .green, hideColorVariation: true) + } + Section { + + MatchListView(section: "à lancer", matches: groupStage.readyMatches(playedMatches: playedMatches), hideWhenEmpty: true) + } + + Section { + + MatchListView(section: "terminés", matches: groupStage.finishedMatches(playedMatches: playedMatches), hideWhenEmpty: playedMatches.isEmpty || playedMatches.flatMap({ $0.teamScores }).isEmpty, isExpanded: false) + } if playedMatches.isEmpty { RowButtonView("Créer les matchs de poules") { diff --git a/PadelClub/Views/GroupStage/GroupStagesView.swift b/PadelClub/Views/GroupStage/GroupStagesView.swift index ebc9e2a..f3e2a58 100644 --- a/PadelClub/Views/GroupStage/GroupStagesView.swift +++ b/PadelClub/Views/GroupStage/GroupStagesView.swift @@ -131,12 +131,7 @@ struct GroupStagesView: View { } } } label: { - Label { - Text("Qualifier un \(name) de poule par tirage au sort") - } icon: { - Image(systemName: "exclamationmark.circle.fill") - .foregroundStyle(.logoBackground) - } + Text("Qualifier un \(name) de poule par tirage au sort") } .disabled(tournament.moreQualifiedToDraw() == 0 || missingQualifiedFromGroupStages.isEmpty) } footer: { @@ -149,10 +144,24 @@ struct GroupStagesView: View { } let runningMatches = Tournament.runningMatches(allMatches) - MatchListView(section: "en cours", matches: runningMatches, matchViewStyle: .standardStyle, isExpanded: false) - MatchListView(section: "prêt à démarrer", matches: Tournament.availableToStart(allMatches, in: runningMatches), matchViewStyle: .standardStyle, isExpanded: false) - MatchListView(section: "à lancer", matches: Tournament.readyMatches(allMatches), matchViewStyle: .standardStyle, isExpanded: false) - MatchListView(section: "terminés", matches: finishedMatches, matchViewStyle: .standardStyle, isExpanded: false) + Section { + + MatchListView(section: "en cours", matches: runningMatches, matchViewStyle: .standardStyle, isExpanded: false) + } + Section { + + MatchListView(section: "prêt à démarrer", matches: Tournament.availableToStart(allMatches, in: runningMatches), matchViewStyle: .standardStyle, isExpanded: false) + } + + Section { + + MatchListView(section: "à lancer", matches: Tournament.readyMatches(allMatches), matchViewStyle: .standardStyle, isExpanded: false) + } + + Section { + + MatchListView(section: "terminés", matches: finishedMatches, matchViewStyle: .standardStyle, isExpanded: false) + } } .navigationTitle("Toutes les poules") case .groupStage(let groupStage): diff --git a/PadelClub/Views/Match/MatchSummaryView.swift b/PadelClub/Views/Match/MatchSummaryView.swift index 199fa43..3f63c16 100644 --- a/PadelClub/Views/Match/MatchSummaryView.swift +++ b/PadelClub/Views/Match/MatchSummaryView.swift @@ -60,21 +60,21 @@ struct MatchSummaryView: View { } Spacer() VStack(alignment: .trailing, spacing: 0) { - if let courtName, match.canBePlayedInSpecifiedCourt() { - if match.isRunning() == false { + if match.hasEnded() == false, match.isRunning() == false { + if let courtName, match.canBePlayedInSpecifiedCourt() { Text("prévu") - } - Text(courtName) - } else if let first = match.availableCourts().first { - Text("possible") - Text(match.courtName(for: first)) - } else { - if let estimatedStartDate = match.estimatedStartDate() { + Text(courtName) + } else if let first = match.availableCourts().first { + Text("possible") + Text(match.courtName(for: first)) + } else if let estimatedStartDate = match.estimatedStartDate() { Text(match.courtName(for: estimatedStartDate.0) + " possible") Text("dans ~ " + estimatedStartDate.1.timeElapsedString()) } else { Text("aucun terrain disponible") } + } else if let courtName { + Text(courtName) } } .foregroundStyle(.secondary)