SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller. Support 3D Touch!

Overview

SAHistoryNavigationViewController

Platform Language Version License

Support 3D Touch for iOS9!!

SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller.

ManiacDev.com referred.
https://maniacdev.com/2015/03/open-source-component-enhancing-the-back-button-with-view-history-navigation

Features

  • iOS task manager like UI
  • Launch Navigation History with Long tap action of Back Bar Button
  • Support Swift2.0
  • Support 3D Touch (If device is not supported 3D Touch, automatically replacing to long tap gesture.)
  • Support Swift2.3
  • Sipport Swift3

Installation

CocoaPods

SAHistoryNavigationViewController is available through CocoaPods. If you have cocoapods 0.38.0 or greater, you can install it, simply add the following line to your Podfile:

pod "SAHistoryNavigationViewController"

Manually

Add the SAHistoryNavigationViewController directory to your project.

Usage

If you install from cocoapods, You have to write import SAHistoryNavigationViewController.

Storyboard or Xib

Set custom class of UINavigationController to SAHistoryNavigationViewController. In addition, set module to SAHistoryNavigationViewController.

Code

You can use SAHistoryNavigationViewController as self.sah.navigationController in any ViewController, bacause implemented extension SAHistoryExtension as below codes.

public protocol SAHistoryCompatible {
    associatedtype CompatibleType
    var sah: CompatibleType { get }
}

public extension SAHistoryCompatible {
    public var sah: SAHistoryExtension<Self> {
        return SAHistoryExtension(self)
    }
}

public final class SAHistoryExtension<Base> {
    public let base: Base
    public init(_ base: Base) {
        self.base = base
    }
}

extension UIViewController: SAHistoryCompatible {}

extension SAHistoryExtension where Base: UIViewController {
    public var navigationController: SAHistoryNavigationViewController? {
        return base.navigationController as? SAHistoryNavigationViewController
    }
}

And you have to initialize like this.

let ViewController = UIViewController()
let navigationController = SAHistoryNavigationViewController()
navigationController.setViewControllers([ViewController], animated: true)
presentViewController(navigationController, animated: true, completion: nil)

If you want to launch Navigation History without long tap action, use this code.

//In any UIViewController
self.sah.navigationController?.showHistory()

Customize

If you want to customize background of Navigation History, you can use those methods.

//In any UIViewController
self.sah.navigationController?.contentView
self.sah.navigationController?.historyBackgroundColor

This is delegate methods.

@objc public protocol SAHistoryNavigationViewControllerDelegate: NSObjectProtocol {
    optional func historyControllerDidShowHistory(controller: SAHistoryNavigationViewController, viewController: UIViewController)
}

Requirements

Author

Taiki Suzuki, [email protected]

License

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

