Settings: Fix focus for fields

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2023-04-23 15:57:18 -04:00
parent 9e362c14b7
commit 3606dbb6ff
2 changed files with 17 additions and 1 deletions

View file

@ -15,7 +15,7 @@ struct HybridSecureField: View {
@Binding var text: String
@State private var showPassword = false
@FocusState var focusedField: Field?
@FocusState private var focusedField: Field?
var body: some View {
HStack {

View file

@ -34,6 +34,12 @@ struct SettingsView: View {
@AppStorage("Debug.ShowErrorToasts") var showErrorToasts = true
private enum Field {
case requestTimeout
}
@FocusState private var focusedField: Field?
var body: some View {
NavView {
Form {
@ -90,6 +96,7 @@ struct SettingsView: View {
TextField("", value: $requestTimeoutSecs, formatter: NumberFormatter())
.fixedSize()
.keyboardType(.numberPad)
.focused($focusedField, equals: Field.requestTimeout)
}
}
}
@ -206,6 +213,15 @@ struct SettingsView: View {
.prefersEphemeralWebBrowserSession(true)
}
.navigationTitle("Settings")
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Spacer()
Button("Done") {
focusedField = nil
}
}
}
}
}
}