Created
February 3, 2020 20:45
-
-
Save artur-ios-dev/5bd32381de3e170298976d392a0d8d86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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