Poi - You can use tinder UI like tableview method

Related tags

Animation Poi
Overview

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.

You might also like...
Numbers animation allows you to click on different numbers and accordingly it will animate numbers in a cool way. It has a very attractive UI and is very easy to use.
Numbers animation allows you to click on different numbers and accordingly it will animate numbers in a cool way. It has a very attractive UI and is very easy to use.

Numbers Animation Cool Numbers Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.
Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.

Reading Animation Cool Reading Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions
Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions. Every animation is randomized. Currently supported animations:

Each step you take reveals a new horizon. You have taken the first step today.
Each step you take reveals a new horizon. You have taken the first step today.

The story Seeing the animations behind Paper, or the transitions behind Mail, being in a world of flat design and transitions, user interaction, app b

WifiView Pod can animate wifi signal strength
WifiView Pod can animate wifi signal strength

WifiView WifiView is animateable UIView that can significantly enhance your users’ experiences and set your app apart from the rest of the pack. It is

A lightweight loading animation that can be applied to any SwiftUI view with 1 line of code.

SimpleAFLoader A lightweight loading animation that can be applied to any SwiftUI view with 1 line of code. All animations are built using the SwiftUI

🎨 Gradient animation effect like Instagram
🎨 Gradient animation effect like Instagram

Pastel 🎨 Gradient animation effect like Instagram Example override func viewDidLoad() { super.viewDidLoad() let pastelView = PastelView(fram

Bring life to CALayers with SpriteKit-like animation builders
Bring life to CALayers with SpriteKit-like animation builders

Animo Bring life to CALayers with SpriteKit-like animation builders. Why use Animo? Because declaring CAAnimations (especially with CAAnimationGroups)

FloatingBubbles is a customizable views that float like zero gravity animation.
FloatingBubbles is a customizable views that float like zero gravity animation.

Floating Bubbles FloatingBubbles is a customizable views that float like zero gravity animation. $ pod try FloatingBubbles Features Create Multiple V

Comments
  • reloadData() method

    reloadData() method

    Hello,

    I have tested your Poi framwork in one of my project and it is very easy to use!

    Howewere, I was trouble that there is no reloadData() method in order to be similar to a UITableView or UICollectionView. I think it could be a good feature to add.

    Regards.

    opened by iMac0de 1
Releases(3.1.1)
Owner
I'm iOS engineer at Mercari. Passionate about iOS & open source.
null
API to make great custom transitions in one method

AZTransitions Make your modal transition with custom animation. AZTransitions helps you think about creativity, giving specific API methods. Visual Ex

Alexander 418 Aug 4, 2022
Fluid - Use a declarative syntax to build your user interface using UIKit like SwiftUI

Fluid Fluid is powered by ResultBuilder and a custom layout engine. You can uses

HZ.Liu 13 Dec 9, 2022
Design-system-demo - This example code is bare-bones to show you what this framework can do

Basic Style Dictionary This example code is bare-bones to show you what this fra

Tylen St Hilaire 0 Feb 3, 2022
jasu 29 Dec 20, 2022
Protoyping-Project WallAngle - With this App, you can measure the angle without searching for tools and calculations

Protoyping-Project_WallAngle This is the App that I made for the Prototyping Pro

null 1 Apr 4, 2022
You can dismiss modal by using gesture

RPModalGestureTransition You can dismiss modal by using gesture. Usage 1.Define animation You define animator class inherits UIViewControllerAnimatedT

Naoya Sugimoto 90 Apr 21, 2020
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
Letters animation allows you to click on different letters and accordingly it will animate letters in a cool way. It has a very attractive UI and is very easy to use.

Letters Animation Cool Letters Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MindInventory 31 Oct 4, 2022