Swiftpack.co - danielsaidi/DeckKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by danielsaidi.
danielsaidi/DeckKit 1.0.1
DeckKit makes it easy to create deck-based apps in SwiftUI.
⭐️ 535
🕓 1 week ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/danielsaidi/DeckKit.git", from: "1.0.1")

DeckKit Logo

Version Swift 5.9 MIT License Twitter: @danielsaidi Mastodon: @danielsaidi@mastodon.social

About DeckKit

DeckKit helps you create deck-based apps in SwiftUI. It has a DeckView that can render DeckItem collections, with support for swipe gestures, edge swipe detection, shuffling, etc.

The result can look like this or completely different:

DeckKit decks can be customized to great extent. You can change colors, fonts, corner radius etc. of the standard card views, and also use completely custom views.

Installation

DeckKit can be installed with the Swift Package Manager:

https://github.com/danielsaidi/DeckKit.git

If you prefer to not have external dependencies, you can also just copy the source code into your app.

Getting started

With DeckKit, you can create a Deck of any model that implement the DeckItem protocol:

struct Hobby: DeckItem {
    
    var name: String
    var text: String

    var id: String { name }
}

extension Deck {
    
    static var hobbies: Deck<Hobby> {
        .init(
            name: "Hobbies",
            items: [
                Hobby(name: "Music", text: "I love music!"),
                Hobby(name: "Movies", text: "I also love movies!"),
                Hobby(name: "Programming", text: "Not to mention programming!")
            ]
        )
    }
}

You can display a Deck in any of the built-in views, like a DeckView:

struct MyView: View {

    @State var deck = Deck<Hobby>.hobbies

    var body: some View {
        DeckView(deck: $deck) { hobby in
            RoundedRectangle(cornerRadius: 25.0)
                .fill(.blue)
                .overlay(Text(hobby.name))
                .shadow(radius: 10)
        }
        .padding()
        .deckViewConfiguration(
            .init(direction: .down)
        )
    }
}

For more information, please see the getting started guide.

Documentation

The online documentation has more information, articles, code examples, etc.

Demo Application

The demo app lets you explore the library on iOS and macOS. To try it out, just open and run the Demo project.

Support my work

You can sponsor me on GitHub Sponsors or reach out for paid support, to help support my open-source projects.

Contact

Feel free to reach out if you have questions or if you want to contribute in any way:

License

DeckKit is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 535
Last commit: 4 days ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

Release Notes

1 week ago

This patch adds support for visionOS and environment keys.

It also adjustes the default direction of the DeckView, from .up to .down.

✨ New features

  • DeckViewConfiguration.Key is a new environment key.
  • View has a .deckViewConfiguration modifier that you can use to apply a custom view configuration.

💡 Behavior changes

  • DeckViewConfiguration now uses .down as the default direction.

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