Swiftpack.co - scr037/SearchableList as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by scr037.
scr037/SearchableList 1.0
A convenience modifier that adds a UISearchBar on top of a SwiftUI List and allows filtering its content with a query (a binding string).
⭐️ 1
🕓 2 weeks ago
iOS
.package(url: "https://github.com/scr037/SearchableList.git", from: "1.0")

SearchableList

Description

A convenience modifier that adds a UISearchBar on top of a SwiftUI List and allows filtering its content with a query (a binding string).

Description

The SearchableList relies on ViewModifier and UIViewRepresentable (accessible only through lists using .searchable(query:)) in order to allow users to easily filter the list`s content.

Usage

struct ExampleView: View {
  @State private var query: String = ""

  var body: some View {
    List {
      ForEach(TestFruits.allCases, id: \.self) {
        if query != "" {
          if $0.rawValue.contains(query) {
            Text($0.rawValue)
          }
        } else {
          Text($0.rawValue)
        }
      }
    }
    .searchable(query: $query)
  }
}

Preview

Looking for Starks

No Filter Filter
testSearchableListNoFilter 1 testSearchableListWithFilter 1

GitHub

link
Stars: 1
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

0.1.0
2 weeks ago

Publish SearchableList

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics