diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 54cac3d..deb4f64 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -1396,10 +1396,10 @@ defer { if let name { return name } else { - return tournamentLevel.localizedLabel(.title) + return tournamentLevel.localizedLevelLabel(.title) } } - let title: String = [tournamentLevel.localizedLabel(displayStyle), tournamentCategory.localizedLabel(displayStyle), federalTournamentAge.localizedLabel(displayStyle)].joined(separator: " ") + let title: String = [tournamentLevel.localizedLevelLabel(displayStyle), tournamentCategory.localizedLabel(displayStyle), federalTournamentAge.localizedLabel(displayStyle)].filter({ $0.isEmpty == false }).joined(separator: " ") if displayStyle == .wide, let name { return [title, name].joined(separator: " - ") } else { @@ -1410,9 +1410,9 @@ defer { func localizedTournamentType() -> String { switch tournamentLevel { case .unlisted: - return tournamentLevel.localizedLabel(.short) + return tournamentLevel.localizedLevelLabel(.short) default: - return tournamentLevel.localizedLabel(.short) + tournamentCategory.localizedLabel(.short) + return tournamentLevel.localizedLevelLabel(.short) + tournamentCategory.localizedLabel(.short) } } diff --git a/PadelClub/Utils/HtmlGenerator.swift b/PadelClub/Utils/HtmlGenerator.swift index af72534..4139f67 100644 --- a/PadelClub/Utils/HtmlGenerator.swift +++ b/PadelClub/Utils/HtmlGenerator.swift @@ -186,7 +186,7 @@ class HtmlGenerator: ObservableObject { .day() .dateSeparator(.dash)) - let name = tournament.tournamentLevel.localizedLabel() + "-" + tournament.tournamentCategory.importingRawValue + let name = tournament.tournamentLevel.localizedLevelLabel() + "-" + tournament.tournamentCategory.importingRawValue return pdfFolderURL.appendingPathComponent(stringDate + "-" + name + ".pdf") } diff --git a/PadelClub/Utils/PadelRule.swift b/PadelClub/Utils/PadelRule.swift index 8a069d4..62a1889 100644 --- a/PadelClub/Utils/PadelRule.swift +++ b/PadelClub/Utils/PadelRule.swift @@ -48,7 +48,7 @@ struct TournamentBuild: TournamentBuildHolder, Hashable, Codable, Identifiable { } var identifier: String { - level.localizedLabel()+":"+category.localizedLabel()+":"+age.localizedLabel() + level.localizedLevelLabel()+":"+category.localizedLabel()+":"+age.localizedLabel() } var computedLabel: String { @@ -57,11 +57,11 @@ struct TournamentBuild: TournamentBuildHolder, Hashable, Codable, Identifiable { } func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String { - level.localizedLabel() + category.localizedLabel(.short) + level.localizedLevelLabel() + category.localizedLabel(.short) } var localizedTitle: String { - level.localizedLabel() + " " + category.localizedLabel() + level.localizedLevelLabel() + " " + category.localizedLabel() } var localizedAge: String { @@ -72,7 +72,7 @@ struct TournamentBuild: TournamentBuildHolder, Hashable, Codable, Identifiable { extension TournamentBuild { init?(category: String, level: String, age: FederalTournamentAge = .senior) { - guard let levelFound = TournamentLevel.allCases.first(where: { $0.localizedLabel() == level }) else { return nil } + guard let levelFound = TournamentLevel.allCases.first(where: { $0.localizedLevelLabel() == level }) else { return nil } var c = category if c.hasPrefix("ME") { @@ -465,7 +465,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { } } - func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String { + func localizedLevelLabel(_ displayStyle: DisplayStyle = .wide) -> String { if self == .unlisted { return displayStyle == .title ? "Animation" : "Anim." } return String(describing: self).capitalized } diff --git a/PadelClub/ViewModel/FederalDataViewModel.swift b/PadelClub/ViewModel/FederalDataViewModel.swift index 010b211..d4d6d24 100644 --- a/PadelClub/ViewModel/FederalDataViewModel.swift +++ b/PadelClub/ViewModel/FederalDataViewModel.swift @@ -25,7 +25,7 @@ class FederalDataViewModel { func filterStatus() -> String { var labels: [String] = [] - labels.append(contentsOf: levels.map { $0.localizedLabel() }.formatList()) + labels.append(contentsOf: levels.map { $0.localizedLevelLabel() }.formatList()) labels.append(contentsOf: categories.map { $0.localizedLabel() }.formatList()) labels.append(contentsOf: ageCategories.map { $0.localizedLabel() }.formatList()) let clubNames = selectedClubs.compactMap { codeClub in diff --git a/PadelClub/Views/Calling/CallMessageCustomizationView.swift b/PadelClub/Views/Calling/CallMessageCustomizationView.swift index 93a1779..569f420 100644 --- a/PadelClub/Views/Calling/CallMessageCustomizationView.swift +++ b/PadelClub/Views/Calling/CallMessageCustomizationView.swift @@ -95,6 +95,16 @@ struct CallMessageCustomizationView: View { } .headerProminence(.increased) .navigationBarTitleDisplayMode(.inline) + .navigationBarBackButtonHidden(focusedField != nil) + .toolbar(content: { + if focusedField != nil { + ToolbarItem(placement: .topBarLeading) { + Button("Annuler", role: .cancel) { + focusedField = nil + } + } + } + }) .toolbarBackground(.visible, for: .navigationBar) .navigationTitle("Message de convocation") .toolbar { diff --git a/PadelClub/Views/Cashier/Event/EventSettingsView.swift b/PadelClub/Views/Cashier/Event/EventSettingsView.swift index d2f7d9c..cad0f0a 100644 --- a/PadelClub/Views/Cashier/Event/EventSettingsView.swift +++ b/PadelClub/Views/Cashier/Event/EventSettingsView.swift @@ -27,7 +27,7 @@ struct EventSettingsView: View { link.append(tournaments.compactMap({ tournament in if let url = tournament.shareURL(pageLink) { var tournamentLink = [String]() - tournamentLink.append(tournament.tournamentTitle()) + tournamentLink.append(tournament.tournamentTitle(.title)) tournamentLink.append(url.absoluteString) return tournamentLink.joined(separator: "\n") } else { @@ -87,6 +87,16 @@ struct EventSettingsView: View { } } } + .navigationBarBackButtonHidden(textFieldIsFocus) + .toolbar(content: { + if textFieldIsFocus { + ToolbarItem(placement: .topBarLeading) { + Button("Annuler", role: .cancel) { + textFieldIsFocus = false + } + } + } + }) .toolbar { if textFieldIsFocus { ToolbarItem(placement: .keyboard) { diff --git a/PadelClub/Views/Cashier/Event/TournamentConfiguratorView.swift b/PadelClub/Views/Cashier/Event/TournamentConfiguratorView.swift index 65ecfc3..68483c3 100644 --- a/PadelClub/Views/Cashier/Event/TournamentConfiguratorView.swift +++ b/PadelClub/Views/Cashier/Event/TournamentConfiguratorView.swift @@ -22,7 +22,7 @@ struct TournamentConfigurationView: View { var body: some View { Picker(selection: $tournament.federalLevelCategory, label: Text("Niveau")) { ForEach(TournamentLevel.allCases) { type in - Text(type.localizedLabel(.title)).tag(type) + Text(type.localizedLevelLabel(.title)).tag(type) } } .onChange(of: tournament.federalLevelCategory) { diff --git a/PadelClub/Views/Club/ClubDetailView.swift b/PadelClub/Views/Club/ClubDetailView.swift index cb3b23b..b04b4f0 100644 --- a/PadelClub/Views/Club/ClubDetailView.swift +++ b/PadelClub/Views/Club/ClubDetailView.swift @@ -213,6 +213,16 @@ struct ClubDetailView: View { } } } + .navigationBarBackButtonHidden(focusedField != nil) + .toolbar(content: { + if focusedField != nil { + ToolbarItem(placement: .topBarLeading) { + Button("Annuler", role: .cancel) { + focusedField = nil + } + } + } + }) .keyboardType(.alphabet) .autocorrectionDisabled() .defaultFocus($focusedField, ._name, priority: .automatic) diff --git a/PadelClub/Views/Club/CourtView.swift b/PadelClub/Views/Club/CourtView.swift index 8986cc4..c4e89f8 100644 --- a/PadelClub/Views/Club/CourtView.swift +++ b/PadelClub/Views/Club/CourtView.swift @@ -12,6 +12,7 @@ struct CourtView: View { @EnvironmentObject var dataStore: DataStore @Bindable var court: Court @State private var name: String = "" + @FocusState var focusedField: Court.CodingKeys? init(court: Court) { self.court = court @@ -23,6 +24,7 @@ struct CourtView: View { Section { LabeledContent { TextField("Nom", text: $name) + .focused($focusedField, equals: ._name) .autocorrectionDisabled() .keyboardType(.alphabet) .multilineTextAlignment(.trailing) @@ -71,6 +73,16 @@ struct CourtView: View { Logger.error(error) } } + .navigationBarBackButtonHidden(focusedField != nil) + .toolbar(content: { + if focusedField != nil { + ToolbarItem(placement: .topBarLeading) { + Button("Annuler", role: .cancel) { + focusedField = nil + } + } + } + }) .navigationTitle(court.courtTitle()) .navigationBarTitleDisplayMode(.inline) .toolbarBackground(.visible, for: .navigationBar) diff --git a/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift b/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift index 6713281..64abb0f 100644 --- a/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift +++ b/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift @@ -20,7 +20,8 @@ struct GroupStageSettingsView: View { @State private var presentConfirmationButton: Bool = false @State private var size: Int @State private var courtIndex: Int - + @FocusState var focusedField: GroupStage.CodingKeys? + init(groupStage: GroupStage) { _groupStage = Bindable(groupStage) _groupStageName = .init(wrappedValue: groupStage.name ?? "") @@ -37,6 +38,7 @@ struct GroupStageSettingsView: View { Section { TextField("Nom de la poule", text: $groupStageName) .keyboardType(.alphabet) + .focused($focusedField, equals: ._name) .submitLabel(.done) .frame(maxWidth: .infinity) .onSubmit { @@ -153,6 +155,16 @@ struct GroupStageSettingsView: View { presentConfirmationButton = true } } + .navigationBarBackButtonHidden(focusedField != nil) + .toolbar(content: { + if focusedField != nil { + ToolbarItem(placement: .topBarLeading) { + Button("Annuler", role: .cancel) { + focusedField = nil + } + } + } + }) .navigationTitle("Paramètres") .toolbarBackground(.visible, for: .navigationBar) } diff --git a/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift b/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift index 000ba3f..ede4f2d 100644 --- a/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift +++ b/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift @@ -335,7 +335,7 @@ struct TournamentLookUpView: View { NavigationLink { List([TournamentLevel.p25, TournamentLevel.p100, TournamentLevel.p250, TournamentLevel.p500, TournamentLevel.p1000, TournamentLevel.p1500, TournamentLevel.p2000], selection: $appSettings.tournamentLevels) { type in - Text(type.localizedLabel()) + Text(type.localizedLevelLabel()) } .navigationTitle("Niveaux") .environment(\.editMode, Binding.constant(EditMode.active)) @@ -413,7 +413,7 @@ struct TournamentLookUpView: View { if dataStore.appSettings.tournamentLevels.isEmpty || dataStore.appSettings.tournamentLevels.count == TournamentLevel.allCases.count { Text("Tous les niveaux") } else { - Text(levels.map({ $0.localizedLabel() }).joined(separator: ", ")) + Text(levels.map({ $0.localizedLevelLabel() }).joined(separator: ", ")) } } diff --git a/PadelClub/Views/Navigation/Toolbox/RankCalculatorView.swift b/PadelClub/Views/Navigation/Toolbox/RankCalculatorView.swift index 0ebd1bf..28b4050 100644 --- a/PadelClub/Views/Navigation/Toolbox/RankCalculatorView.swift +++ b/PadelClub/Views/Navigation/Toolbox/RankCalculatorView.swift @@ -17,7 +17,7 @@ struct RankCalculatorView: View { Section { HStack { let ordinal = NumberFormatter.ordinal.string(from: NSNumber(value:rank))! - Text("\(ordinal) d'un \(tournamentLevel.localizedLabel()) de \(count.localizedLabel()) équipes:") + Text("\(ordinal) d'un \(tournamentLevel.localizedLevelLabel()) de \(count.localizedLabel()) équipes:") Spacer() Text(tournamentLevel.points(for: rank-1, count: count.rawValue).formatted(.number.sign(strategy: .always()))) } @@ -25,7 +25,7 @@ struct RankCalculatorView: View { Section { Picker(selection: $tournamentLevel) { ForEach(TournamentLevel.allCases) { level in - Text(level.localizedLabel()).tag(level) + Text(level.localizedLevelLabel()).tag(level) } } label: { Label("Niveau", systemImage: "gauge.medium") diff --git a/PadelClub/Views/Player/PlayerDetailView.swift b/PadelClub/Views/Player/PlayerDetailView.swift index 3d65b72..e5a203c 100644 --- a/PadelClub/Views/Player/PlayerDetailView.swift +++ b/PadelClub/Views/Player/PlayerDetailView.swift @@ -179,6 +179,16 @@ struct PlayerDetailView: View { player.team()?.updateWeight(inTournamentCategory: tournament.tournamentCategory) _save() } + .navigationBarBackButtonHidden(focusedField != nil) + .toolbar(content: { + if focusedField != nil { + ToolbarItem(placement: .topBarLeading) { + Button("Annuler", role: .cancel) { + focusedField = nil + } + } + } + }) .headerProminence(.increased) .navigationTitle("Édition") .navigationBarTitleDisplayMode(.inline) diff --git a/PadelClub/Views/Shared/TournamentFilterView.swift b/PadelClub/Views/Shared/TournamentFilterView.swift index 8e84a0b..6af4d7c 100644 --- a/PadelClub/Views/Shared/TournamentFilterView.swift +++ b/PadelClub/Views/Shared/TournamentFilterView.swift @@ -63,7 +63,7 @@ struct TournamentFilterView: View { } } } label: { - Text(level.localizedLabel(.title)) + Text(level.localizedLevelLabel(.title)) } } } header: { diff --git a/PadelClub/Views/Team/EditingTeamView.swift b/PadelClub/Views/Team/EditingTeamView.swift index 782e996..e60c949 100644 --- a/PadelClub/Views/Team/EditingTeamView.swift +++ b/PadelClub/Views/Team/EditingTeamView.swift @@ -21,7 +21,8 @@ struct EditingTeamView: View { @State private var registrationDate : Date @State private var callDate : Date @State private var name: String - + @FocusState private var focusedField: TeamRegistration.CodingKeys? + var messageSentFailed: Binding { Binding { sentError != nil @@ -142,6 +143,7 @@ struct EditingTeamView: View { Section { TextField("Nom de l'équipe", text: $name) .autocorrectionDisabled() + .focused($focusedField, equals: ._name) .keyboardType(.alphabet) .frame(maxWidth: .infinity) .submitLabel(.done) @@ -186,6 +188,16 @@ struct EditingTeamView: View { } } } + .navigationBarBackButtonHidden(focusedField != nil) + .toolbar(content: { + if focusedField != nil { + ToolbarItem(placement: .topBarLeading) { + Button("Annuler", role: .cancel) { + focusedField = nil + } + } + } + }) .alert("Un problème est survenu", isPresented: messageSentFailed) { Button("OK") { } diff --git a/PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift b/PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift index 49de144..1258938 100644 --- a/PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift +++ b/PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift @@ -91,6 +91,16 @@ struct TournamentGeneralSettingsView: View { } } } + .navigationBarBackButtonHidden(focusedField != nil) + .toolbar(content: { + if focusedField != nil { + ToolbarItem(placement: .topBarLeading) { + Button("Annuler", role: .cancel) { + focusedField = nil + } + } + } + }) .toolbarBackground(.visible, for: .navigationBar) .toolbar { if focusedField != nil { diff --git a/PadelClub/Views/Tournament/Screen/Components/TournamentLevelPickerView.swift b/PadelClub/Views/Tournament/Screen/Components/TournamentLevelPickerView.swift index 5550b66..4e3bc69 100644 --- a/PadelClub/Views/Tournament/Screen/Components/TournamentLevelPickerView.swift +++ b/PadelClub/Views/Tournament/Screen/Components/TournamentLevelPickerView.swift @@ -15,7 +15,7 @@ struct TournamentLevelPickerView: View { Picker(selection: $tournament.tournamentLevel, label: Text("Niveau")) { ForEach(TournamentLevel.allCases) { type in - Text(type.localizedLabel(.title)).tag(type) + Text(type.localizedLevelLabel(.title)).tag(type) } } .onChange(of: tournament.federalLevelCategory) { diff --git a/PadelClub/Views/Tournament/Screen/TableStructureView.swift b/PadelClub/Views/Tournament/Screen/TableStructureView.swift index 460fd28..d3ec145 100644 --- a/PadelClub/Views/Tournament/Screen/TableStructureView.swift +++ b/PadelClub/Views/Tournament/Screen/TableStructureView.swift @@ -62,6 +62,8 @@ struct TableStructureView: View { } label: { Text("Nombre de poules") } + } footer: { + Text("Vous pourrez modifier la taille de vos poules de manière spécifique dans l'écran des poules.") } if groupStageCount > 0 { diff --git a/PadelClub/Views/Tournament/Shared/TournamentCellView.swift b/PadelClub/Views/Tournament/Shared/TournamentCellView.swift index 1e9ab62..94a7353 100644 --- a/PadelClub/Views/Tournament/Shared/TournamentCellView.swift +++ b/PadelClub/Views/Tournament/Shared/TournamentCellView.swift @@ -88,7 +88,7 @@ struct TournamentCellView: View { .font(.caption) } HStack(alignment: .bottom) { - Text(build.level.localizedLabel()) + Text(build.level.localizedLevelLabel()) .fontWeight(.semibold) if displayStyle == .wide { VStack(alignment: .leading, spacing: 0) {