From af1ea610b4766d04e54c3e0043f34cf5b0b2b0dd Mon Sep 17 00:00:00 2001 From: Raz Date: Mon, 28 Oct 2024 11:47:50 +0100 Subject: [PATCH] minor fixes --- PadelClub.xcodeproj/project.pbxproj | 8 ++++---- PadelClub/Data/GroupStage.swift | 4 ++-- PadelClub/Data/Tournament.swift | 3 ++- .../Extensions/FixedWidthInteger+Extensions.swift | 10 +++++++++- PadelClub/Utils/PadelRule.swift | 9 +++++++-- .../GroupStage/Components/GroupStageSettingsView.swift | 8 ++++++++ PadelClub/Views/GroupStage/GroupStageView.swift | 2 -- PadelClub/Views/Shared/MatchFormatRowView.swift | 5 +++-- PadelClub/Views/Shared/MatchTypeSelectionView.swift | 3 ++- 9 files changed, 37 insertions(+), 15 deletions(-) diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 10ac1be..4c90f36 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3383,7 +3383,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -3406,7 +3406,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.24; + MARKETING_VERSION = 1.0.25; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -3427,7 +3427,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; @@ -3449,7 +3449,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.24; + MARKETING_VERSION = 1.0.25; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/PadelClub/Data/GroupStage.swift b/PadelClub/Data/GroupStage.swift index da476cb..e89d98a 100644 --- a/PadelClub/Data/GroupStage.swift +++ b/PadelClub/Data/GroupStage.swift @@ -221,8 +221,8 @@ final class GroupStage: ModelObject, Storable { func scoreLabel(forGroupStagePosition groupStagePosition: Int, score: TeamGroupStageScore? = nil) -> (wins: String, losses: String, setsDifference: String?, gamesDifference: String?)? { if let scoreData = (score ?? _score(forGroupStagePosition: groupStagePosition, nilIfEmpty: true)) { let hideSetDifference = matchFormat.setsToWin == 1 - let setDifference = scoreData.setDifference.formatted(.number.sign(strategy: .always(includingZero: false))) - let gameDifference = scoreData.gameDifference.formatted(.number.sign(strategy: .always(includingZero: false))) + let setDifference = scoreData.setDifference.formatted(.number.sign(strategy: .always(includingZero: true))) + " set" + scoreData.setDifference.pluralSuffix + let gameDifference = scoreData.gameDifference.formatted(.number.sign(strategy: .always(includingZero: true))) + " jeu" + scoreData.gameDifference.localizedPluralSuffix("x") return (wins: scoreData.wins.formatted(), losses: scoreData.loses.formatted(), setsDifference: hideSetDifference ? nil : setDifference, gamesDifference: gameDifference) // return "\(scoreData.wins)/\(scoreData.loses) " + differenceAsString } else { diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 512ba1a..8334da2 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -152,17 +152,18 @@ final class Tournament : ModelObject, Storable { self.publishBrackets = true self.publishGroupStages = true self.publishRankings = true + self.publishTournament = true #else self.publishTeams = publishTeams self.publishSummons = publishSummons self.publishBrackets = publishBrackets self.publishGroupStages = publishGroupStages self.publishRankings = publishRankings + self.publishTournament = publishTournament #endif self.shouldVerifyBracket = shouldVerifyBracket self.shouldVerifyGroupStage = shouldVerifyGroupStage self.hideTeamsWeight = hideTeamsWeight - self.publishTournament = publishTournament self.hidePointsEarned = hidePointsEarned self.loserBracketMode = loserBracketMode self.initialSeedRound = initialSeedRound diff --git a/PadelClub/Extensions/FixedWidthInteger+Extensions.swift b/PadelClub/Extensions/FixedWidthInteger+Extensions.swift index f9c0d6d..c40c74a 100644 --- a/PadelClub/Extensions/FixedWidthInteger+Extensions.swift +++ b/PadelClub/Extensions/FixedWidthInteger+Extensions.swift @@ -19,8 +19,16 @@ public extension FixedWidthInteger { return self.formatted() + self.ordinalFormattedSuffix(feminine: feminine) } + private var isMany: Bool { + self > 1 || self < -1 + } + var pluralSuffix: String { - return self > 1 ? "s" : "" + return isMany ? "s" : "" + } + + func localizedPluralSuffix(_ plural: String = "s") -> String { + return isMany ? plural : "" } func formattedAsRawString() -> String { diff --git a/PadelClub/Utils/PadelRule.swift b/PadelClub/Utils/PadelRule.swift index 404899b..81bb541 100644 --- a/PadelClub/Utils/PadelRule.swift +++ b/PadelClub/Utils/PadelRule.swift @@ -1349,8 +1349,13 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { return setFormat } - func formatTitle() -> String { - ["Format ", shortFormat, suffix].joined() + func formatTitle(_ displayStyle: DisplayStyle = .wide) -> String { + switch displayStyle { + case .short: + return ["Format ", shortFormat].joined() + default: + return ["Format ", shortFormat, suffix].joined() + } } var suffix: String { diff --git a/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift b/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift index 5bfa715..6dcd8f9 100644 --- a/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift +++ b/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift @@ -181,6 +181,10 @@ struct GroupStageSettingsView: View { presentConfirmationButton = true } } + .onChange(of: groupStage.matchFormat) { + _save() + groupStage.updateAllMatchesFormat() + } .navigationBarBackButtonHidden(focusedField != nil) .toolbar(content: { if focusedField != nil { @@ -190,6 +194,10 @@ struct GroupStageSettingsView: View { } } } + + ToolbarItem(placement: .topBarTrailing) { + MatchTypeSelectionView(selectedFormat: $groupStage.matchFormat, additionalEstimationDuration: tournament.additionalEstimationDuration, displayStyle: .short) + } }) .navigationTitle("Paramètres") .toolbarBackground(.visible, for: .navigationBar) diff --git a/PadelClub/Views/GroupStage/GroupStageView.swift b/PadelClub/Views/GroupStage/GroupStageView.swift index 63abc49..dd5007a 100644 --- a/PadelClub/Views/GroupStage/GroupStageView.swift +++ b/PadelClub/Views/GroupStage/GroupStageView.swift @@ -165,13 +165,11 @@ struct GroupStageView: View { if let setsDifference = score.setsDifference { HStack(spacing: 4.0) { Text(setsDifference) - Text("sets") }.font(.footnote) } if let gamesDifference = score.gamesDifference { HStack(spacing: 4.0) { Text(gamesDifference) - Text("jeux") }.font(.footnote) } } diff --git a/PadelClub/Views/Shared/MatchFormatRowView.swift b/PadelClub/Views/Shared/MatchFormatRowView.swift index 8698ea4..c03a13b 100644 --- a/PadelClub/Views/Shared/MatchFormatRowView.swift +++ b/PadelClub/Views/Shared/MatchFormatRowView.swift @@ -13,6 +13,7 @@ struct MatchFormatRowView: View { var hideExplanation: Bool = false var hideDuration: Bool = false var additionalEstimationDuration: Int? + var displayStyle: DisplayStyle = .wide var body: some View { VStack(alignment: .leading) { @@ -26,8 +27,8 @@ struct MatchFormatRowView: View { } } HStack { - Text(matchFormat.formatTitle()) - if hideDuration == false { + Text(matchFormat.formatTitle(displayStyle)) + if hideDuration == false && displayStyle != .short { Spacer() Text("~" + matchFormat.formattedEstimatedDuration(additionalEstimationDuration ?? 0)) } diff --git a/PadelClub/Views/Shared/MatchTypeSelectionView.swift b/PadelClub/Views/Shared/MatchTypeSelectionView.swift index 54bc81c..2801067 100644 --- a/PadelClub/Views/Shared/MatchTypeSelectionView.swift +++ b/PadelClub/Views/Shared/MatchTypeSelectionView.swift @@ -11,6 +11,7 @@ struct MatchTypeSelectionView: View { @Binding var selectedFormat: MatchFormat var format: String? var additionalEstimationDuration: Int? + var displayStyle: DisplayStyle = .wide var body: some View { NavigationLink { @@ -18,7 +19,7 @@ struct MatchTypeSelectionView: View { .navigationTitle("Choix du format") .toolbarBackground(.visible, for: .navigationBar) } label: { - MatchFormatRowView(matchFormat: selectedFormat, headerLabel: format, hideExplanation: true, additionalEstimationDuration: additionalEstimationDuration) + MatchFormatRowView(matchFormat: selectedFormat, headerLabel: format, hideExplanation: true, additionalEstimationDuration: additionalEstimationDuration, displayStyle: displayStyle) } } }