ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - HideakiTouhara/Poi
Contribute to HideakiTouhara/Poi development by creating an account on GitHub.
Visit Site

GitHub - HideakiTouhara/Poi

GitHub - HideakiTouhara/Poi

Poi

Pod version Carthage compatible MIT License Swift 4.0.x

You can use tinder UI like tableview method

demo1

Installation

Manual Installation

  1. Use this command
git clone [email protected]:HideakiTouhara/Poi.git
  1. Import Poi.xcodeproj to your project

direct_import1

  1. Add Poi.frameworkiOS to Embedded Binaries

direct_import2

Cocoa Pods

Please write the below code in Podfile

pod ‘Poi’

Carthage

Write this code in your Cartfile.

github "HideakiTouhara/Poi"

and implement this command

carthage update

Add Poi.framework in /Carthage/Build/iOS/ to Embedded Binaries.

carthage_import

Usage

Create PoiView in storyboard or swift file

import Poi

@IBOutlet weak var poiView: PoiView!
// Change View's class to PoiView in Attributes inspector.

or

import Poi

let poiView = PoiView()
self.view.addSubView(poiView)

Conform to PoiViewDataSource and PoiViewDelegate

class ViewController: UIViewController, PoiViewDataSource, PoiViewDelegate {

Designate delegate target.

Please put this code after setting card contents.

poiView.dataSource = self
poiView.delegate = self

PoiViewDataSource method

Set swipeable card number(required method)

func numberOfCards(_ poi: PoiView) -> Int

Set swipeable card(required method)

func poi(_ poi: PoiView, viewForCardAt index: Int) -> UIView

Set overlay image if right or left swiped

func poi(_ poi: PoiView, viewForCardOverlayFor direction: SwipeDirection) -> UIImageView? {
    switch direction {
    case .right:
        return UIImageView(image: #imageLiteral(resourceName: "good"))
    case .left:
        return UIImageView(image: #imageLiteral(resourceName: "bad"))
    }
}

PoiViewDelegate method

When did swipe, this method is called

func poi(_ poi: PoiView, didSwipeCardAt: Int, in direction: SwipeDirection)

When last card was swiped, this method is called

func poi(_ poi: PoiView, runOutOfCardAt: Int, in direction: SwipeDirection)

Public method

Swipe current card

func swipeCurrentCard(to direction: SwipeDirection)

Undo animation and go back previous card

func undo()

Example

Check the Example file!

import UIKit
import Poi

class ViewController: UIViewController, PoiViewDataSource, PoiViewDelegate {

    @IBOutlet weak var poiView: PoiView!

    var sampleCards = [UIView]()

    override func viewDidLoad() {
        super.viewDidLoad()
        var colors = [UIColor.red, UIColor.orange]
        for i in (0..<2) {
            sampleCards.append(UIView(frame: CGRect(x: 0, y: 0, width: 240, height: 128)))
            sampleCards[i].backgroundColor = colors[i]
        }
        poiView.dataSource = self
        poiView.delegate = self
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    // MARK: PoiViewDataSource
    func numberOfCards(_ poi: PoiView) -> Int {
        return 2
    }

    func poi(_ poi: PoiView, viewForCardAt index: Int) -> UIView {
        return sampleCards[index]
    }

    func poi(_ poi: PoiView, viewForCardOverlayFor direction: SwipeDirection) -> UIImageView? {
        switch direction {
        case .right:
            return UIImageView(image: #imageLiteral(resourceName: "good"))
        case .left:
            return UIImageView(image: #imageLiteral(resourceName: "bad"))
        }
    }

    // MARK: PoiViewDelegate
    func poi(_ poi: PoiView, didSwipeCardAt: Int, in direction: SwipeDirection) {
        switch direction {
        case .left:
            print("left")
        case .right:
            print("right")
        }
    }

    func poi(_ poi: PoiView, runOutOfCardAt: Int, in direction: SwipeDirection) {
        print("last")
    }

    // MARK: IBAction
    @IBAction func OKAction(_ sender: UIButton) {
        poiView.swipeCurrentCard(to: .right)
    }

    @IBAction func undo(_ sender: UIButton) {
        poiView.undo()
    }
}

Contribution

Please create issues or submit pull requests for anything.

License

Poi is released under the MIT license.

© 2018 GitHub, Inc.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory