QuickSearch lets type into a searchable text fields by typing on the keyboard without first having to focus on the text field.
QuickSearch can be enabled by applying a quickSearch
modifier to a view hierarchy that contains a .searchable
view modifier:
struct ContentView: View {
@State
var query = ""
@State
var text = ""
@FocusState
var isTextFieldFocused
var body: some View {
NavigationStack {
VStack {
TextField("Type here...", text: $text)
}
.quickSearch(text: $query)
.searchable(text: $query)
}
}
}
When the app launches, the user can now start typing on the keyboard without first focusing on the search text field.
QuickSearch can be installed with the Swift Package Manager:
https://github.com/danielsaidi/QuickSearch.git
If you prefer to not have external dependencies, you can also just copy the source code into your app.
You can sponsor me on GitHub Sponsors or reach out for paid support, to help support my open-source projects.
Feel free to reach out if you have questions or if you want to contribute in any way:
- Website: danielsaidi.com
- Mastodon: @danielsaidi@mastodon.social
- Twitter: @danielsaidi
- E-mail: daniel.saidi@gmail.com
QuickSearch is available under the MIT license. See the LICENSE file for more info.