Skip to content

Instantly share code, notes, and snippets.

@artur-ios-dev
Created February 3, 2020 20:45
Show Gist options
  • Save artur-ios-dev/5bd32381de3e170298976d392a0d8d86 to your computer and use it in GitHub Desktop.
Save artur-ios-dev/5bd32381de3e170298976d392a0d8d86 to your computer and use it in GitHub Desktop.
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