Settings: Fix focus for fields
Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
parent
9e362c14b7
commit
3606dbb6ff
2 changed files with 17 additions and 1 deletions
|
|
@ -15,7 +15,7 @@ struct HybridSecureField: View {
|
||||||
|
|
||||||
@Binding var text: String
|
@Binding var text: String
|
||||||
@State private var showPassword = false
|
@State private var showPassword = false
|
||||||
@FocusState var focusedField: Field?
|
@FocusState private var focusedField: Field?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack {
|
HStack {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,12 @@ struct SettingsView: View {
|
||||||
|
|
||||||
@AppStorage("Debug.ShowErrorToasts") var showErrorToasts = true
|
@AppStorage("Debug.ShowErrorToasts") var showErrorToasts = true
|
||||||
|
|
||||||
|
private enum Field {
|
||||||
|
case requestTimeout
|
||||||
|
}
|
||||||
|
|
||||||
|
@FocusState private var focusedField: Field?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavView {
|
NavView {
|
||||||
Form {
|
Form {
|
||||||
|
|
@ -90,6 +96,7 @@ struct SettingsView: View {
|
||||||
TextField("", value: $requestTimeoutSecs, formatter: NumberFormatter())
|
TextField("", value: $requestTimeoutSecs, formatter: NumberFormatter())
|
||||||
.fixedSize()
|
.fixedSize()
|
||||||
.keyboardType(.numberPad)
|
.keyboardType(.numberPad)
|
||||||
|
.focused($focusedField, equals: Field.requestTimeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -206,6 +213,15 @@ struct SettingsView: View {
|
||||||
.prefersEphemeralWebBrowserSession(true)
|
.prefersEphemeralWebBrowserSession(true)
|
||||||
}
|
}
|
||||||
.navigationTitle("Settings")
|
.navigationTitle("Settings")
|
||||||
|
.toolbar {
|
||||||
|
ToolbarItemGroup(placement: .keyboard) {
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
Button("Done") {
|
||||||
|
focusedField = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue