Giter Club home page Giter Club logo

rkswipecards's Introduction

RKSwipeCards

alt tag

This is for maximum customizability and / or learning purposes, not a pod or drop-in solution

The basics of a swipeable card interface inspired by Tinder and influenced by http://guti.in

This is meant to be taken and built off of, not as a simple drag and drop solution. New developers are often forced to use dependencies they don't understand and can't customize. This is the opposite. I've fully explained exactly how this works in detailed comments so that you can take it apart and customize it at will. For a pod/drag and drop solution, see https://github.com/modocache/MDCSwipeToChoose

Updates, Questions, and Requests

twitter <--- I am a very light twitterer, so I wont spam you

or Support

Relevant Article for deciding how to implement swipe cards into your app

https://medium.com/@cwRichardKim/adding-tinder-esque-cards-to-your-iphone-app-4047967303d1

On top of your current View Controllers

alt tag

Features:

  • Swipe cards left or right to call two separate actions
  • Have multiple cards on screen depending on the number of items in an array
  • Extremely simple, every component is explained
  • Very easily customizeable

Customizeability Examples:

action margin (the distance from the middle required for an action to take place)

alt tag alt tag

squeeze ratio (limit, strength)

alt tag alt tag

rotation (strength, limit, angle)

alt tag alt tag

+ More!

in DraggableView.h

  • ACTION_MARGIN: distance from center where the action applies. Higher = swipe further in order for the action to be called
  • SCALE_STRENGTH: how quickly the card shrinks. Higher = slower shrinking
  • SCALE_MAX: upper bar for how much the card shrinks. Higher = shrinks less
  • ROTATION_MAX: the maximum rotation allowed in radians. Higher = card can keep rotating longer
  • ROTATION_STRENGTH: strength of rotation. Higher = weaker rotation
  • ROTATION_ANGLE: Higher = stronger rotation angle

Each component is also explained thoroughly, so it is highly customizeable in many ways

How to use

files

  • ViewController.h/m: example view controller (not necessary)
  • DraggableViewBackground.h/m: UIView that holds the DraggableView. This can be put ontop of view controllers or you can set it as the main view of your view controller
  • DraggableView.h/m: UIView of the draggable cards
  • OverlayView.h/m: UIView of the X and โˆš images

Setup as View Controller (see ViewController.m)

DraggableViewBackground *draggableBackground = [[DraggableViewBackground alloc]initWithFrame:self.view.frame];
[self.view addSubview:draggableBackground];

Setup as UIView ontop of View Controller

CGRect frame = self.view.frame;
frame.origin.y = -self.view.frame.size.height; //optional: if you want the view to drop down
DraggableViewBackground *draggableBackground = [[DraggableViewBackground alloc]initWithFrame:frame];
draggableBackground.alpha = 0; //optional: if you want the view to fade in

[self.view addSubview:draggableBackground];

  //optional: animate down and in
[UIView animateWithDuration:0.5 animations:^{
    draggableBackground.center = self.view.center;
    draggableBackground.alpha = 1;
}];

Presenting Your Data

Loading Data

  • edit -(void)loadCards in DraggableViewBackground.m to dictate what information is loaded and how

  • "allCards" holds all the cards you want to show, "loadedCards" only shows the first few so that it doesn't load everything at once.

  • if card data is loaded after initWithFrame, then make sure the data is included in your custom data array (currently "exampleCardLabels") at the index: yourIndex and then write the code:

    DraggableView* newCard = [self createDraggableViewWithDataAtIndex:yourIndex];
    [allCards addObject:newCard];

    whenever you need to.

  • I used exampleCardLabels as an example of how to load data, but feel free to change that

Presenting Data in View

  • Customize the presentation of your data in -(DraggableView *)createDraggableViewWithDataAtIndex:(NSInteger)index in DraggableViewBackground.m (eg: make certain data appear on labels or photos in custom UIImageViews)
  • to access any card directly, use [loadedCards objectAtIndex:yourIndex]; For example, the card that is currently visible is at [loadedCards firstObject];

Looking for certain features?

Areas for Future Improvement / Involvement

  • Too much happening in a view (DraggableViewBackground)
  • Improved naming (while maintaining legacy and / or easy directions for change)

Change Log

  • May 28, 2017 - Take down notice issued from Tinder, changed naming and various references

rkswipecards's People

Contributors

cwrichardkim avatar jaredmoskowitz avatar bryant1410 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.