UI/UX Enhancement: Inline Clear Button for Text Fields in QueryView
Currently, when users want to delete or modify a long string of text in text input fields, they have to manually press backspace multiple times or select all text to delete it.
Proposal
Add a circular "X" (clear) button inside the right edge of text fields.
HStack {
TextField("G2/380/CRH2A2001", text: Binding(
get: { query },
set: { query = $0.filter { $0.isLetter || $0.isNumber }.uppercased() }
))
.keyboardType(.asciiCapable)
.textInputAutocapitalization(.characters)
.autocorrectionDisabled()
.onSubmit {
guard !query.isEmpty else { return }
path.append(Query.trainOrEmu(trainOrEmu: query))
}
if !query.isEmpty {
Button(action: {
query = ""
}) {
Image(systemName: "xmark.circle.fill")
.foregroundColor(.gray)
}
.buttonStyle(.plain)
}
}
Behavior:
The button should only appear when the text field is focused and contains text. It should disappear when the text field is empty or loses focus. Tapping the button should instantly clear all inputted text and keep the text field focused.
Code Refactor: Multi-language Support via .xcstrings
Several user-facing strings are currently hardcoded directly into the source code.
Proposal
Adopt Xcode’s String Catalogs (.xcstrings) to externalize and manage all app text.
Refactor the codebase to replace hardcoded strings with localized string keys (e.g., using NSLocalizedString or SwiftUI's String(localized: "...") features). Create an .xcstrings catalog file to centrally manage translations.
UI/UX Enhancement: Inline Clear Button for Text Fields in
QueryViewCurrently, when users want to delete or modify a long string of text in text input fields, they have to manually press backspace multiple times or select all text to delete it.
Proposal
Add a circular "X" (clear) button inside the right edge of text fields.
Behavior:
The button should only appear when the text field is focused and contains text. It should disappear when the text field is empty or loses focus. Tapping the button should instantly clear all inputted text and keep the text field focused.
Code Refactor: Multi-language Support via
.xcstringsSeveral user-facing strings are currently hardcoded directly into the source code.
Proposal
Adopt Xcode’s String Catalogs (.xcstrings) to externalize and manage all app text.
Refactor the codebase to replace hardcoded strings with localized string keys (e.g., using
NSLocalizedStringor SwiftUI'sString(localized: "...")features). Create an .xcstrings catalog file to centrally manage translations.