Comments
  • Crash when inheriting SAHistoryNavigationViewController

    Crash when inheriting SAHistoryNavigationViewController

    I gave this lib a try but discovered a nasty crash when using it on iOS 9.2 Here's the end of the stack trace.

    * thread #1: tid = 0x9b91cc, 0x0000000103fd1dbb libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
        frame #0: 0x0000000103fd1dbb libobjc.A.dylib`objc_exception_throw
        frame #1: 0x000000010304ad9d CoreFoundation`+[NSException raise:format:] + 205
        frame #2: 0x0000000101466f0a UIKit`-[UINavigationBar setDelegate:] + 81
      * frame #3: 0x00000001012c228a SAHistoryNavigationViewController`SAHistoryNavigationViewController.SAHistoryNavigationViewController.viewDidLoad (self=<unavailable>)() -> () + 1418 at SAHistoryNavigationViewController.swift:101
        frame #4: 0x0000000100337059 CaptainJet`CaptainJet.CaptainJetNavigationController.viewDidLoad (self=0x00007fc03304e200)() -> () + 41 at CaptainJetNavigationController.swift:16
        frame #5: 0x0000000100337932 CaptainJet`@objc CaptainJet.CaptainJetNavigationController.viewDidLoad (CaptainJet.CaptainJetNavigationController)() -> () + 34 at CaptainJetNavigationController.swift:0
        frame #6: 0x0000000101508f98 UIKit`-[UIViewController loadViewIfRequired] + 1198
        frame #7: 0x00000001015092e7 UIKit`-[UIViewController view] + 27
        frame #8: 0x000000010155184b UIKit`-[UINavigationController pushViewController:transition:forceImmediate:] + 663
        frame #9: 0x0000000101551299 UIKit`-[UINavigationController pushViewController:animated:] + 848
        frame #10: 0x00000001012c28d8 
    

    The debugger gives this output: Cannot manually set the delegate on a UINavigationBar managed by a controller.

    Looking at the documentation you can see that:

    If the navigation bar was created by a navigation controller and is being managed by that object, you must not change the value of this property. Navigation controllers act as the delegate for any navigation bars they create.

    This is what is happening here. The controller automatically becomes the navigationBar delegate. I think this line should be removed. Let me know if you need a PR I would happily do so.

    opened by apouche 5
  • Some desired changes

    Some desired changes

    The code here:

    1. Solves the bug where the SAHistoryNavigationViewController extends behind status bar if a modal UIViewController is presented.
    2. Removes any custom animation and works purely by following the delegate methods. (IMHO, the animation should be a different pod altogether)
    3. Uses some functional constructs where it makes understanding code easier.
    4. Extends Sample to present a UIViewController modally.

    Some of these changes might be in conflict with what you had planned for this pod. In that case, I would like to create a different pod from this. Also, if you have any suggestions for the code which could make this merge, would love to know them. :innocent:

    opened by ayushgoel 5
  • Crash when navigation between screens is half complete and reverted

    Crash when navigation between screens is half complete and reverted

    Hi, First off, great control utility for ios, thanks a bunch, I came across this peculiar bug, i've uploaded the procedure here, and its reproducible. Please have a look. I'm trying to fix this up myself, i'll submit a pull request if i'm successful :) https://www.youtube.com/watch?v=unzY6lAhSeo&feature=youtu.be

    opened by giridharvc7 5
  • Warning when going back and a tabbar controller has been pushed

    Warning when going back and a tabbar controller has been pushed

    The warning is: Unbalanced calls to begin/end appearance transitions for UITabBarController: 0x7fb91bd2a850.

    Consider the following scenario in storyboards:

    • Have a navigation controller as the initial view controller wit a UIViewController
    • Add a button to the UIViewController that leads to a UITabbarController

    Tap on the button to see the tabbar controller, then long press the back button to see the error above.

    I can provide you a zip file if you want with this test case, no code involved, just storyboards.

    opened by pepejeria 4
  • Added support for landscape orientation

    Added support for landscape orientation

    Added support for mixing landscape and portrait orientations when navigating through a UINaivigationController. This feature is especially useful for tablets, where supporting just one orientation is not practical.

    In regards to supporting both portrait and landscape, there is one aspect worth discussing: when restoring a landscape screenshot into a portrait screen or viceversa, how should the animation look? Stretching the photo to fill the new size did not look right to me, so I left the old behavior, which zooms the image until it hits one of the screen's edges, then, it is replaced by destination VC with the proper bounds.

    opened by ratzinho87 1
  • Cannot set if historyContentView.backgroundColor

    Cannot set if historyContentView.backgroundColor

    Hi! First of all, I would like to say that this is one of the greatest new functionality I have seen in a long time, It perfectly fits in my app!

    There is just one little tiny detail on iOS 9.2 setting up background color gets overriten in SAHistoryNavigationViewController.swift on line 49. I haven't tested this on any other version of iOS, but I am pretty sure that it won't work also.

    So I have made a really tiny change, basically just check if backgroundColor is already set, if so It won't get ser on grayColor.

    Tested and It works now.

    opened by syky27 1
  • Very simple fix for animation flickering issue when returning to selected view controller from history.

    Very simple fix for animation flickering issue when returning to selected view controller from history.

    Before when selecting a view controller from the history, the navigation bar would be animating in at the same time, doing it without animation solves this problem and the transition is much nicer looking.

    Cheers! This is a great idea!

    opened by jakemarsh 1
  • [#38] fixed crash when changing navbar delegate

    [#38] fixed crash when changing navbar delegate

    According to Apple documentation:

    If the navigation bar was created by a navigation controller and is being managed by that object, you must not change the value of this property. Navigation controllers act as the delegate for any navigation bars they create.

    Since this is exactly what's happening here, the OS triggers a trap and any controller subclassing SAHistoryNavigationViewController will crash as well.

    Simply removing the delegate assignment solves this issue.

    opened by apouche 0
Releases(3.0.0)
Owner
Taiki Suzuki
AbemaTV / University of Aizu 18th
Taiki Suzuki
πŸš€ It Makes easy to track your task πŸ”₯ Beautiful & Animated UIπŸ‘¨πŸ»β€πŸ’» . Contributions are always welcome πŸ€—

Taskey ?? What is Taskey ?? ? Taskey is an application build in SwiftUI to track your task with a beautiful animations and UI . Also used core data to

AppLobby 36 Nov 20, 2022
Gravity is a simple Swift Package Manager to add gravity to UI objects easily.

Gravity -- Gravity is a simple Swift Package to add gravity to UI objects easily. -- How to use: Add a new Swift Package from XCode and paste the url

alberto 1 Nov 23, 2021
AwaitKit 4.0.0 with Swift 5 support

Have you ever dream to write asynchronous code like its synchronous counterpart? AwaitKit is a powerful Swift library inspired by the Async/Await spec

null 8 Sep 28, 2022
A library for building an internal/development support app easily

Scenarios A library supporting fast prototyping for iOS Projects. Introduction Challenges of mobile frontend development Stories with multiple require

An Tran 29 Sep 15, 2022
🎨 Gradient animation effect like Instagram

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

Cruz 3.4k Jan 1, 2023
Poi - You can use tinder UI like tableview method

Poi You can use tinder UI like tableview method Installation Manual Installation Use this command git clone [email protected]:HideakiTouhara/Poi.git Imp

null 65 Nov 7, 2022
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)

エウレカ 279 Dec 9, 2022
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

Chandan Sharda 18 Oct 11, 2022
An animated trophy banner that looks like Xbox achievement πŸ†

TrophyKit An animated trophy banner that looks like Xbox achievement. Demo demo.mov Usage Requirements iOS 14.0+ tvOS 14.0+ Swift 5.3+ Installation Tr

Yubo Qin 11 Jul 18, 2022
An experiment for using SwiftUI's custom timing Animation to create an orbital-like animation.

Orbital-SwiftUI-Animation An experiment for using SwiftUI's custom timing curve to create an orbital-like animation. How it looks: How it works: Apply

Mostafa Abdellateef 7 Jan 2, 2023
Cool wave like transition between two or more UICollectionView

CKWaveCollectionViewTransition This is a cool custom transition between two or more UICollectionViewControllers with wave-like cell animation. Could b

Cezary Kopacz 1.9k Oct 4, 2022
Confetti! Who doesn't like confetti?

SAConfettiView It's raining confetti! SAConfettiView is the easiest way to add fun, multi-colored confetti to your application and make users feel rew

Sudeep Agarwal 1.5k Dec 22, 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
Tinder/Bumble like user image with user details scroll animation

TinderUserProfile Tinder/Bumble like user image with user details scroll animation Add ProfileView.m,ProfileView.h class to your project. Set the clas

Souvick Ghosh 21 Jun 21, 2022
Snapchat-like filters, AR lenses, and real-time facial animations.

react-native-deepar Snapchat-like filters, AR lenses, and real-time facial animations. React-Native wrapper for DeepAR. Table of Contents What is Deep

RΔ±dvan Altun 82 Dec 13, 2022
Animated alert library like Swarm app.

TKSwarmAlert Animation Tool for Alert like Swarm app. ScreenShot Installation CocoaPods You can use CocoaPods to install TKSwarmAlert by adding it to

Takuya Okamoto 581 Dec 2, 2022
An app that will help UI/UX designers and iOS developpers to easily work together, using demos and examples about iOS capabilities, limitations, ecosystem, ...

Demoapp Work in progress... ?? What's about? It's an app built in SwiftUI that will help UI/UX designers and iOS developpers to work together smoothly

Kaww 2 Nov 2, 2022
(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
Project 04 I created for "iOS & Swift - The Complete iOS App Development Bootcamp"

Magic 8 Ball This is the fourth project I created for "iOS & Swift - The Complete iOS App Development Bootcamp" Our Goal The objective of this challen

Lukas Goodfellow 0 Dec 23, 2021