Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
struct SearchView: View {
let array = "SwiftUI is great but some views might need an extra work".components(separatedBy: " ")
@State private var searchText = ""
var body: some View {
VStack {
SearchBar(text: $searchText)
List {
ForEach(array.filter{$0.hasPrefix(searchText) || searchText == ""}, id:\.self) {
searchText in Text(searchText)
}
}
.gesture(DragGesture().onChanged { _ in
UIApplication.shared.endEditing(true)
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.