fix textfield cancel / validate UI stuff

sync2
Raz 1 year ago
parent daec637301
commit 913d3de4f5
  1. 8
      PadelClub/Data/Tournament.swift
  2. 2
      PadelClub/Utils/HtmlGenerator.swift
  3. 10
      PadelClub/Utils/PadelRule.swift
  4. 2
      PadelClub/ViewModel/FederalDataViewModel.swift
  5. 10
      PadelClub/Views/Calling/CallMessageCustomizationView.swift
  6. 12
      PadelClub/Views/Cashier/Event/EventSettingsView.swift
  7. 2
      PadelClub/Views/Cashier/Event/TournamentConfiguratorView.swift
  8. 10
      PadelClub/Views/Club/ClubDetailView.swift
  9. 12
      PadelClub/Views/Club/CourtView.swift
  10. 12
      PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift
  11. 4
      PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift
  12. 4
      PadelClub/Views/Navigation/Toolbox/RankCalculatorView.swift
  13. 10
      PadelClub/Views/Player/PlayerDetailView.swift
  14. 2
      PadelClub/Views/Shared/TournamentFilterView.swift
  15. 12
      PadelClub/Views/Team/EditingTeamView.swift
  16. 10
      PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift
  17. 2
      PadelClub/Views/Tournament/Screen/Components/TournamentLevelPickerView.swift
  18. 2
      PadelClub/Views/Tournament/Screen/TableStructureView.swift
  19. 2
      PadelClub/Views/Tournament/Shared/TournamentCellView.swift

