Card-based view controller for apps that display content cards with accompanying maps, similar to Apple Maps.

Overview

TripGo Card View Controller

This is a repo for providing the card-based design for TripGo as well as the TripKitUI SDK by SkedGo.

Specs

1. Basic functionality of cards

Behaviour:

  • Card positions (!3):
    1. collapsed: Only shows header of card
    2. peaking: Shows half of card's content and the map content
    3. extended: Shows card fully, map shows a little bit on top but is greyed out
  • Pushing a card from another card
    • Adds (x) button unless it’s the root card
    • Card has a preferred position which is used when pushing (!3)
    • Animation: Slide up from the bottom; fading black view on card below with alpha from 0% to 25%
    • Pass on appearance callbacks appropriately to involved cards
  • Popping a card
    • Tap (x) to pop card
    • When popping top card, restore card position of card below when something got pushed on it (!3)
    • Animation: Slide back down; fading out black view on card below with alpha from 25% to 0%
    • Pass on appearance callbacks appropriately to involved cards
  • Cards are draggable
    • Snap to collapsed (only title), peaking (near half-way showing both map and card content), extended (still shows a bit of the map on top, but darkened) (!3)
    • Cards can be dragged up and down anywhere on the card
    • Tap title when collapsed: go to peaking (!3)
    • Tap title when peaking: go to extended (!3)
    • Tap title when extended: do nothing
    • Tap map when extended: go to peaking (!3)
  • Cards are scrollable
    • Cards typically have scrolling content: when scrolling down the card's header stays at the top and a bit of the map still keeps peaking through at the top.
    • When scrolling down show a thin separator line between the card's scrolling content and the card's header (!18)
    • When scrolling to the top and keeping to scroll, start dragging card (!12)

Styles:

  • Animation curve for push and pop (!1)
  • Blurry view under status bar (like Maps app) (!1)
  • When rotating device and card is collapsed, make sure card ends up in correct position (!1)

2. Card content and gestures

Card types:

  • Plain card
    • On top: Title, (x), optional subtitle and optional accessory view
    • Add accessory view (!11)
    • Content can be scrollable and size adjusts to content. If it fits, it shouldn’t be scrollable
    • Add optional floaty button (!14)
  • Table card
    • Same as plain card, but with a table view as its content
    • Allow specifying plain (e.g., for departures) or grouped style (e.g., for profile) (!13)
  • Collection card
    • Same as plain card, but with a collection view as its content
    • Allow specifying collection view layout
  • Paging card (!5)
    • Handles list of child cards on the same hierarchical level which can be paged programatically and through gestures
    • Has header view: Used for titles (child cards shouldn't show them then) and navigation; Header view is separate from sticky bar, i.e., you can have both.
    • Re-uses the top card's map manager
    • Pass on appearance callbacks appropriately to child cards

Card styles:

  • Rounded corners to cards (!2)
  • Grab handle for cards (!2)
  • Nice close buttons (and next button for paging cards) (!5)
  • Title and subtitle styling
  • Add mini drop shadow to card views (!2)
  • Bottom view (!4)

3. Map content

Map content:

  • Cards can optionally have map content
  • When showing the content, the insets should be respected to account for the card overlapping the map
  • If there’s no map content: Show card always extended and don't allow dragging it down (or just snap back up when using tries) (!3)

Map buttons:

  • Optional list of buttons that float on the right above the card or in the top right corner (when collapsed or peaking) (!27)
  • When dragging up the card to extended, the buttons fade away (!27)

4. Large width (iPad + iPhone in landscape)

  • Move card to the side with min (iPhone Plus) and max (iPad) width (!9)
  • Make sure transitions work when changing size and traits (!9)

5. UIKit features

  • State restoration
  • VoiceOver Accessibility (!38)
  • NSUserActivity
  • Keyboard shortcuts (#30)

Installation and usage

Install

Via CocoaPods:

  1. Check out the repo and make it accessible to your project, e.g., as a git submodule

  2. Add it to your Podfile, e.g.:

    pod 'TGCardViewController', path: 'Libraries/TGCardViewController'

  3. Run pod update

Via Carthage

  1. Add it to your Cartfile, e.g.:

    git "[email protected]:SkedGo/tripgo-cards-ios.git" "master"

  2. Run carthage update and follow the usual instructions to add it to your project.

Add it to your app

  1. Create a TGCardViewController subclass and use it in your storyboard

  2. Override init(coder:) so that the instance from the storyboard isn't used, but instead TGCardViewController.xib:

    import TGCardViewController
    
    class CardViewController: TGCardViewController {
    
      required init(coder aDecoder: NSCoder) {
        // When loading from the storyboard we don't want to use the controller
        // as defined in the storyboard but instead use the TGCardViewController.xib
        super.init(nibName: "TGCardViewController", bundle: TGCardViewController.bundle)
      }
    
      ...
    }
  3. Create a TGCard subclass, that represents the card at the top level, and add then push that in your view controller's viewDidLoad:

      override func viewDidLoad() {
        rootCard = MyRootCard()
        super.viewDidLoad()
      }

End-user documentation

Keyboard shortcuts

  • Card controller
    • ⌃+↑: Expand card
    • ⌃+↓: Expand/collapse card
    • ⌘+w: Pop card or dismiss modal
  • Table view cards
    • ↑: Highlight previous item
    • ↓: Highlight next item
    • ⌘+↑: Highlight item at start of list
    • ⌘+↓: Highlight item at end of list
    • Space or enter: select item
    • Esc: deselect
  • Paging cards
    • ⌃+←: Previous card
    • ⌃+→: Next card
Comments
  • Xcode13

    Xcode13

    Updates for Xcode 13:

    • @MainActor annotations
    • Remove deprecated state restoration -- use UserActivities instead
    • Remove Bundle.cardVC in favour of Bundle.module and TGCardViewController.bundle
    • Now requires iOS 13

    Some project clean-ups

    opened by nighthawk 2
  • Remove deprecated state restoration

    Remove deprecated state restoration

    Follow up to #7, as state restoration was only half implemented and no longer actively supported. Better for user of the library to instead restore manually based on NSUserActivity.

    opened by nighthawk 1
  • Safe area for the map view

    Safe area for the map view

    This PR restructured TGCardVC slightly to have the map view in its own VC with, critically, its own safe area. The safe area is the visible part of the map when the card VC is in collapsed or peaking mode.

    This fixes the positioning of the attribution and legal label when used with MKMapView, and it fixes setting the centre location of the map or taking the map into tracking mode when the card is in peaking mode.

    Additional changes:

    • When the card is extended the map is made non-interactive to disable it from surfacing any VoiceOver from underneath the extended card.
    • Removes the need for manually handling edgePadding when using the MKMapView-based TGMapManager.

    Bugs to address:

    • [x] The maps attribution label jumps to its new position when tapping to expand
    • [x] Doesn't deal with card header properly (e.g., "Show pages" in example)
    • [x] Wrong map safe area on first load
    • [x] Wrong left map safe area on iPad in landscape
    opened by nighthawk 1
  • RTL-support

    RTL-support

    Adds right-to-left language support, in particular adjusting:

    • [x] Ordering page cards right to left, i.e., card at index 0 is right-most and "forward" moves left
    • [x] Adjusting map offset when the card is floating on the right
    opened by nighthawk 0
  • VoiceOver fixes

    VoiceOver fixes

    • Don't trigger paging to a different card using voice over; only the current card is "accessible" and when using voice over you have to page manually (e.g., by using a page control), but not by scrolling through the pages.
    • Don't read out hidden elements when card is extended
    opened by nighthawk 0
  • Table card unable to scroll to the bottom

    Table card unable to scroll to the bottom

    It seems the introduction of TGMapViewController and the work with additional safe area inset broke the previous fix on table view's content inset. On both devices with and without the physical Home button, table view cannot scroll to the very bottom.

    opened by pnuts2 0
Releases(2.2.2)
  • 2.2.2(Aug 31, 2022)

  • 2.2.1(Aug 30, 2022)

    • Add cardTitleHeightDidChanged for dynamic card title height

    Full Changelog: https://github.com/skedgo/TGCardViewController/compare/2.2.0...2.2.1

    Source code(tar.gz)
    Source code(zip)
  • 2.2.0(Aug 14, 2022)

    What's Changed

    • Allow specifying multiple interactive frames, not just one (TGInteractiveCardTitle had a change to its requirement!)
    • Documentation update and add .spi.yml by @nighthawk in https://github.com/skedgo/TGCardViewController/pull/13

    Full Changelog: https://github.com/skedgo/TGCardViewController/compare/2.1.2...2.2.0

    Source code(tar.gz)
    Source code(zip)
  • 2.1.1(Jan 30, 2022)

    What's Changed

    • Force 1-20 range for zoom level by @nighthawk in https://github.com/skedgo/TGCardViewController/pull/12

    Full Changelog: https://github.com/skedgo/TGCardViewController/compare/2.1.0...2.1.1

    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Jan 12, 2022)

    What's Changed

    • RTL-support by @nighthawk in https://github.com/skedgo/TGCardViewController/pull/11

    Full Changelog: https://github.com/skedgo/TGCardViewController/compare/2.0.3...2.1.0

    Source code(tar.gz)
    Source code(zip)
  • 2.0.3(Dec 20, 2021)

    What's Changed

    • VoiceOver tweaks by @nighthawk in https://github.com/skedgo/TGCardViewController/pull/9
    • Make support for the preferred view more explicit, adding TGPreferredView by @nighthawk in https://github.com/skedgo/TGCardViewController/pull/10

    Full Changelog: https://github.com/skedgo/TGCardViewController/compare/2.0.2...2.0.3

    Source code(tar.gz)
    Source code(zip)
  • 2.0.2(Nov 19, 2021)

    Tweak for VoiceOver: Stay in extended mode if VoiceOver is running

    Full Changelog: https://github.com/skedgo/TGCardViewController/compare/2.0.1...2.0.2

    Source code(tar.gz)
    Source code(zip)
  • 2.0.1(Nov 18, 2021)

    Small tweak for VoiceOver: Allow opting out of the preferredView selection on a per-card basis

    Full Changelog: https://github.com/skedgo/TGCardViewController/compare/2.0.0...2.0.1

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Nov 16, 2021)

    What's Changed

    Updates for Xcode 13: @nighthawk in https://github.com/skedgo/TGCardViewController/pull/7

    • @MainActor annotations
    • Remove deprecated state restoration -- use NSUserActivity instead, see https://github.com/skedgo/TGCardViewController/pull/8
    • Remove Bundle.cardVC in favour of Bundle.module and TGCardViewController.bundle
    • Now requires iOS 13

    Full Changelog: https://github.com/skedgo/TGCardViewController/compare/1.7.6...2.0.0

    Source code(tar.gz)
    Source code(zip)
  • 1.7.6(Nov 15, 2021)

    VoiceOver fixes (#6)

    • Don't trigger paging to a different card using voice over; only the current card is "accessible" and when using voice over you have to page manually (e.g., by using a page control), but not by scrolling through the pages.
    • Don't read out hidden elements when card is extended
    Source code(tar.gz)
    Source code(zip)
  • 1.7.5(Oct 5, 2021)

  • 1.7.4(Oct 5, 2021)

  • 1.7.3(Oct 5, 2021)

    Fixes when pairing with nav bar

    1. Don't account twice for the top overlap, keeping extended close to the nav bar.
    2. Fix landscape where card content was always faded out
    Source code(tar.gz)
    Source code(zip)
  • 1.7.2(Oct 5, 2021)

  • 1.7.1(Sep 3, 2021)

    Small bug fixes:

    • Remove shadow path optimisation as that breaks the shadow when rotating
    • Inset floating views relative to safe area on devices with a notch
    • Fix map insets when card wrapper is hidden, after updating toolbars, and when toggling map overlays
    Source code(tar.gz)
    Source code(zip)
  • 1.7.0(Sep 1, 2021)

    • Fixes TGMapManager's placement of MKMapView attribution and legal label
    • Fixes TGMapManager's centring of the map when the card is in peaking mode
    • Fixes MKMapView's accessibility when (partially) covered by the card
    • Removes edgePadding: parameter from TGMapManager's takeCharge method
    Source code(tar.gz)
    Source code(zip)
Owner
SkedGo
SkedGo
Swipe able, customizable card stack view, Tinder like card stack view based on UICollectionView. Cards UI

Swipable, customizable card stack view, Tinder like card stack view based on UICollectionView. Cards UI Сocoapods installation Add in your Podfile: po

Indy 850 Nov 17, 2022
A navigation controller that displays its view controllers as an interactive stack of cards.

CardNavigation The easiest way to turn a navigation controller into an interactive stack of cards. Highlights ✅ Fully interactive and interruptible ✅

James Randolph 41 Sep 29, 2022
IOS Card Game - A simple card game using SwiftUI

IOS_Card_Game A simple card game using Swift UI.

Md. Masum Musfique 1 Mar 25, 2022
Recreation of cards from Apple's AppStore written using SwiftUI.

App Store Cards Animation I tried to reproduce the look and the feeling of the cards from the AppStore. Please note that this repository is a work-in-

Roman 3 Mar 30, 2022
A easy-to-use SwiftUI view for Tinder like cards on iOS, macOS & watchOS.

?? CardStack A easy-to-use SwiftUI view for Tinder like cards on iOS, macOS & watchOS. Installation Xcode 11 & Swift Package Manager Use the package r

Deniz Adalar 285 Jan 3, 2023
A SwiftUI view that arranges its children in a whimsical interactive deck of cards, as seen in Big News

CardStack A SwiftUI view that arranges its children in a whimsical interactive deck of cards. CardStack mimics the behaviour of the photo stack in iMe

The Not So Big Company 74 Dec 13, 2022
A reactive, card-based UI framework built on UIKit for iOS developers.

CardParts - made with ❤️ by Intuit: Example Requirements Installation Communication & Contribution Overview Quick Start Architecture CardsViewControll

Intuit 2.5k Jan 4, 2023
A SwiftUI based custom sheet card to show information in iOS application.

A SwiftUI based custom sheet card to show any custom view inside the card in iOS application.

Mahmud Ahsan 4 Mar 28, 2022
A SwiftUI card view, made great for setup interactions.

SlideOverCard A SwiftUI card design, similar to the one used by Apple in HomeKit, AirPods, Apple Card and AirTag setup, NFC scanning, Wi-Fi password s

João Gabriel 716 Dec 29, 2022
SimpleCardView-SwiftUI is a very simple card view written with SwiftUI

SimpleCardView-SwiftUI is a very simple card view written with SwiftUI

Tomortec 3 May 19, 2022
A swift SDK to help you scan debit/credit cards.

SKCardReader A swift SDK to help you scan debit/credit cards. Requirements To use the SDK the following requirements must be met: Xcode 11.0 or newer

Syed Kashan 4 Jul 29, 2022
Swift Package to download Transactions for LunchOnUs Cards

LunchOnUs Downloader What This is a small library to download transaction and balance data for LunchOnUs Cards (Giftcards by Eigen Development). How C

Steffen Kötte 0 Jan 15, 2022
KolodaView is a class designed to simplify the implementation of Tinder like cards on iOS.

KolodaView Check this article on our blog. Purpose KolodaView is a class designed to simplify the implementation of Tinder like cards on iOS. It adds

Yalantis 5.2k Jan 2, 2023
Presenting timelines as cards, single or bundled in scrollable feed!

TimelineCards ?? Autogenerated timelines presented as cards ?? ?? Single or bundled into feed ?? Installation CocoaPods (wtf is that?) Add pod 'Timeli

0xNSHuman 428 Dec 16, 2022
Awesome iOS 11 appstore cards in swift 5.

Cards brings to Xcode the card views seen in the new iOS XI Appstore. Getting Started Storyboard Go to main.storyboard and add a blank UIView Open the

Paolo Cuscela 4.1k Dec 14, 2022
Presenting timelines as cards, single or bundled in scrollable feed!

TimelineCards ?? Autogenerated timelines presented as cards ?? ?? Single or bundled into feed ?? Installation CocoaPods (wtf is that?) Add pod 'Timeli

0xNSHuman 428 Dec 16, 2022
This UI attempts to capture the Quibi Card Stack and the associated User Interaction.

RGStack This UI attempts to capture the Quibi Card Stack and the associated User Interaction. Required A View that conforms to the ConfigurableCard pr

RGeleta 96 Dec 18, 2022
Card flip animation by pan gesture.

CardAnimation Design from Dribble. 实现思路在这里。 Two Solutions At the begin, I didn't encapsulate code, @luxorules refactor code into class and improve it

null 1.2k Dec 14, 2022
Awesome looking Dial like card selection ViewController

KVCardSelectionVC Awesome looking Dial like card selection ViewController An updated Swift 3 working version of : https://github.com/atljeremy/JFCardS

Kunal Verma 23 Feb 1, 2021