Navigate

@available(iOS 9.0, *)
public class Navigate

An object to help with navigation.

Configure NavigationController

  • Configure the Navigate Singleton with the Root Navigation Controller

    Declaration

    Swift

    @discardableResult
    public func configure(controller: UINavigationController?) -> Self
  • Set the visibleViewController’s title

    Declaration

    Swift

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

    Parameters

    title

    The title of the currentViewController

  • Set the left barButton

    Declaration

    Swift

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

    Parameters

    barButton

    The UIBarButtonItem to be set

    animated

    Should animate setting the left UIBarButtonItem (Default: true)

  • Set the right barButton

    Declaration

    Swift

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

    Parameters

    barButton

    The UIBarButtonItem to be set

    animated

    Should animate setting the right UIBarButtonItem (Default: true)

  • Set the left barButtons

    Declaration

    Swift

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

    Parameters

    barButton

    The [UIBarButtonItem] to be set

    animated

    Should animate setting the left UIBarButtonItem

  • Set the right barButtons

    Declaration

    Swift

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

    Parameters

    barButton

    The [UIBarButtonItem] to be set

    animated

    Should animate setting the right UIBarButtonItem

Navigation

  • Go to a viewController by using the configured NavigationController

    Declaration

    Swift

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

    Parameters

    viewController

    UIViewController to navigate to

    style

    Style of navigation (Default: nil)

  • Go to a viewController by using another viewController

    Declaration

    Swift

    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 (Default: nil)

  • Navigate back and dismiss the visibleViewController

    Declaration

    Swift

    public func back(toRoot: Bool = false)

    Parameters

    toRoot

    Should navigate back to the rootViewController (Default: false)

  • Dismiss the visibleViewController

    Declaration

    Swift

    public func dismiss()

Alert

  • Show an Alert

    Declaration

    Swift

    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 (Default: [])

    secondsToPersist

    Amount of seconds the Alert should show before dismissing itself

    closure

    A closure that is passed the UIAlertController before presenting it (Default: nil)

ActionSheet

  • Show an ActionSheet

    Declaration

    Swift

    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 (Default: [])

    closure

    A closure that is passed the UIAlertController before presenting it (Default: nil)

Toasts & Messages

  • Show a Toast Message

    Declaration

    Swift

    @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 (Default: nil)

    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 (Default: 8)

    tapHandler

    What happens when the user taps on the Toast (Default: { $0.removeFromSuperview() })

    closure

    A trailing closure that accepts a view

  • Destory the toast

    Declaration

    Swift

    public func destroyToast()