@ -1396,10 +1396,10 @@ defer {
if let name { if let name {
return name return name
} else { } 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 { if displayStyle == .wide, let name {
return [title, name].joined(separator: " - ") return [title, name].joined(separator: " - ")
} else { } else {
@ -1410,9 +1410,9 @@ defer {
func localizedTournamentType() -> String { func localizedTournamentType() -> String {
switch tournamentLevel { switch tournamentLevel {
case .unlisted: case .unlisted:
return tournamentLevel.localizedLabel(.short) return tournamentLevel.localizedLevelLabel(.short)
default: default:
return tournamentLevel.localizedLabel(.short) + tournamentCategory.localizedLabel(.short) return tournamentLevel.localizedLevelLabel(.short) + tournamentCategory.localizedLabel(.short)
} }
} }

@ -186,7 +186,7 @@ class HtmlGenerator: ObservableObject {
.day() .day()
.dateSeparator(.dash)) .dateSeparator(.dash))
let name = tournament.tournamentLevel.localizedLabel() + "-" + tournament.tournamentCategory.importingRawValue let name = tournament.tournamentLevel.localizedLevelLabel() + "-" + tournament.tournamentCategory.importingRawValue
return pdfFolderURL.appendingPathComponent(stringDate + "-" + name + ".pdf") return pdfFolderURL.appendingPathComponent(stringDate + "-" + name + ".pdf")
} }

@ -48,7 +48,7 @@ struct TournamentBuild: TournamentBuildHolder, Hashable, Codable, Identifiable {
} }
var identifier: String { var identifier: String {
level.localizedLabel()+":"+category.localizedLabel()+":"+age.localizedLabel() level.localizedLevelLabel()+":"+category.localizedLabel()+":"+age.localizedLabel()
} }
var computedLabel: String { var computedLabel: String {
@ -57,11 +57,11 @@ struct TournamentBuild: TournamentBuildHolder, Hashable, Codable, Identifiable {
} }
func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String { func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String {
level.localizedLabel() + category.localizedLabel(.short) level.localizedLevelLabel() + category.localizedLabel(.short)
} }
var localizedTitle: String { var localizedTitle: String {
level.localizedLabel() + " " + category.localizedLabel() level.localizedLevelLabel() + " " + category.localizedLabel()
} }
var localizedAge: String { var localizedAge: String {
@ -72,7 +72,7 @@ struct TournamentBuild: TournamentBuildHolder, Hashable, Codable, Identifiable {
extension TournamentBuild { extension TournamentBuild {
init?(category: String, level: String, age: FederalTournamentAge = .senior) { 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 var c = category
if c.hasPrefix("ME") { 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." } if self == .unlisted { return displayStyle == .title ? "Animation" : "Anim." }
return String(describing: self).capitalized return String(describing: self).capitalized
} }

@ -25,7 +25,7 @@ class FederalDataViewModel {
func filterStatus() -> String { func filterStatus() -> String {
var labels: [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: categories.map { $0.localizedLabel() }.formatList())
labels.append(contentsOf: ageCategories.map { $0.localizedLabel() }.formatList()) labels.append(contentsOf: ageCategories.map { $0.localizedLabel() }.formatList())
let clubNames = selectedClubs.compactMap { codeClub in let clubNames = selectedClubs.compactMap { codeClub in

@ -95,6 +95,16 @@ struct CallMessageCustomizationView: View {
} }
.headerProminence(.increased) .headerProminence(.increased)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(focusedField != nil)
.toolbar(content: {
if focusedField != nil {
ToolbarItem(placement: .topBarLeading) {
Button("Annuler", role: .cancel) {
focusedField = nil
}
}
}
})
.toolbarBackground(.visible, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar)
.navigationTitle("Message de convocation") .navigationTitle("Message de convocation")
.toolbar { .toolbar {

@ -27,7 +27,7 @@ struct EventSettingsView: View {
link.append(tournaments.compactMap({ tournament in link.append(tournaments.compactMap({ tournament in
if let url = tournament.shareURL(pageLink) { if let url = tournament.shareURL(pageLink) {
var tournamentLink = [String]() var tournamentLink = [String]()
tournamentLink.append(tournament.tournamentTitle()) tournamentLink.append(tournament.tournamentTitle(.title))
tournamentLink.append(url.absoluteString) tournamentLink.append(url.absoluteString)
return tournamentLink.joined(separator: "\n") return tournamentLink.joined(separator: "\n")
} else { } else {
@ -87,6 +87,16 @@ struct EventSettingsView: View {
} }
} }
} }
.navigationBarBackButtonHidden(textFieldIsFocus)
.toolbar(content: {
if textFieldIsFocus {
ToolbarItem(placement: .topBarLeading) {
Button("Annuler", role: .cancel) {
textFieldIsFocus = false
}
}
}
})
.toolbar { .toolbar {
if textFieldIsFocus { if textFieldIsFocus {
ToolbarItem(placement: .keyboard) { ToolbarItem(placement: .keyboard) {

@ -22,7 +22,7 @@ struct TournamentConfigurationView: View {
var body: some View { var body: some View {
Picker(selection: $tournament.federalLevelCategory, label: Text("Niveau")) { Picker(selection: $tournament.federalLevelCategory, label: Text("Niveau")) {
ForEach(TournamentLevel.allCases) { type in ForEach(TournamentLevel.allCases) { type in
Text(type.localizedLabel(.title)).tag(type) Text(type.localizedLevelLabel(.title)).tag(type)
} }
} }
.onChange(of: tournament.federalLevelCategory) { .onChange(of: tournament.federalLevelCategory) {

@ -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) .keyboardType(.alphabet)
.autocorrectionDisabled() .autocorrectionDisabled()
.defaultFocus($focusedField, ._name, priority: .automatic) .defaultFocus($focusedField, ._name, priority: .automatic)

@ -12,6 +12,7 @@ struct CourtView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@Bindable var court: Court @Bindable var court: Court
@State private var name: String = "" @State private var name: String = ""
@FocusState var focusedField: Court.CodingKeys?
init(court: Court) { init(court: Court) {
self.court = court self.court = court
@ -23,6 +24,7 @@ struct CourtView: View {
Section { Section {
LabeledContent { LabeledContent {
TextField("Nom", text: $name) TextField("Nom", text: $name)
.focused($focusedField, equals: ._name)
.autocorrectionDisabled() .autocorrectionDisabled()
.keyboardType(.alphabet) .keyboardType(.alphabet)
.multilineTextAlignment(.trailing) .multilineTextAlignment(.trailing)
@ -71,6 +73,16 @@ struct CourtView: View {
Logger.error(error) Logger.error(error)
} }
} }
.navigationBarBackButtonHidden(focusedField != nil)
.toolbar(content: {
if focusedField != nil {
ToolbarItem(placement: .topBarLeading) {
Button("Annuler", role: .cancel) {
focusedField = nil
}
}
}
})
.navigationTitle(court.courtTitle()) .navigationTitle(court.courtTitle())
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar)

@ -20,6 +20,7 @@ struct GroupStageSettingsView: View {
@State private var presentConfirmationButton: Bool = false @State private var presentConfirmationButton: Bool = false
@State private var size: Int @State private var size: Int
@State private var courtIndex: Int @State private var courtIndex: Int
@FocusState var focusedField: GroupStage.CodingKeys?
init(groupStage: GroupStage) { init(groupStage: GroupStage) {
_groupStage = Bindable(groupStage) _groupStage = Bindable(groupStage)
@ -37,6 +38,7 @@ struct GroupStageSettingsView: View {
Section { Section {
TextField("Nom de la poule", text: $groupStageName) TextField("Nom de la poule", text: $groupStageName)
.keyboardType(.alphabet) .keyboardType(.alphabet)
.focused($focusedField, equals: ._name)
.submitLabel(.done) .submitLabel(.done)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.onSubmit { .onSubmit {
@ -153,6 +155,16 @@ struct GroupStageSettingsView: View {
presentConfirmationButton = true presentConfirmationButton = true
} }
} }
.navigationBarBackButtonHidden(focusedField != nil)
.toolbar(content: {
if focusedField != nil {
ToolbarItem(placement: .topBarLeading) {
Button("Annuler", role: .cancel) {
focusedField = nil
}
}
}
})
.navigationTitle("Paramètres") .navigationTitle("Paramètres")
.toolbarBackground(.visible, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar)
} }

@ -335,7 +335,7 @@ struct TournamentLookUpView: View {
NavigationLink { NavigationLink {
List([TournamentLevel.p25, TournamentLevel.p100, TournamentLevel.p250, TournamentLevel.p500, TournamentLevel.p1000, TournamentLevel.p1500, TournamentLevel.p2000], selection: $appSettings.tournamentLevels) { type in 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") .navigationTitle("Niveaux")
.environment(\.editMode, Binding.constant(EditMode.active)) .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 { if dataStore.appSettings.tournamentLevels.isEmpty || dataStore.appSettings.tournamentLevels.count == TournamentLevel.allCases.count {
Text("Tous les niveaux") Text("Tous les niveaux")
} else { } else {
Text(levels.map({ $0.localizedLabel() }).joined(separator: ", ")) Text(levels.map({ $0.localizedLevelLabel() }).joined(separator: ", "))
} }
} }

@ -17,7 +17,7 @@ struct RankCalculatorView: View {
Section { Section {
HStack { HStack {
let ordinal = NumberFormatter.ordinal.string(from: NSNumber(value:rank))! 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() Spacer()
Text(tournamentLevel.points(for: rank-1, count: count.rawValue).formatted(.number.sign(strategy: .always()))) Text(tournamentLevel.points(for: rank-1, count: count.rawValue).formatted(.number.sign(strategy: .always())))
} }
@ -25,7 +25,7 @@ struct RankCalculatorView: View {
Section { Section {
Picker(selection: $tournamentLevel) { Picker(selection: $tournamentLevel) {
ForEach(TournamentLevel.allCases) { level in ForEach(TournamentLevel.allCases) { level in
Text(level.localizedLabel()).tag(level) Text(level.localizedLevelLabel()).tag(level)
} }
} label: { } label: {
Label("Niveau", systemImage: "gauge.medium") Label("Niveau", systemImage: "gauge.medium")

@ -179,6 +179,16 @@ struct PlayerDetailView: View {
player.team()?.updateWeight(inTournamentCategory: tournament.tournamentCategory) player.team()?.updateWeight(inTournamentCategory: tournament.tournamentCategory)
_save() _save()
} }
.navigationBarBackButtonHidden(focusedField != nil)
.toolbar(content: {
if focusedField != nil {
ToolbarItem(placement: .topBarLeading) {
Button("Annuler", role: .cancel) {
focusedField = nil
}
}
}
})
.headerProminence(.increased) .headerProminence(.increased)
.navigationTitle("Édition") .navigationTitle("Édition")
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)

@ -63,7 +63,7 @@ struct TournamentFilterView: View {
} }
} }
} label: { } label: {
Text(level.localizedLabel(.title)) Text(level.localizedLevelLabel(.title))
} }
} }
} header: { } header: {

@ -21,6 +21,7 @@ struct EditingTeamView: View {
@State private var registrationDate : Date @State private var registrationDate : Date
@State private var callDate : Date @State private var callDate : Date
@State private var name: String @State private var name: String
@FocusState private var focusedField: TeamRegistration.CodingKeys?
var messageSentFailed: Binding<Bool> { var messageSentFailed: Binding<Bool> {
Binding { Binding {
@ -142,6 +143,7 @@ struct EditingTeamView: View {
Section { Section {
TextField("Nom de l'équipe", text: $name) TextField("Nom de l'équipe", text: $name)
.autocorrectionDisabled() .autocorrectionDisabled()
.focused($focusedField, equals: ._name)
.keyboardType(.alphabet) .keyboardType(.alphabet)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.submitLabel(.done) .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) { .alert("Un problème est survenu", isPresented: messageSentFailed) {
Button("OK") { Button("OK") {
} }

@ -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) .toolbarBackground(.visible, for: .navigationBar)
.toolbar { .toolbar {
if focusedField != nil { if focusedField != nil {

@ -15,7 +15,7 @@ struct TournamentLevelPickerView: View {
Picker(selection: $tournament.tournamentLevel, label: Text("Niveau")) { Picker(selection: $tournament.tournamentLevel, label: Text("Niveau")) {
ForEach(TournamentLevel.allCases) { type in ForEach(TournamentLevel.allCases) { type in
Text(type.localizedLabel(.title)).tag(type) Text(type.localizedLevelLabel(.title)).tag(type)
} }
} }
.onChange(of: tournament.federalLevelCategory) { .onChange(of: tournament.federalLevelCategory) {

@ -62,6 +62,8 @@ struct TableStructureView: View {
} label: { } label: {
Text("Nombre de poules") 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 { if groupStageCount > 0 {

@ -88,7 +88,7 @@ struct TournamentCellView: View {
.font(.caption) .font(.caption)
} }
HStack(alignment: .bottom) { HStack(alignment: .bottom) {
Text(build.level.localizedLabel()) Text(build.level.localizedLevelLabel())
.fontWeight(.semibold) .fontWeight(.semibold)
if displayStyle == .wide { if displayStyle == .wide {
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {

Loading…
Cancel
Save