Sources: Fix searchbar behavior
Cancelling the search now actually cancels the search. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
parent
52409099d7
commit
a9d2604fb3
1 changed files with 7 additions and 5 deletions
|
|
@ -40,14 +40,13 @@ struct SourcesView: View {
|
||||||
return tempSources
|
return tempSources
|
||||||
}
|
}
|
||||||
|
|
||||||
@State private var viewTask: Task<Void, Never>? = nil
|
|
||||||
@State private var checkedForSources = false
|
@State private var checkedForSources = false
|
||||||
|
|
||||||
@State private var searchText: String = ""
|
|
||||||
@State private var isEditing = false
|
@State private var isEditing = false
|
||||||
|
|
||||||
@State var filteredUpdatedSources: [SourceJson] = []
|
@State private var viewTask: Task<Void, Never>? = nil
|
||||||
@State var filteredAvailableSources: [SourceJson] = []
|
@State private var searchText: String = ""
|
||||||
|
@State private var filteredUpdatedSources: [SourceJson] = []
|
||||||
|
@State private var filteredAvailableSources: [SourceJson] = []
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavView {
|
NavView {
|
||||||
|
|
@ -128,6 +127,9 @@ struct SourcesView: View {
|
||||||
.navigationSearchBar {
|
.navigationSearchBar {
|
||||||
SearchBar("Search", text: $searchText, isEditing: $isEditing)
|
SearchBar("Search", text: $searchText, isEditing: $isEditing)
|
||||||
.showsCancelButton(isEditing)
|
.showsCancelButton(isEditing)
|
||||||
|
.onCancel {
|
||||||
|
searchText = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.onChange(of: searchText) { newValue in
|
.onChange(of: searchText) { newValue in
|
||||||
filteredAvailableSources = sourceManager.availableSources.filter { searchText.isEmpty ? true : $0.name.contains(searchText) }
|
filteredAvailableSources = sourceManager.availableSources.filter { searchText.isEmpty ? true : $0.name.contains(searchText) }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue