Swiftpack.co - NigelGee/AFFilterList as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by NigelGee.
NigelGee/AFFilterList 1.1.5
A Filtering List for SwiftUI
⭐️ 2
🕓 3 years ago
iOS
.package(url: "https://github.com/NigelGee/AFFilterList.git", from: "1.1.5")

AFFilterList

A Filtering List for SwiftUI

  • ☐ Would like text be hidden then show when screen pulled down slight as in the Setting menu on iPhone

Installation

Add this Swift package in Xcode using its Github repository url. (File > Swift Packages > Add Package Dependency...)

Usage

You need a collection of Identifiable data for computing the list. The filterKeys need to String but you can choose which field(s) you want to filter on.

The default placeholder is "Search" however you can change that in call.

The default SF Symbol is "magnifyingglass" however you can put any SF Symbol.

The default color of sytemImage is same as text however can be changed too.

If you want text only to show then make systemImage: nil

Example

Here is a simple example code:

import AFFilterList
import SwiftUI

struct ContentView: View {
    let data = Bundle.main.decode([Cab].self, from: "Cab.json")

    var body: some View {
        NavigationView {
            FilterList(data, filterKeys: \.title) {
                Text($0.title)
            }
            .navigationTitle("Title")
        }
        .listStyle(PlainListStyle())
    }
}![Image](https://raw.github.com/NigelGee/AFFilterList/main/README.assets/Image.gif?raw=true)

ImageAndText

Change the PlaceHolder

import AFFilterList
import SwiftUI

struct ContentView: View {
    let data = Bundle.main.decode([Cab].self, from: "Cab.json")

    var body: some View {
        NavigationView {
            FilterList(data, filterKeys: \.title, placeholder: "Enter Title",systemImage: nil) {
                Text($0.title)
            }
            .navigationTitle("Title")
        }
        .listStyle(PlainListStyle())
    }
}

TextOnly

Credit

This was base on Paul Hudson who writes Hacking with Swift. It’s available under the MIT license, which permits commercial use, modification, distribution, and private use.

I was able to do this Package with the great Video of Creating a Swift Package in Xcode from Stewart Lynch from CreaTech Solutions.

License

This package is released under the MIT License, which is copied below.

Copyright (c) 2021 Nigel Gee

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

GitHub

link
Stars: 2
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

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