Coder Social home page Coder Social logo

alphabetscrollbar's Introduction

AlphabetScrollBar

AlphabetScrollBar is a SwiftUI package that provides a reusable view for displaying collections of items in an alphabetized manner. It allows you to present the collection either as a List or a Grid, with section headers representing the alphabet index.

Features

  • Alphabetically group items in the collection.
  • Display the collection as a List or a Grid with alphabet headers.
  • Easy to use and customizable with your own cell views.

Requirements

  • Swift 5.3+
  • iOS 15.0+

Installation

You can add AlphabetizedList to your project using Swift Package Manager. To add it, follow these steps:

  1. In Xcode, open your project or workspace.
  2. Go to File > Swift Packages > Add Package Dependency.
  3. Enter the repository URL: (https://github.com/Salubrejoe/AlphabetScrollBar.git).
  4. Click Next, then select the version rule you want to use.
  5. Click Finish.

Usage

To use AlphabetizedList in your SwiftUI project, follow these steps:

  1. Import the package:
import SwiftUI
import AlphabetScrollBar

Conform your model type to the Alphabetizable protocol:



struct Country: Alphabetizable {
    var id: String { self.name }
    let name: String
}

Create an instance of the AlphabetizedList view:



let countries: [Country] = [
    // ... your collection of Country instances ...
]

var body: some View {
    AlphabetizedList(
        collectionDisplayMode: .asList, // or .asGrid
        collection: countries,
        sectionHeaderFont: .headline,
        sectionHeaderForegroundColor: .primary,
        resultAnchor: .top,
        cell: { country in
            // Customize your cell view here based on the 'Country' model.
            Text(country.name)
        }
    )
}

Licence

Customize the appearance by adjusting the sectionHeaderFont, sectionHeaderForegroundColor, and the cell view. License

This package is distributed under the MIT License. See LICENSE for more information.

Acknowledgments

The AlphabetizedList package was inspired by the need for an easy-to-use SwiftUI view to display alphabetically sorted collections.

Contributing

Contributions are welcome! If you have any bug reports, feature requests, or suggestions, please open an issue or submit a pull request.

alphabetscrollbar's People

Contributors

salubrejoe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.