Latest 0.0.4
Homepage https://github.com/gkye/Swiper
License MIT
Platforms ios 9.0
Dependencies Stellar, PeekView
Frameworks UIKit
Authors

UIView sublass for creating Tinder like swipe cards, with a peek view.

codebeat badge
Version
License
Platform

TODO

  • [ ] Fix reloading/bump spec

Demo

Installation

Swiper is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'Swiper'

Usage

Check out the demo app for a detailed example.

Adding Swiper View

A Swiper view can be added via storyboard or programmatically

var swiperView = Swiper(frame: CGRect(x: 0, y: 0, width: 350, height: 350)))
view.addSubview(swiperView)
swipeView.delegate = self
swipeView.dataSource = self

Protocols

DataSource

Returns the images to be displayed within the Swiper view.

public func cardData() -> [SwiperData]

Returns the number of items to be displayed by the Swiper view.

public func numberOfCards()->Int

Delegate

Method is called when the Swiper view is first display and each time a swipe actions occurs. Returns the current index of the card and its dataSource

 func didShowCardAtIndex(swiper: Swiper, index: Int, dataSource: SwiperData)

Method is called when the Swiper view is swipped left or programtically undoSwipe. Returns the current index of the card and its dataSource

 func didUndoAction(swiper: Swiper, index: Int, dataSource: SwiperData)

Method is called when the Swiper view is tapped. Returns the current index of the card of the current item

 func didSelectCardAtIndex(swiper: Swiper, index: Int)

Method is called when the Swiper view is no more items to be displayed from its current dataSource

  func cardsDidRunOut(swiper: Swiper, status: Bool)

Controlling SwiperView

Swiper supports both right and left swipe actions. Swiper Right to move to the next card and Swipe left to undo an action.
These actions are also supported programtically.

public func swipeToNext()
public func undoSwipe()

Reloads the Swiper views items from its current dataSource and refreshes display.

public func reloadData()

Using the PeekView

Must the peekViewEnabed = true and conform to the peekViewDelegate in order to use the PeekView

    swipeView.peekViewEnabled = true
    swipeView.peekViewDelegate = self

PeekView Attributes

In order for the peekView to function a parentViewController and contentViewController must be set (actions are optional). Below is an example.

func swiperPeekViewAttributes() -> SwiperPeekViewAttributes {
    let controller = storyboard?.instantiateViewControllerWithIdentifier("PeekViewController") as! PeekViewController
    controller.image = imgs[currentIndex].image
    controller.labelText = imgs[currentIndex].title

    let actions = [
      PeekViewAction(title: "Like", style: .Selected),
      PeekViewAction(title: "Show Details", style: .Default),
      PeekViewAction(title: "Cancel", style: .Destructive) ]
    let attributes = SwiperPeekViewAttributes.init(parentVC: self, contentVC: controller, actions: actions)
    return attributes
  }

Handling PeekView actions

Returns the selected index of selected action from the PeekView

func swiperPeekViewDidSelectAtionAtIndex(index: Int)

Dependencies

License

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

Latest podspec

{
    "name": "Swiper",
    "version": "0.0.4",
    "summary": "UIView sublass for creating Tinder like swipe cards.",
    "description": "UIView sublass for creating Tinder like swipe cards, with a peek view.",
    "homepage": "https://github.com/gkye/Swiper",
    "license": "MIT",
    "authors": {
        "George Kye": "[email protected]"
    },
    "source": {
        "git": "https://github.com/gkye/Swiper.git",
        "tag": "0.0.4"
    },
    "social_media_url": "https://twitter.com/kyegeorge",
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "Sources/**/*",
    "frameworks": "UIKit",
    "dependencies": {
        "Stellar": [],
        "PeekView": []
    }
}

Pin It on Pinterest

Share This