Skip to content

Latest commit

 

History

History
200 lines (128 loc) · 5.02 KB

Navigate.md

File metadata and controls

200 lines (128 loc) · 5.02 KB

Navigate

@available(iOS 9.0, *) public class Navigate

Initializers

init(controller:)

public init(controller: UINavigationController? = nil)

Properties

shared

var shared: Navigate

Methods

configure(controller:)

Configure the Navigate Singleton with the Root Navigation Controller

@discardableResult public func configure(controller: UINavigationController?) -> Self

set(title:)

Set the visibleViewController's title

@discardableResult public func set(title: String) -> Self

Parameters

  • title: The title of the currentViewController

setLeft(barButton:animated:)

Set the left barButton

@discardableResult public func setLeft(barButton: UIBarButtonItem?, animated: Bool = true) -> Self

Parameters

  • barButton: The UIBarButtonItem to be set
  • animated: Should animate setting the left UIBarButtonItem

setRight(barButton:animated:)

Set the right barButton

@discardableResult public func setRight(barButton: UIBarButtonItem?, animated: Bool = true) -> Self

Parameters

  • barButton: The UIBarButtonItem to be set
  • animated: Should animate setting the right UIBarButtonItem

setLeft(barButtons:animated:)

Set the left barButtons

@discardableResult public func setLeft(barButtons: [UIBarButtonItem]?, animated: Bool = true) -> Self

Parameters

  • barButton: The [UIBarButtonItem] to be set
  • animated: Should animate setting the left [UIBarButtonItem]

setRight(barButtons:animated:)

Set the right barButtons

@discardableResult public func setRight(barButtons: [UIBarButtonItem]?, animated: Bool = true) -> Self

Parameters

  • barButton: The [UIBarButtonItem] to be set
  • animated: Should animate setting the right [UIBarButtonItem]

go(_:style:completion:)

Go to a viewController by using the configured NavigationController

public func go(_ viewController: UIViewController, style: NavigationStyle, completion: (() -> Void)? = nil)

Parameters

  • viewController: UIViewController to navigate to
  • style: Style of navigation

go(from:to:style:completion:)

Go to a viewController by using another viewController

public func go(from: UIViewController, to: UIViewController, style: NavigationStyle, completion: (() -> Void)? = nil)

Parameters

  • from: The UIViewController that is handling the navigation
  • viewController: UIViewController to navigate to
  • style: Style of navigation

back(toRoot:)

Navigate back and dismiss the visibleViewController

public func back(toRoot: Bool = false)

Parameters

  • toRoot: Should navigate back to the rootViewController

dismiss()

Dismiss the visibleViewController

public func dismiss()

alert(title:message:withActions:secondsToPersist:_:)

Show an Alert

public func alert(title: String, message: String, withActions actions: [UIAlertAction] = [], secondsToPersist: Double?, _ closure: ((UIAlertController) -> Void)? = nil)

Parameters

  • title: Title of the UIAlertController
  • message: Message of the UIAlertController
  • withactions: Array of action objects to be added to the Alert
  • secondsToPersist: Amount of seconds the Alert should show before dismissing itself
  • closure: A closure that is passed the UIAlertController before presenting it

actionSheet(title:message:withActions:_:)

Show an ActionSheet

public func actionSheet(title: String, message: String, withActions actions: [UIAlertAction] = [], _ closure: ((UIAlertController) -> Void)? = nil)

Parameters

  • title: Title of the UIAlertController
  • message: Message of the UIAlertController
  • withactions: Array of action objects to be added to the ActionSheet
  • closure: A closure that is passed the UIAlertController before presenting it

toast(style:pinToTop:secondsToPersist:animationInDuration:animationOutDuration:padding:tapHandler:_:)

Show a Toast Message

@available(iOS 11.0, *) public func toast(style: ToastStyle = .custom, pinToTop: Bool = true, secondsToPersist: Double? = nil, animationInDuration: Double = 0.5, animationOutDuration: Double = 0.5, padding: Float = 8, tapHandler: @escaping (UIView) -> Void = { $0.removeFromSuperview() }, _ closure: @escaping () -> UIView)

Parameters

  • style: The ToastStyle (default: .custom)
  • pinToTop: Should the Toast pin to the top or bottom (default: true)
  • secondsToPersist: Amount of seconds the Toast should show before dismissing itself
  • animationInDuration: The amount of seconds the Toast should fade in (default: 0.5)
  • animationOutDuration: The amount of seconds the Toast should fade out (default: 0.5)
  • padding: The amount of spacing around the Toast
  • tapHandler: What happens when the user taps on the Toast (default: { $0.removeFromSuperview() })
  • closure: A trailing closure that accepts a view

destroyToast()

Destory the toast

public func destroyToast()