GithubHelp home page GithubHelp logo

aryansbtloe / sahistorynavigationviewcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marty-suzuki/sahistorynavigationviewcontroller

0.0 2.0 0.0 10.17 MB

SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller.

License: MIT License

Ruby 1.84% Swift 87.96% Objective-C 0.82% C 0.72% Shell 8.66%

sahistorynavigationviewcontroller's Introduction

SAHistoryNavigationViewController

Platform Language Version License

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

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.navigationController in ViewController, bacause implemented extension UINavigationController as below codes and override those methods in SAHistoryNavigationViewController.

extension UINavigationController {
    public weak var navigationDelegate: SAHistoryNavigationViewControllerDelegate? {
        set {
            willSetNavigationDelegate(navigationDelegate)
        }
        get {
            return willGetNavigationDelegate()
        }
    }
    public weak var transitionDelegate: SAHistoryNavigationViewControllerTransitionDelegate? {
        set {
            willSetTransitionDelegate(transitionDelegate)
        }
        get {
            return willGetTransitionDelegate()
        }
    }
    public var interactivePopGestureEnabled: Bool {
        set {
            willSetInteractivePopGestureEnabled(newValue)
        }
        get {
            return willGetInteractivePopGestureEnabled()
        }
    }
    public func showHistory() {}
    public func setHistoryBackgroundColor(color: UIColor) {}
    public func contentView() -> UIView? { return nil }
    func willSetNavigationDelegate(navigationDelegate: SAHistoryNavigationViewControllerDelegate?) {}
    func willGetNavigationDelegate() -> SAHistoryNavigationViewControllerDelegate? { return nil }
    func willSetNavigationTransitioningDelegate(navigationTransitioningDelegate: SAHistoryNavigationViewControllerTransitioningDelegate?) {}
    func willGetNavigationTransitioningDelegate() -> SAHistoryNavigationViewControllerTransitioningDelegate? { return nil }
    func willSetInteractivePopGestureEnabled(interactivePopGestureEnabled: Bool) {}
    func willGetInteractivePopGestureEnabled() -> Bool { return true }
}

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.

	navigationController?.showHistory()

Customize

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

	navigationController?.contentView()
	navigationController?.setHistoryBackgroundColor(color: UIColor)

This is delegate methods.

@objc public protocol SAHistoryNavigationViewControllerDelegate : NSObjectProtocol {
    optional func navigationController(navigationController: SAHistoryNavigationViewController, willShowViewController viewController: UIViewController, animated: Bool)
    optional func navigationController(navigationController: SAHistoryNavigationViewController, didShowViewController viewController: UIViewController, animated: Bool)
    optional func navigationControllerSupportedInterfaceOrientations(navigationController: SAHistoryNavigationViewController) -> UIInterfaceOrientationMask
    optional func navigationControllerPreferredInterfaceOrientationForPresentation(navigationController: SAHistoryNavigationViewController) -> UIInterfaceOrientation
    optional func navigationController(navigationController: SAHistoryNavigationViewController, willHandleEdgeSwipe gesture: UIScreenEdgePanGestureRecognizer)
    optional func navigationController(navigationController: SAHistoryNavigationViewController, didHandleEdgeSwipe gesture: UIScreenEdgePanGestureRecognizer)
}
@objc public protocol SAHistoryNavigationViewControllerTransitioningDelegate : NSObjectProtocol {
    optional func navigationController(navigationController: SAHistoryNavigationViewController, interactionControllerForAnimationController animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?
    optional func navigationController(navigationController: SAHistoryNavigationViewController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
}

Requirements

  • Xcode 7.0 or greater
  • iOS7.0(manually only) or greater

Author

Taiki Suzuki, [email protected]

License

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

sahistorynavigationviewcontroller's People

Contributors

marty-suzuki avatar ayushgoel avatar jakemarsh avatar

Watchers

James Cloos avatar Alok kumar singh 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.