I have data in row like Text(data.user)
and I want to use searchable for it, I can use search bar, bat I want to use filter for user.
Text(data.user)
.searchable(text: $searchText, placement: .navigationBarDrawer)
like here, tere is some example for filter, but how can I use it for my data. Any idea?
.onChange(of: searchText) { searchText in
if !searchText.isEmpty {
articles = sampleArticles.filter { $0.title.contains(searchText) }
} else {
articles = sampleArticles
}
}