Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/d-32/dmswipecards
🃏 Tinder like card interface
https://github.com/d-32/dmswipecards
cards generic ios swift ui
Last synced: 6 days ago
JSON representation
🃏 Tinder like card interface
- Host: GitHub
- URL: https://github.com/d-32/dmswipecards
- Owner: D-32
- License: mit
- Created: 2016-12-18T12:30:56.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-21T03:07:55.000Z (over 5 years ago)
- Last Synced: 2024-10-26T20:34:14.333Z (20 days ago)
- Topics: cards, generic, ios, swift, ui
- Language: Swift
- Homepage:
- Size: 218 KB
- Stars: 253
- Watchers: 9
- Forks: 31
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Version](https://img.shields.io/cocoapods/v/DMSwipeCards.svg?style=flat)](http://cocoadocs.org/docsets/DMSwipeCards)
![License](https://img.shields.io/cocoapods/l/DMSwipeCards.svg?style=flat)
[![twitter: @dylan36032](http://img.shields.io/badge/twitter-%40dylan36032-blue.svg?style=flat)](https://twitter.com/dylan36032)![image](screenshot_1482145004.png)
## Features
- Swift 3
- Custom views for the card & overlay
- Generic
- Dynamically add new cards on top or on the bottom
- Lazy view loading## Setup
```ruby
pod 'DMSwipeCards'
```## Usage
First import the module:
```swift
import DMSwipeCards
```Next create an instance of a `DMSwipeCardsView`:
(`Element` can be your custom model, or just `String`)
```swift
let swipeView = DMSwipeCardsView(frame: frame,
viewGenerator: viewGenerator,
overlayGenerator: overlayGenerator)
```
Views get loaded lazy, so you have to provide `DMSwipeCardsView` with a ViewGenerator and optionally an OverlayGenerator.
```swift
let viewGenerator: (String, CGRect) -> (UIView) = { (element: Element, frame: CGRect) -> (UIView) in
// return a UIView here
}let overlayGenerator: (SwipeMode, CGRect) -> (UIView) = { (mode: SwipeMode, frame: CGRect) -> (UIView) in
// return a UIView here
}
```
### Adding cardsTo add new cards, just call the `addCards` method with an array of the previously defined `Element`:
```swift
swipeView.addCards([Element], onTop: true)
```
### Delegate`DMSwipeCardsView` has a delegate property so you can get informed when a card has been swipped. The delegate has to implement following methods:
```swift
func swipedLeft(_ object: Any)
func swipedRight(_ object: Any)
func cardTapped(_ object: Any)
func reachedEndOfStack()
```
The `object` parameter is guarenteed to have the type `Element`. Sadly generics don't work here.## Example
For a nice working demo sample, please take a look the [Example](https://github.com/D-32/DMSwipeCards/tree/master/Example) project.
To run the example, first run `pod install` in the `Example` directory.## Credits
Loosly based on [TinderSimpleSwipeCards](https://github.com/cwRichardKim/TinderSimpleSwipeCards)