From ea0159e3df47ff7c9f90e81709dfb15e493b0c10 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Wed, 26 Jun 2024 09:34:34 +0200 Subject: [PATCH] fix text stuff --- PadelClub.xcodeproj/project.pbxproj | 4 +- PadelClub/Data/Round.swift | 4 +- PadelClub/Data/Tournament.swift | 38 +++++---- PadelClub/Utils/PadelRule.swift | 2 +- .../Views/Calling/CallSettingsView.swift | 2 +- PadelClub/Views/Planning/SchedulerView.swift | 40 +++++---- .../Screen/TournamentScheduleView.swift | 2 +- .../Tournament/TournamentBuildView.swift | 82 +++++++++---------- .../Views/Tournament/TournamentInitView.swift | 10 ++- 9 files changed, 99 insertions(+), 85 deletions(-) diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index efdee37..500ba92 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -1878,7 +1878,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 69; + CURRENT_PROJECT_VERSION = 71; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -1918,7 +1918,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 69; + CURRENT_PROJECT_VERSION = 71; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/Data/Round.swift b/PadelClub/Data/Round.swift index 881f649..60a137f 100644 --- a/PadelClub/Data/Round.swift +++ b/PadelClub/Data/Round.swift @@ -36,7 +36,7 @@ class Round: ModelObject, Storable { } func _matches() -> [Match] { - return DataStore.shared.matches.filter { $0.round == self.id } + return DataStore.shared.matches.filter { $0.round == self.id }.sorted(by: \.index) } func getDisabledMatches() -> [Match] { @@ -249,7 +249,7 @@ defer { } func enabledMatches() -> [Match] { - return DataStore.shared.matches.filter { $0.round == self.id && $0.disabled == false } + return DataStore.shared.matches.filter { $0.round == self.id && $0.disabled == false }.sorted(by: \.index) } func displayableMatches() -> [Match] { diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 5a0ea1d..eee8c5f 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -1394,20 +1394,28 @@ defer { return TournamentStatus(label: label, completion: completionLabel) } - func bracketStatus() async -> (status: String, cut: TeamRegistration.TeamRange?) { + func bracketStatus() async -> (status: String, description: String?, cut: TeamRegistration.TeamRange?) { let availableSeeds = availableSeeds() - let cut = TeamRegistration.TeamRange(availableSeeds.first, availableSeeds.last) + var description: String? = nil if availableSeeds.isEmpty == false { - return ("placer \(availableSeeds.count) tête\(availableSeeds.count.pluralSuffix) de série", cut) + description = "placer \(availableSeeds.count) équipe\(availableSeeds.count.pluralSuffix)" } - let availableQualifiedTeams = availableQualifiedTeams() - if availableQualifiedTeams.isEmpty == false { - return ("placer \(availableQualifiedTeams.count) qualifié" + availableQualifiedTeams.count.pluralSuffix, cut) + if description == nil { + let availableQualifiedTeams = availableQualifiedTeams() + if availableQualifiedTeams.isEmpty == false { + description = "placer \(availableQualifiedTeams.count) qualifié" + availableQualifiedTeams.count.pluralSuffix + } + } + + var cut: TeamRegistration.TeamRange? = nil + if description == nil && isAnimation() == false { + cut = TeamRegistration.TeamRange(availableSeeds.first, availableSeeds.last) } + if let round = getActiveRound() { - return ([round.roundTitle(.short), round.roundStatus()].joined(separator: " "), cut) + return ([round.roundTitle(.short), round.roundStatus()].joined(separator: " ").lowercased(), description, cut) } else { - return ("à construire", nil) + return ("", description, nil) } } @@ -1415,10 +1423,10 @@ defer { let groupStageTeams = groupStageTeams() let groupStageTeamsCount = groupStageTeams.count if groupStageTeamsCount == 0 || groupStageTeamsCount != groupStageSpots() { - return ("à faire", nil) + return ("à compléter", nil) } - let cut = TeamRegistration.TeamRange(groupStageTeams.first, groupStageTeams.last) + let cut : TeamRegistration.TeamRange? = isAnimation() ? nil : TeamRegistration.TeamRange(groupStageTeams.first, groupStageTeams.last) let runningGroupStages = groupStages().filter({ $0.isRunning() }) if groupStagesAreOver() { return ("terminées", cut) } @@ -1435,16 +1443,12 @@ defer { } func settingsDescriptionLocalizedLabel() -> String { - [dayDuration.formatted() + " jour\(dayDuration.pluralSuffix)", courtCount.formatted() + " terrain\(courtCount.pluralSuffix)"].joined(separator: ", ") + [courtCount.formatted() + " terrain\(courtCount.pluralSuffix)", entryFeeMessage].joined(separator: ", ") } func structureDescriptionLocalizedLabel() -> String { - if state() == .initial { - return "à valider" - } else { - let groupStageLabel: String? = groupStageCount > 0 ? groupStageCount.formatted() + " poule\(groupStageCount.pluralSuffix)" : nil - return [teamCount.formatted() + " équipes", groupStageLabel].compactMap({ $0 }).joined(separator: ", ") - } + let groupStageLabel: String? = groupStageCount > 0 ? groupStageCount.formatted() + " poule\(groupStageCount.pluralSuffix)" : nil + return [teamCount.formatted() + " équipes", groupStageLabel].compactMap({ $0 }).joined(separator: ", ") } func deleteAndBuildEverything() { diff --git a/PadelClub/Utils/PadelRule.swift b/PadelClub/Utils/PadelRule.swift index e14f1fd..2a6afa8 100644 --- a/PadelClub/Utils/PadelRule.swift +++ b/PadelClub/Utils/PadelRule.swift @@ -342,7 +342,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { return .twoSetsDecisivePointSuperTie } default: - return .twoSetsDecisivePoint + return .superTie } } diff --git a/PadelClub/Views/Calling/CallSettingsView.swift b/PadelClub/Views/Calling/CallSettingsView.swift index 34bd12d..027945d 100644 --- a/PadelClub/Views/Calling/CallSettingsView.swift +++ b/PadelClub/Views/Calling/CallSettingsView.swift @@ -46,7 +46,7 @@ struct CallSettingsView: View { Logger.error(error) } } label: { - Text(.init("Le tournoi n'est pas visible sur [Padel Club](\(URLs.main.rawValue)), ")).foregroundStyle(.logoRed) + Text("le rendre visible ?").underline().foregroundStyle(.master) + Text(.init("Le tournoi est privée, le publier ?")).underline().foregroundStyle(.master) } } } diff --git a/PadelClub/Views/Planning/SchedulerView.swift b/PadelClub/Views/Planning/SchedulerView.swift index 924720d..4b9fcc6 100644 --- a/PadelClub/Views/Planning/SchedulerView.swift +++ b/PadelClub/Views/Planning/SchedulerView.swift @@ -50,13 +50,15 @@ struct SchedulerView: View { } } footer: { - if tournament.groupStageMatchFormat.weight > tournament.groupStageSmartMatchFormat().weight { - Button { - tournament.groupStageMatchFormat = tournament.groupStageSmartMatchFormat() - } label: { - Text("devrait être joué au moins en " + tournament.groupStageSmartMatchFormat().format + ", ") + Text("modifier ?").underline().foregroundStyle(.master) + if tournament.isAnimation() == false { + if tournament.groupStageMatchFormat.weight > tournament.groupStageSmartMatchFormat().weight { + Button { + tournament.groupStageMatchFormat = tournament.groupStageSmartMatchFormat() + } label: { + Text("devrait être joué au moins en " + tournament.groupStageSmartMatchFormat().format + ", ") + Text("modifier ?").underline().foregroundStyle(.master) + } + .buttonStyle(.plain) } - .buttonStyle(.plain) } } @@ -117,19 +119,21 @@ struct SchedulerView: View { } header: { Text(round.titleLabel()) } footer: { - let federalFormat = tournament.roundSmartMatchFormat(round.index) - if round.matchFormat.weight > federalFormat.weight { - Button { - round.updateMatchFormatAndAllMatches(federalFormat) - do { - try dataStore.rounds.addOrUpdate(instance: round) - } catch { - Logger.error(error) + if tournament.isAnimation() == false { + let federalFormat = tournament.roundSmartMatchFormat(round.index) + if round.matchFormat.weight > federalFormat.weight { + Button { + round.updateMatchFormatAndAllMatches(federalFormat) + do { + try dataStore.rounds.addOrUpdate(instance: round) + } catch { + Logger.error(error) + } + } label: { + Text("devrait être joué au moins en " + federalFormat.format + ", ") + Text("modifier ?").underline().foregroundStyle(.master) } - } label: { - Text("devrait être joué au moins en " + federalFormat.format + ", ") + Text("modifier ?").underline().foregroundStyle(.master) + .buttonStyle(.plain) } - .buttonStyle(.plain) } } @@ -160,7 +164,7 @@ struct SchedulerView: View { } header: { Text("Match de classement \(round.roundTitle(.short))") } footer: { - if round.index == 1, let semi = round.loserRounds().first { + if tournament.isAnimation() == false, round.index == 1, let semi = round.loserRounds().first { let federalFormat = tournament.loserBracketSmartMatchFormat(1) if semi.matchFormat.weight > federalFormat.weight { Button { diff --git a/PadelClub/Views/Tournament/Screen/TournamentScheduleView.swift b/PadelClub/Views/Tournament/Screen/TournamentScheduleView.swift index 9e4c965..bb7bb55 100644 --- a/PadelClub/Views/Tournament/Screen/TournamentScheduleView.swift +++ b/PadelClub/Views/Tournament/Screen/TournamentScheduleView.swift @@ -92,7 +92,7 @@ struct TournamentScheduleView: View { } .navigationBarTitleDisplayMode(.inline) .toolbarBackground(.visible, for: .navigationBar) - .navigationTitle("Horaires") + .navigationTitle("Horaires et formats") } } diff --git a/PadelClub/Views/Tournament/TournamentBuildView.swift b/PadelClub/Views/Tournament/TournamentBuildView.swift index 7f4954d..9852f12 100644 --- a/PadelClub/Views/Tournament/TournamentBuildView.swift +++ b/PadelClub/Views/Tournament/TournamentBuildView.swift @@ -9,7 +9,7 @@ import SwiftUI struct TournamentBuildView: View { var tournament: Tournament - @State private var bracketStatus: (status: String, cut: TeamRegistration.TeamRange?)? + @State private var bracketStatus: (status: String, description: String?, cut: TeamRegistration.TeamRange?)? @State private var groupStageStatus: (String, TeamRegistration.TeamRange?)? @State private var callStatus: Tournament.TournamentStatus? @State private var scheduleStatus: Tournament.TournamentStatus? @@ -65,7 +65,9 @@ struct TournamentBuildView: View { Text("Tableau") if tournament.shouldVerifyBracket { Text("Vérifier la tableau").foregroundStyle(.logoRed) - } else if let range = bracketStatus?.1 { + } else if let description = bracketStatus?.1 { + Text(description) + } else if let range = bracketStatus?.2 { HStack { if let left = range.left { Text(left.weight.formatted()) @@ -98,50 +100,48 @@ struct TournamentBuildView: View { TournamentBroadcastRowView(tournament: tournament) } - if state != .finished { - NavigationLink(value: Screen.schedule) { - let tournamentStatus = scheduleStatus - LabeledContent { - if let tournamentStatus { - Text(tournamentStatus.completion) - } else { - ProgressView() - } - } label: { - Text("Horaires") - if let tournamentStatus { - Text(tournamentStatus.label).lineLimit(1) - } else { - Text(" ") - } + NavigationLink(value: Screen.schedule) { + let tournamentStatus = scheduleStatus + LabeledContent { + if let tournamentStatus { + Text(tournamentStatus.completion) + } else { + ProgressView() } - } - .task { - scheduleStatus = await tournament.scheduleStatus() - } - - NavigationLink(value: Screen.call) { - let tournamentStatus = callStatus - LabeledContent { - if let tournamentStatus { - Text(tournamentStatus.completion) - } else { - ProgressView() - } - } label: { - Text("Convocations") - if let tournamentStatus { - Text(tournamentStatus.label).lineLimit(1) - } else { - Text(" ") - } + } label: { + Text("Horaires et formats") + if let tournamentStatus { + Text(tournamentStatus.label).lineLimit(1) + } else { + Text(" ") } } - .task { - callStatus = await tournament.callStatus() - } + } + .task { + scheduleStatus = await tournament.scheduleStatus() } + NavigationLink(value: Screen.call) { + let tournamentStatus = callStatus + LabeledContent { + if let tournamentStatus { + Text(tournamentStatus.completion) + } else { + ProgressView() + } + } label: { + Text("Convocations") + if let tournamentStatus { + Text(tournamentStatus.label).lineLimit(1) + } else { + Text(" ") + } + } + } + .task { + callStatus = await tournament.callStatus() + } + NavigationLink(value: Screen.cashier) { let tournamentStatus = cashierStatus LabeledContent { diff --git a/PadelClub/Views/Tournament/TournamentInitView.swift b/PadelClub/Views/Tournament/TournamentInitView.swift index 6bd6faf..f0de978 100644 --- a/PadelClub/Views/Tournament/TournamentInitView.swift +++ b/PadelClub/Views/Tournament/TournamentInitView.swift @@ -28,17 +28,23 @@ struct TournamentInitView: View { NavigationLink(value: Screen.structure) { LabeledContent { - Text(tournament.structureDescriptionLocalizedLabel()) + if tournament.state() == .initial { + Text("à valider") + } else { + Image(systemName: "checkmark").foregroundStyle(.green) + } } label: { LabelStructure() + Text(tournament.structureDescriptionLocalizedLabel()) } } NavigationLink(value: Screen.settings) { LabeledContent { - Text(tournament.settingsDescriptionLocalizedLabel()) + Text(tournament.tournamentTitle(.short)) } label: { LabelSettings() + Text("Formats, statut, club, prix, etc.") } }