QuickSearch
QuickSearch copied to clipboard
QuickSearch is a SwiftUI SDK that lets you type into a searchable text field without first having to focus on it.
About QuickSearch
QuickSearch is a SwiftUI SDK that lets you type into a .searchable text field without first having to focus on it, which is how many native utilty apps behave.
This is convenient, since .searchable text fields lack focus control and doesn't allow you to focus programmatically.
Installation
QuickSearch can be installed with the Swift Package Manager:
https://github.com/danielsaidi/QuickSearch.git
Getting Started
All you have to do to make QuickSearch work, is to apply a .quickSearch view modifier after .searchable:
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)
}
}
}
If you can add .quickSearch directly next to .searchable, you can use .searchable(text:quickSearch:...) instead. It is not as flexible as .searchable, but works well to apply basic .searchable capabilities.
For more information, please see the documentation.
Documentation
The online documentation has more information, articles, code examples, etc.
Demo Application
The demo app lets you explore the library. To try it out, just open and run the Demo project.
Support my work
You can sponsor me on GitHub Sponsors or reach out for paid support, to help support my open-source projects.
Your support makes it possible for me to put more work into these projects and make them the best they can be.
Contact
Feel free to reach out if you have questions or want to contribute in any way:
- Website: danielsaidi.com
- Mastodon: @[email protected]
- Twitter: @danielsaidi
- E-mail: [email protected]
License
QuickSearch is available under the MIT license. See the LICENSE file for more info.