Keep the new keyword field focused
This commit is contained in:
parent
199f83c386
commit
0842f23d52
|
@ -20,7 +20,12 @@ struct EditFilterView: View {
|
||||||
@State private var filterAction: ServerFilter.Action
|
@State private var filterAction: ServerFilter.Action
|
||||||
@State private var expiresAt: Date?
|
@State private var expiresAt: Date?
|
||||||
@State private var expirySelection: Duration
|
@State private var expirySelection: Duration
|
||||||
@FocusState private var isTitleFocused: Bool
|
|
||||||
|
enum Fields {
|
||||||
|
case title, newKeyword
|
||||||
|
}
|
||||||
|
|
||||||
|
@FocusState private var focusedField: Fields?
|
||||||
|
|
||||||
private var data: ServerFilterData {
|
private var data: ServerFilterData {
|
||||||
var expiresIn: String?
|
var expiresIn: String?
|
||||||
|
@ -71,7 +76,7 @@ struct EditFilterView: View {
|
||||||
.background(theme.secondaryBackgroundColor)
|
.background(theme.secondaryBackgroundColor)
|
||||||
.onAppear {
|
.onAppear {
|
||||||
if filter == nil {
|
if filter == nil {
|
||||||
isTitleFocused = true
|
focusedField = .title
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.toolbar {
|
.toolbar {
|
||||||
|
@ -107,7 +112,7 @@ struct EditFilterView: View {
|
||||||
private var titleSection: some View {
|
private var titleSection: some View {
|
||||||
Section("filter.edit.title") {
|
Section("filter.edit.title") {
|
||||||
TextField("filter.edit.title", text: $title)
|
TextField("filter.edit.title", text: $title)
|
||||||
.focused($isTitleFocused)
|
.focused($focusedField, equals: .title)
|
||||||
.onSubmit {
|
.onSubmit {
|
||||||
Task {
|
Task {
|
||||||
await saveFilter()
|
await saveFilter()
|
||||||
|
@ -164,10 +169,12 @@ struct EditFilterView: View {
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
TextField("filter.edit.keywords.add", text: $newKeyword, axis: .horizontal)
|
TextField("filter.edit.keywords.add", text: $newKeyword, axis: .horizontal)
|
||||||
|
.focused($focusedField, equals: .newKeyword)
|
||||||
.onSubmit {
|
.onSubmit {
|
||||||
Task {
|
Task {
|
||||||
await addKeyword(name: newKeyword)
|
await addKeyword(name: newKeyword)
|
||||||
newKeyword = ""
|
newKeyword = ""
|
||||||
|
focusedField = .newKeyword
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
Loading…
Reference in New Issue