Skip to content

A small, lightweight UISearchController wrapper for SwiftUI

License

Notifications You must be signed in to change notification settings

supertrouper/SwiftlySearch

 
 

Repository files navigation

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:

  1. Go to File > Swift Packages > Add Package Depencency...
  2. Enter https://github.com/thislooksfun/SwiftlySearch as the URL
  3. Select your desired versioning constraint
  4. Click Next
  5. 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)
    }
  }
}

About

A small, lightweight UISearchController wrapper for SwiftUI

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 100.0%