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

Overview

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.

Comments
  • Transition snapshots

    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!

    opened by oscarbc96 2
  • Remove snapshot image on controller dismissal

    Remove snapshot image on controller dismissal

    This fixes #5. Admittedly haven't tested it too thoroughly, but it's a pretty straightforward fix. Forgot to use a topic branch, hopefully that's okay!

    opened by timglorioso 1
  • Unable to read license file

    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! :(

    opened by timglorioso 1
  • Carthage support

    Carthage support

    opened by TofPlay 1
  • fix: unstack all completion

    fix: unstack all completion

    The completion block passed to API method unstackAllViewControllers(completion:) wasn't getting passed along to private method unstack(viewControllers:completion:), so this is just a minor fix for that.

    opened by timglorioso 0
  • fix: remove snapshot view on controller dismissal

    fix: remove snapshot view on controller dismissal

    These changes are identical to #8, just using a topic branch as per best practices. Fixes #5.

    Worth noting you can witness #5 in action in the README gif when the slider values flash after card dismissal!

    Thanks again for such an awesome package ❤️

    opened by timglorioso 1
  • iOS 10 rotation issue

    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.

    enhancement 
    opened by akotulu 7
Owner
jobandtalent
jobandtalent
A controller that uses a UIStackView and view controller composition to display content in a list

StackViewController Overview StackViewController is a Swift framework that simplifies the process of building forms and other static content using UIS

Seed 867 Dec 27, 2022
DrawerKit lets an UIViewController modally present another UIViewController in a manner similar to the way Apple's Maps app works.

DrawerKit What is DrawerKit? DrawerKit is a custom view controller presentation mimicking the kind of behaviour in the Apple Maps app. It lets any vie

Babylon Health 773 Dec 27, 2022
A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI.

BetterSafariView A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI. Contents Motivation Requirements U

Dongkyu Kim 392 Dec 31, 2022
UIViewController subclass to beautifully present news articles and blog posts.

LMArticleViewController This framework allows you to create Apple News-inspired UIViewControllers with ease. It is heavily inspired by MRArticleViewCo

Luca Mozzarelli 7 Feb 3, 2022
BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen

BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen. It is especially well

Alexis (Aubry) Akers 5.3k Jan 2, 2023
Wallet is a library to manage cards and passes.

Wallet Wallet is a replica of the Apple's Wallet interface. Add, delete or present your cards and passes. Feel free to use this pod in your project an

Russ St Amant 360 Feb 4, 2022
Provides an iOS view controller allowing a user to draw their signature with their finger in a realistic style.

Swift version now available! Mimicking pen-on-paper signatures with a touch screen presents a difficult set of challenges. The rate touch events are e

Uber Open Source 1.3k Jan 6, 2023
Meet Page View Controller for iOS by Cleveroad

While a standard page view allows you to navigate between pages by using simple gestures, our component goes further

Cleveroad 397 Aug 20, 2022
This widget displays a weight and a label. It can be used in the summary view for a strength assessment.

Strength Assessment Widget - Flutter Modern UI engineering is all about components. When we build components to be reusable, we enable faster iteratio

null 1 Feb 18, 2022
A library, which adds the ability to hide navigation bar when view controller is pushed via hidesNavigationBarWhenPushed flag

HidesNavigationBarWhenPushed A library, which adds the ability to hide navigation bar when view controller is pushed via hidesNavigationBarWhenPushed

Danil Gontovnik 55 Oct 19, 2022
A set of UIKit helpers that simplify the usage of UIKit view's and controller's in SwiftUI.

A set of UIKit helpers that simplify the usage of UIKit view's and controller's in SwiftUI. Many of these helpers are useful even in a pure UIKit project.

SwiftUI+ 6 Oct 28, 2022
Page view controller with bounce effect

BouncyPageViewController Page view controller with bounce effect inspired by motion design by Stan Yakushevish. Quickstart Create a queue of UIViewCon

Bohdan Orlov 843 Oct 17, 2022
ElongationPreview is an elegant UI push-pop style view controller

ElongationPreview is an elegant UI push-pop style view controller

Ramotion 886 Dec 19, 2022
📖 A simple, highly informative page view controller

TL;DR UIPageViewController done properly. ⭐️ Features Simplified data source management & enhanced delegation. Dynamically insert & remove pages. Infi

UI At Six 1.8k Dec 24, 2022
A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView and iPhone X safe area support for content reloading. Built for iOS 10 and later.

Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f

Putra Z. 43 Feb 4, 2022
A SwiftUI bottom-up controller, like in the Maps app. Drag to expand or minimize.

SwiftUI Drawer A SwiftUI bottom-up controller, like in the Maps app. Drag to expand or minimize. Contents Add the Package Basic Usage Examples Credits

Michael Verges 695 Jan 3, 2023
Pull up controller with multiple sticky points like in iOS Maps

PullUpController Create your own pull up controller with multiple sticky points like in iOS Maps Features Multiple sticky points Landscape support Scr

Mario Iannotta 1.2k Dec 22, 2022
Blobmorphism is a brand new design language I've created to break free of the material overload in iOS, built in SwiftUI. Everything feels smooth and fluid.

Blobmorphism is a brand new design language I've created to break free of the material overload in iOS, built in SwiftUI. Everything feels smooth and fluid.

Ethan Lipnik 89 Nov 29, 2022