Skip to content

Commit

Permalink
Settings: Fix focus for fields
Browse files Browse the repository at this point in the history
Signed-off-by: kingbri <[email protected]>
  • Loading branch information
bdashore3 committed Apr 23, 2023
1 parent 9e362c1 commit 3606dbb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Ferrite/Views/CommonViews/HybridSecureField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions Ferrite/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -90,6 +96,7 @@ struct SettingsView: View {
TextField("", value: $requestTimeoutSecs, formatter: NumberFormatter())
.fixedSize()
.keyboardType(.numberPad)
.focused($focusedField, equals: Field.requestTimeout)
}
}
}
Expand Down Expand Up @@ -206,6 +213,15 @@ struct SettingsView: View {
.prefersEphemeralWebBrowserSession(true)
}
.navigationTitle("Settings")
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Spacer()

Button("Done") {
focusedField = nil
}
}
}
}
}
}
Expand Down

0 comments on commit 3606dbb

Please sign in to comment.