Giter Site home page Giter Site logo

cardstackcontroller's Introduction

CardStackController

iOS custom controller used in the Jobandtalent app to present new view controllers as cards.

This controller behaves very similar to UINavigationController, maintaining a stack of ViewControllers. The presentation of new view controllers is different though. New view controllers are presented as a new “Card” in front of the current context. The next GIFs show the control in action.

Gif from the example project supplied:

Gif from the Jobandtalent app:

Installation

Use Cocoapods to install this custom control in your project.

pod ‘CardStackController’, '~> 0.1.0’

Usage

Use the main and only public class CardStackController to present or stack new view controllers. After creating and configuring CardStackController, present it modally (it doesn’t need to be animated). Once the controller itself is presented, you can start stacking cards by calling stack(viewController:) method.

Example of usage:

cardStackController.delegate = self
cardStackController.cardScaleFactor = CGFloat(firstSlider.value)
cardStackController.firstCardTopOffset = CGFloat(secondSlider.value)
cardStackController.topOffsetBetweenCards = CGFloat(thirdSlider.value)
cardStackController.verticalTranslation = CGFloat(fourthSlider.value)
cardStackController.automaticallyDismiss = false
present(cardStackController, animated: false, completion: nil)

let root = newController()
root.delegate = self
cardStackController.stack(viewController: root)

This control is highly customisable and contains many features, among the ones we highlight:

  • The user can dismiss cards by dragging them down.
  • It is possible to tune the damping and frequency values of the presenting animation to achieve all kinds of animation curves.
  • It is possible to customise the top distance between cards, the amount each card gets resized, the size of each card…
  • There are many convenient methods to unstack cards: unstackAll, unstackUntilRoot, unstackLast, etc.

Under the hood

CardStackController uses UIKit Dynamics to present or stack cards. It creates an attachment behaviour between a card and a fix point on the screen. To prevent the card moving sideways, there is a collision behaviour between each card and the borders of the screen. Finally, there is a DynamicItem behaviour for each card to prevent rotation (this behaviour could also be used to apply density/friction/etc to them, but we didn’t find it necessary).

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

cardstackcontroller's People

Contributors

andresbrun avatar stalkerrus avatar timglorioso avatar victorbaro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cardstackcontroller's Issues

Transition snapshots

Hi,
This component is awesome. I was testing it and I get stuck trying to reload a collectionview in the original view with data added in stack view. I was debugging layers and I realize that screen snapshoots on transitions are not updated.

I was trying snapshotViewAfterScreenUpdates and all related methods but I couldn't solved it.
I'm newbie in iOS transitions, I don't know if that's correct.

Original Screen:
captura de pantalla 2017-02-06 a les 0 25 43
After add 1 player:
captura de pantalla 2017-02-06 a les 0 26 32
After add 2 player:
captura de pantalla 2017-02-06 a les 0 28 29

Thanks in advance!

iOS 10 rotation issue

When rotating to landscape, card will be show as in portrait. After closing the opened card, new one opens in correct orientation. Same goes when rotating back to portrait. First card is always messed up.

Also when I open cards on different view controller, it shows the last image of it not the current one.

Unable to read license file

Cocoapods complains:
[!] Unable to read the license file ... /Pods/CardStackController/LICENSE for the spec CardStackController (0.1.0)

Pretty sure it's because the filename has a .txt extension while the podspec specifies an extension-less file.

Because of this your awesome package isn't included in Cocoapods auto-generated acknowledgments file! :(

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.