DeckKit

0.6.0

DeckKit makes it easy to create deck-based apps in SwiftUI.
danielsaidi/DeckKit

What's New

2023-02-06T07:55:33Z

💡 New features

This version adds an additional DeckView initializer so that you don't have to specify the itemViewBuilder parameter name.

💥 Breaking Changes

  • All previously deprecated code has been removed.
  • DeckView itemViewBuilder has been renamed to itemView.

DeckKit Logo

Version Swift 5.6 MIT License Twitter: @danielsaidi

About DeckKit

DeckKit makes it easy to create deck-based apps in SwiftUI.

The result can look like this or completely different:

These decks can be customized to fit your specific needs. You can change colors, fonts, corner radius, expanded height etc. and use any views you like.

Installation

DeckKit can be installed with the Swift Package Manager:

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

or with CocoaPods:

pod DeckKit

You can also clone the repository and build the library locally.

Supported Platforms

DeckKit supports iOS 13, macOS 11, tvOS 13 and watchOS 6.

Getting started

The online documentation has a getting-started guide that will help you get started with the library.

In DeckKit, a Deck can be used to define a deck of items that implement the DeckItem protocol.

For instance, consider a Hobby type that looks like this:

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

    var id: String { name }
}

You can now create a deck with hobbies and display it in a DeckView:

struct MyView: View {

    @State
    var deck = Deck(
        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!")
        ]
    )

    var body: some View {
        DeckView(deck: $deck) {
            // Create a view for the hobby here
        }.padding()
    }
}

The DeckView takes an optional DeckViewConfiguration parameter that can be used to configure the view in various ways. You can for instance use it to control the visual direction, the number of visible items, the drag threshold before sending an item to the back of the stack etc. You can also provide additional actions that should be triggered when a card is dragged to the leading, trailing, top and bottom edges.

DeckKit has many options for managing state, additional views etc. Check the online documentation and getting-started guide for more information.

Documentation

The online documentation has articles, code examples etc. that let you overview the various parts of the library.

The online documentation is currently iOS-specific. To generate documentation for other platforms, open the package in Xcode, select a simulator then run Product/Build Documentation.

Demo Application

This project has a demo app that lets you explore the library on iOS and macOS. To try it out, just open and run Demo/Demo.xcodeproj.

Support

You can sponsor this project on GitHub Sponsors or get in touch for paid support.

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.

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Mar 30 2023 13:21:52 GMT-0500 (GMT-05:00)