ViewControllerBuilder

public protocol ViewControllerBuilder

Type, that is capable of building a ViewController, given Context.

  • Type of View, that this ViewControllerBuilder can build.

    Declaration

    Swift

    associatedtype ViewType : ViewController
  • Argument type, that ViewBuilder needs to build a ViewController.

    Declaration

    Swift

    associatedtype Context
  • Builds a View using provided Context or throws an error, if building process was not successful

    Throws

    Build error, if building process was not successful.

    Declaration

    Swift

    func build(with context: Context) throws -> ViewType

    Parameters

    context

    Argument, required to build ViewController.

    Return Value

    View, that was built using provided Context object.

  • Creates a NavigationSingleViewEmbeddingBuilder, embedding current view builder in it.

    Declaration

    Swift

    public func embeddedInNavigation(navigationBuilder: @escaping () -> UINavigationController = { .init() }) -> NavigationSingleViewEmbeddingBuilder<Self>

    Return Value

    NavigationSingleViewEmbeddingBuilder with current builder embedded.

  • pushRoute(isAnimated:) Extension method

    Creates a route, that uses current builder, creates a view, and pushes it onto current navigation stack.

    Declaration

    Swift

    public func pushRoute(isAnimated: Bool = true) -> Route<Self, PushNavigationTransition>

    Parameters

    isAnimated

    should the navigation push be animated.

    Return Value

    Route to view built by current builder, that will be pushed onto current navigation stack.

  • presentRoute(isAnimated:) Extension method

    Creates a route, that uses current builder, creates a view, and presents it on top of currently visible view.

    Declaration

    Swift

    public func presentRoute(isAnimated: Bool = true) -> Route<Self, PresentationTransition>

    Parameters

    isAnimated

    should the presentation be animated.

    Return Value

    Route to view built by current builder, that will be presented on top of currently visible view.

  • replace(_:isAnimated:) Extension method

    Creates a route that uses a current builder, creates a view, and replaces current navigation stack with a newly created view. Remaining viewControllers depend on behavior.

    Declaration

    Swift

    public func replace(_ behavior: ReplaceNavigationTransition.Behavior = .replaceLast, isAnimated: Bool = true) -> Route<Self, ReplaceNavigationTransition>

    Parameters

    behavior

    Behavior to use when replacing view controllers in navigation stack

    isAnimated

    should the presentation be animated.

  • with(_:) Extension method

    Combines current builder with provided transition to create a Route, containing them both.

    Declaration

    Swift

    public func with<T>(_ transition: T) -> Route<Self, T> where T : ViewTransition

    Parameters

    transition

    transition to be performed when navigating to created route.

    Return Value

    Route, that combines current builder and transition.

Available where Context == Void

  • asAnyBuilder Extension method

    Converts any ViewControllerBuilder with Void context to AnyBuilder, erasing it’s type.

    Declaration

    Swift

    public var asAnyBuilder: AnyBuilder { get }
  • build() Extension method

    Builds a View, that does not require Context, because it’s Context is Void.

    Throws

    Build error, if building process was not successful.

    Declaration

    Swift

    public func build() throws -> ViewType

    Return Value

    View, that was built using provided Context object.