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. 14
      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. 14
      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 {
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)
}
}

@ -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")
}

@ -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
}

@ -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

@ -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 {

@ -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) {

@ -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) {

@ -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)

@ -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)

@ -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)
}

@ -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: ", "))
}
}

@ -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")

@ -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)

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

@ -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<Bool> {
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") {
}

@ -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 {

@ -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) {

@ -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 {

@ -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) {

Loading…
Cancel
Save