SwiftlySearch
A small, lightweight UISearchController wrapper for SwiftUI.
Installation
Manual:
Update your Package.swift
file:
let package = Package(
...,
dependencies: [
.package(
url: "https://github.com/thislooksfun/SwiftlySearch.git",
from: "1.0.0"),
...
],
...
)
In Xcode:
- Go to File > Swift Packages > Add Package Depencency...
- Enter
https://github.com/thislooksfun/SwiftlySearch
as the URL - Select your desired versioning constraint
- Click Next
- Click Finish
Usage
import SwiftlySearch
struct MRE: View {
let items: [String]
@State
var searchText = ""
var body: some View {
NavigationView {
List(items.filter { $0.localizedStandardContains(searchText) }) { item in
Text(item)
}.navigationBarSearch(self.$searchText)
}
}
}