From 04499515d7f6a115e21dddf53d0847620ccd7b3c Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Mon, 1 Jul 2024 18:56:36 +0200 Subject: [PATCH] fix stuff --- PadelClub/Data/Round.swift | 4 +-- PadelClub/Views/Round/RoundSettingsView.swift | 3 +- .../Screen/TournamentRankView.swift | 13 ++++---- .../Tournament/TournamentBuildView.swift | 30 +++++++++++++++++-- .../Tournament/TournamentRunningView.swift | 4 +-- 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/PadelClub/Data/Round.swift b/PadelClub/Data/Round.swift index 6d402c9..dab7d85 100644 --- a/PadelClub/Data/Round.swift +++ b/PadelClub/Data/Round.swift @@ -179,7 +179,7 @@ defer { return previousMatch.teams().first } } else if let parent = upperBracketTopMatch(ofMatchIndex: match.index, previousRound: previousRound)?.losingTeamId { - return Store.main.findById(parent) + return tournamentStore.findById(parent) } case .two: if let luckyLoser = match.teamScores.first(where: { $0.luckyLoser == match.index * 2 + 1 }) { @@ -191,7 +191,7 @@ defer { return previousMatch.teams().first } } else if let parent = upperBracketBottomMatch(ofMatchIndex: match.index, previousRound: previousRound)?.losingTeamId { - return Store.main.findById(parent) + return tournamentStore.findById(parent) } } diff --git a/PadelClub/Views/Round/RoundSettingsView.swift b/PadelClub/Views/Round/RoundSettingsView.swift index ed6246f..2a66a14 100644 --- a/PadelClub/Views/Round/RoundSettingsView.swift +++ b/PadelClub/Views/Round/RoundSettingsView.swift @@ -100,8 +100,7 @@ struct RoundSettingsView: View { var currentIndex = 0 let matches = (0.. 1 { - Button { + FooterButtonView("monter") { key -= 1 team.finalRanking = key + team.pointsEarned = tournament.isAnimation() ? nil : tournament.tournamentLevel.points(for: key - 1, count: tournament.teamCount) do { try self.tournament.tournamentStore.teamRegistrations.addOrUpdate(instance: team) } catch { Logger.error(error) } - } label: { - Label("descendre", systemImage: "chevron.compact.up").labelStyle(.iconOnly) } - .buttonStyle(.bordered) } } @@ -259,18 +257,17 @@ struct TournamentRankView: View { .buttonStyle(.plain) if editMode?.wrappedValue.isEditing == true { - Button { + FooterButtonView("descendre") { key += 1 team.finalRanking = key + team.pointsEarned = tournament.isAnimation() ? nil : tournament.tournamentLevel.points(for: key - 1, count: tournament.teamCount) + do { try self.tournament.tournamentStore.teamRegistrations.addOrUpdate(instance: team) } catch { Logger.error(error) } - } label: { - Label("descendre", systemImage: "chevron.compact.down").labelStyle(.iconOnly) } - .buttonStyle(.bordered) } } .alert("Position", isPresented: $isEditingTeam) { diff --git a/PadelClub/Views/Tournament/TournamentBuildView.swift b/PadelClub/Views/Tournament/TournamentBuildView.swift index 1353b44..7fd9163 100644 --- a/PadelClub/Views/Tournament/TournamentBuildView.swift +++ b/PadelClub/Views/Tournament/TournamentBuildView.swift @@ -91,12 +91,38 @@ struct TournamentBuildView: View { Section { #if DEBUG NavigationLink(value: Screen.rankings) { - Text("Classement final des équipes") + LabeledContent { + if tournament.publishRankings == false { + Image(systemName: "exclamationmark.circle.fill") + .foregroundStyle(.logoYellow) + } else { + Image(systemName: "checkmark") + .foregroundStyle(.green) + } + } label: { + Text("Classement final des équipes") + if tournament.publishRankings == false { + Text("Vérifiez le classement avant de publier").foregroundStyle(.red) + } + } } #else if tournament.hasEnded() { NavigationLink(value: Screen.rankings) { - Text("Classement final des équipes") + LabeledContent { + if tournament.publishRankings == false { + Image(systemName: "exclamationmark.circle.fill") + .foregroundStyle(.logoYellow) + } else { + Image(systemName: "checkmark") + .foregroundStyle(.green) + } + } label: { + Text("Classement final des équipes") + if tournament.publishRankings == false { + Text("Vérifiez le classement avant de publier").foregroundStyle(.red) + } + } } } #endif diff --git a/PadelClub/Views/Tournament/TournamentRunningView.swift b/PadelClub/Views/Tournament/TournamentRunningView.swift index 4cb25cc..4763306 100644 --- a/PadelClub/Views/Tournament/TournamentRunningView.swift +++ b/PadelClub/Views/Tournament/TournamentRunningView.swift @@ -18,10 +18,10 @@ struct TournamentRunningView: View { @ViewBuilder var body: some View { - MatchListView(section: "en cours", matches: tournament.runningMatches(allMatches)) + MatchListView(section: "en cours", matches: tournament.runningMatches(allMatches), hideWhenEmpty: tournament.hasEnded()) // MatchListView(section: "à lancer", matches: tournament.readyMatches(allMatches), isExpanded: false) // MatchListView(section: "disponible", matches: tournament.availableToStart(allMatches), isExpanded: false) - MatchListView(section: "terminés", matches: tournament.finishedMatches(allMatches), isExpanded: false) + MatchListView(section: "terminés", matches: tournament.finishedMatches(allMatches), isExpanded: tournament.hasEnded()) } }