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:
- E-mail: daniel.saidi@gmail.com
- Twitter: @danielsaidi
- Web site: danielsaidi.com
License
DeckKit is available under the MIT license. See the LICENSE file for more info.