fix groupstage sorting

paca_championship
Raz 1 year ago
parent d6e87daa3d
commit 0e5988b4ed
  1. 2
      PadelClub/Data/GroupStage.swift
  2. 22
      PadelClub/Views/GroupStage/GroupStageView.swift
  3. 29
      PadelClub/Views/GroupStage/GroupStagesView.swift
  4. 18
      PadelClub/Views/Match/MatchSummaryView.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] {

@ -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") {

@ -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):

@ -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)

Loading…
Cancel
Save