ScreenThenable

public protocol ScreenThenable

A protocol representing the route to which actions can be added.

  • A type of root container that will be used to perform actions.

    See also

    ScreenContainer

    Declaration

    Swift

    associatedtype Root : ScreenContainer
  • A type of the current container, which is the container for the actions to be added.

    See also

    ScreenContainer

    Declaration

    Swift

    associatedtype Current : ScreenContainer
  • Route actions that can be performed in the root container.

    Declaration

    Swift

    var actions: [AnyScreenAction<Root, Void>] { get }
  • Adds actions.

    Declaration

    Swift

    func then(_ actions: [AnyScreenAction<Current, Void>]) -> Self

    Parameters

    actions

    Actions to be added to the current actions.

    Return Value

    An instance containing the new actions.

  • Adds an action.

    Declaration

    Swift

    func then<Action: ScreenAction>(
        _ action: Action
    ) -> Self where Action.Container == Current

    Parameters

    action

    Action to be added to the current actions

    Return Value

    An instance containing the new action.

  • Adds actions of another route.

    Declaration

    Swift

    func then<Route: ScreenThenable>(
        _ other: Route
    ) -> Self where Route.Root == Current

    Parameters

    other

    The route whose actions will be added to the current actions.

    Return Value

    An instance containing the new actions.

  • call(to:) Extension method

    Undocumented

    Declaration

    Swift

    public func call(to phoneNumber: String) -> Self
  • mail(to:subject:body:) Extension method

    Undocumented

    Declaration

    Swift

    public func mail(
        to emailAddress: String,
        subject: String? = nil,
        body: String? = nil
    ) -> Self
  • Undocumented

    Declaration

    Swift

    public func openURL(
        _ url: URL,
        fallbackURLs: [URL] = [],
        options: [UIApplication.OpenExternalURLOptionsKey: Any] = [:]
    ) -> Self
  • openAppSettings() Extension method

    Undocumented

    Declaration

    Swift

    public func openAppSettings() -> Self
  • openStoreApp(id:forReview:) Extension method

    Undocumented

    Declaration

    Swift

    public func openStoreApp(id: String, forReview: Bool = false) -> Self
  • first(_:) Extension method

    Undocumented

    Declaration

    Swift

    public func first<Output: ScreenContainer>(
        _ predicate: ScreenPredicate<Output>
    ) -> ScreenRoute<Root, Output>
  • first(_:route:) Extension method

    Undocumented

    Declaration

    Swift

    public func first<Output, Route: ScreenThenable>(
        _ predicate: ScreenPredicate<Output>,
        route: Route
    ) -> Self where Route.Root == Output
  • first(_:route:) Extension method

    Undocumented

    Declaration

    Swift

    public func first<Output: ScreenContainer>(
        _ predicate: ScreenPredicate<Output>,
        route: (_ route: ScreenRootRoute<Output>) -> ScreenRouteConvertible
    ) -> Self
  • last(_:) Extension method

    Undocumented

    Declaration

    Swift

    public func last<Output: ScreenContainer>(
        _ predicate: ScreenPredicate<Output>
    ) -> ScreenRoute<Root, Output>
  • last(_:route:) Extension method

    Undocumented

    Declaration

    Swift

    public func last<Output, Route: ScreenThenable>(
        _ predicate: ScreenPredicate<Output>,
        route: Route
    ) -> Self where Route.Root == Output
  • last(_:route:) Extension method

    Undocumented

    Declaration

    Swift

    public func last<Output: ScreenContainer>(
        _ predicate: ScreenPredicate<Output>,
        route: (_ route: ScreenRootRoute<Output>) -> ScreenRouteConvertible
    ) -> Self
  • top(_:) Extension method

    Undocumented

    Declaration

    Swift

    public func top<Output: ScreenContainer>(
        _ predicate: ScreenPredicate<Output>
    ) -> ScreenRoute<Root, Output>
  • top(_:route:) Extension method

    Undocumented

    Declaration

    Swift

    public func top<Output, Route: ScreenThenable>(
        _ predicate: ScreenPredicate<Output>,
        route: Route
    ) -> Self where Route.Root == Output
  • top(_:route:) Extension method

    Undocumented

    Declaration

    Swift

    public func top<Output: ScreenContainer>(
        _ predicate: ScreenPredicate<Output>,
        route: (_ route: ScreenRootRoute<Output>) -> ScreenRouteConvertible
    ) -> Self
  • refresh() Extension method

    Undocumented

    Declaration

    Swift

    public func refresh() -> Self
  • fail(with:) Extension method

    Undocumented

    Declaration

    Swift

    public func fail(with error: Error) -> Self
  • fold(action:) Extension method

    Performs action to retrieve the container that will be used to perform further actions of the route.

    Declaration

    Swift

    public func fold<Action: ScreenAction>(
        action: Action
    ) -> ScreenRoute<Root, Action.Output> where Action.Container == Current

    Parameters

    action

    Action to retrieve the container.

    Return Value

    An instance containing the new action.

  • fold(action:nested:) Extension method

    Performs a nested action in the container that will be retrieved by performing another action.

    Declaration

    Swift

    public func fold<Action: ScreenAction, Nested: ScreenAction>(
        action: Action,
        nested: Nested
    ) -> Self where Action.Container == Current, Action.Output == Nested.Container

    Parameters

    action

    Action to retrieve the container.

    nested

    Nested action to be performed in the retrieved container.

    Return Value

    An instance containing the new action.

  • fold(action:nested:) Extension method

    Performs nested actions in the container that will be retrieved by performing another action.

    Declaration

    Swift

    public func fold<Action: ScreenAction>(
        action: Action,
        nested: [AnyScreenAction<Action.Output, Void>]
    ) -> Self where Action.Container == Current, Action.Output: ScreenContainer

    Parameters

    action

    Action to retrieve the container.

    nested

    Nested actions to be performed in the retrieved container.

    Return Value

    An instance containing the new action.

  • fold(action:nested:) Extension method

    Performs a nested rout in the container that will be retrieved by performing another action.

    Declaration

    Swift

    public func fold<Action: ScreenAction, Route: ScreenThenable>(
        action: Action,
        nested: Route
    ) -> Self where Action.Container == Current, Action.Output == Route.Root

    Parameters

    action

    Action to retrieve the container.

    nested

    Nested route to be performed in the retrieved container.

    Return Value

    An instance containing the new action.

  • fold(action:nested:) Extension method

    Performs a nested rout in the container that will be retrieved by performing another action.

    Declaration

    Swift

    public func fold<Action: ScreenAction>(
        action: Action,
        nested: (_ route: ScreenRootRoute<Action.Output>) -> ScreenRouteConvertible
    ) -> Self where Action.Container == Current

    Parameters

    action

    Action to retrieve the container.

    nested

    The closure that should return the modified route that will be performed in the retrieved container.

    Return Value

    An instance containing the new action.

  • from(_:) Extension method

    Undocumented

    Declaration

    Swift

    public func from<Output: ScreenContainer>(
        _ container: Output?
    ) -> ScreenRoute<Root, Output>
  • from(_:to:) Extension method

    Undocumented

    Declaration

    Swift

    public func from<Output, Route: ScreenThenable>(
        _ container: Output?,
        to route: Route
    ) -> Self where Route.Root == Output
  • from(_:_:) Extension method

    Undocumented

    Declaration

    Swift

    public func from<Output: ScreenContainer>(
        _ container: Output?,
        _ route: (_ route: ScreenRootRoute<Output>) -> ScreenRouteConvertible
    ) -> Self
  • wait(for:) Extension method

    Waits for a given time interval.

    Usage examples

    • Shows an error message and dismisses it after 3 seconds:
    screenNavigator.navigate(from: self) { route in
        route
            .showAlert(.somethingWentWrong)
            .wait(for: 3.0)
            .dismiss()
    }
    

    Declaration

    Swift

    public func wait(for duration: TimeInterval) -> Self

    Parameters

    duration

    Waiting time in seconds.

    Return Value

    An instance containing the new action.

  • try(action:resolution:) Extension method

    Undocumented

    Declaration

    Swift

    public func `try`<Action: ScreenAction>(
        action: Action,
        resolution: ScreenTryResolution<Current, Action.Output>
    ) -> Self where Action.Container == Current
  • try(action:resolution:) Extension method

    Undocumented

    Declaration

    Swift

    public func `try`<Action: ScreenAction>(
        action: Action,
        resolution: (
            _ resolution: ScreenTryResolution<Current, Action.Output>
        ) -> ScreenTryResolution<Current, Action.Output>
    ) -> Self where Action.Container == Current
  • try(action:done:) Extension method

    Undocumented

    Declaration

    Swift

    public func `try`<Action: ScreenAction, Route: ScreenThenable>(
        action: Action,
        done: @escaping (_ value: Action.Output) -> Route
    ) -> Self where Action.Container == Current, Route.Root == Current
  • try(action:done:) Extension method

    Undocumented

    Declaration

    Swift

    public func `try`<Action: ScreenAction>(
        action: Action,
        done: @escaping (
            _ value: Action.Output,
            _ route: ScreenRootRoute<Current>
        ) -> ScreenRouteConvertible
    ) -> Self where Action.Container == Current
  • ensure(with:) Extension method

    Undocumented

    Declaration

    Swift

    public func ensure<Route: ScreenThenable>(
        with route: Route
    ) -> ScreenRootRoute<Root> where Route.Root == Root
  • ensure(with:) Extension method

    Undocumented

    Declaration

    Swift

    public func ensure(
        with route: (_ route: ScreenRootRoute<Root>) -> ScreenRouteConvertible
    ) -> ScreenRootRoute<Root>
  • fallback(to:) Extension method

    Undocumented

    Declaration

    Swift

    public func fallback<Route: ScreenThenable>(
        to route: @escaping (_ error: Error) -> Route
    ) -> ScreenRootRoute<Root> where Route.Root == Root
  • fallback(to:) Extension method

    Undocumented

    Declaration

    Swift

    public func fallback(
        to route: @escaping (
            _ error: Error,
            _ route: ScreenRootRoute<Root>
        ) -> ScreenRouteConvertible
    ) -> ScreenRootRoute<Root>
  • fallback(to:) Extension method

    Undocumented

    Declaration

    Swift

    public func fallback<Route: ScreenThenable>(
        to route: Route
    ) -> ScreenRootRoute<Root> where Route.Root == Root
  • cauterize() Extension method

    Undocumented

    Declaration

    Swift

    public func cauterize() -> ScreenRootRoute<Root>

Available where Current: UIViewController

Available where Current: ScreenVisibleContainer

  • requestStoreReview() Extension method

    Undocumented

    Declaration

    Swift

    public func requestStoreReview() -> Self

Available where Current: UIViewController

  • Undocumented

    Declaration

    Swift

    public func makeVisible(
        stackAnimation: ScreenStackAnimation? = .default,
        tabsAnimation: ScreenTabAnimation? = nil,
        dissmissAnimated: Bool = true
    ) -> Self
  • dismiss(animated:) Extension method

    Dismisses the screen container that was presented modally by the container in which the action is performed.

    Note

    Unlike the dismiss(animated:completion:) method of UIViewController, this action dismisses only the presented container.

    Usage examples

    navigator.navigate(from: container) { $0.dismiss() }
    

    Declaration

    Swift

    public func dismiss(animated: Bool = true) -> Self

    Parameters

    animated

    Pass true to animate the transition or false if you do not want the transition to be animated. The default value is true.

    Return Value

    An instance containing the new action.

  • present(_:animated:route:) Extension method

    Presents a screen modally and performs a route on the screen container.

    Usage examples

    • Presents a chat screen modally, then shows an error message on its container:
    let nestedRoute = ScreenModalRoute.showAlert(.somethingWentWrong)
    
    navigator.navigate(from: container) { route in
        route.present(ChatScreen(chatID: chatID), route: nestedRoute)
    }
    

    See also

    Screen

    Declaration

    Swift

    public func present<New: Screen, Route: ScreenThenable>(
        _ screen: New,
        animated: Bool = true,
        route: Route
    ) -> Self where New.Container: UIViewController, Route.Root == New.Container

    Parameters

    screen

    The screen to display over the current container’s content.

    animated

    Pass true to animate the transition or false if you do not want the transition to be animated. The default value is true.

    route

    The route that will be performed in the presented screen container.

    Return Value

    An instance containing the new action.

  • present(_:animated:route:) Extension method

    Presents a screen modally and performs a route on the screen container.

    Usage examples

    • Presents a chat screen modally:
    navigator.navigate(from: container) { route in
        route.present(ChatScreen(chatID: chatID))
    }
    
    • Presents a chat screen modally, then shows an error message on its container:
    navigator.navigate(from: self) { route in
        route.present(ChatScreen(chatID: chatID)) { route in
            route.showAlert(.somethingWentWrong)
        }
    }
    

    See also

    Screen

    Declaration

    Swift

    public func present<New: Screen>(
        _ screen: New,
        animated: Bool = true,
        route: (_ route: ScreenRootRoute<New.Container>) -> ScreenRouteConvertible = { $0 }
    ) -> Self where New.Container: UIViewController

    Parameters

    screen

    The screen to display over the current container’s content.

    animated

    Pass true to animate the transition or false if you do not want the transition to be animated. The default value is true.

    route

    The closure that should return the modified route that will be performed in the presented screen container. The default value returns empty route.

    Return Value

    An instance containing the new action.

  • presented Extension method

    Retrieves the modal container that is presented by the current container, or one of its ancestors in the container hierarchy.

    Usage examples

    • Dismisses the screen container that is presented by the presented container:
    navigator.navigate(from: container) { route in
        route
            .presented
            .dismiss()
    }
    

    Declaration

    Swift

    public var presented: ScreenRoute<Root, UIViewController> { get }

    Return Value

    An instance containing the new action.

  • presented(of:) Extension method

    Retrieves the screen container that is presented by the current container, or one of its ancestors in the container hierarchy.

    Usage examples

    • Pops the top screen container from the stack that is presented by the container:
    navigator.navigate(from: container) { route in
        route
            .presented(of: UINavigationController.self)
            .pop()
    }
    

    Declaration

    Swift

    public func presented<Output: UIViewController>(
        of type: Output.Type
    ) -> ScreenRoute<Root, Output>

    Parameters

    type

    The type to which the container will be cast.

    Return Value

    An instance containing the new action.

  • presented(of:route:) Extension method

    Performs a route on the screen container that is presented by the current container, or one of its ancestors in the container hierarchy.

    Usage examples

    • Pops the top screen container from the stack that is presented by the container:
    let nestedRoute = ScreenStackRoute.pop()
    
    navigator.navigate(from: container) { route in
        route.presented(of: UINavigationController.self, route: nestedRoute)
    }
    
    • Dismisses the screen container that is presented by the presented container:
    let nestedRoute = ScreenModalRoute.dismiss()
    
    navigator.navigate(from: container) { route in
        route.presented(route: nestedRoute)
    }
    

    Declaration

    Swift

    public func presented<Output: UIViewController, Route: ScreenThenable>(
        of type: Output.Type = Output.self,
        route: Route
    ) -> Self where Route.Root == Output

    Parameters

    type

    The type to which the container will be cast.

    route

    The route that will be performed in the retrieved screen container.

    Return Value

    An instance containing the new action.

  • presented(of:route:) Extension method

    Performs a route on the screen container that is presented by the current container, or one of its ancestors in the container hierarchy.

    Usage examples

    • Pops the top screen container from the stack that is presented by the container:
    navigator.navigate(from: container) { route in
        route.presented(of: UINavigationController.self) { $0.pop() }
    }
    
    • Dismisses the container that is presented by the presented container:
    navigator.navigate(from: self) { route in
        route.presented { $0.dismiss() }
    }
    

    Declaration

    Swift

    public func presented<Output: UIViewController>(
        of type: Output.Type = Output.self,
        route: (_ route: ScreenRootRoute<Output>) -> ScreenRouteConvertible
    ) -> Self

    Parameters

    type

    The type to which the container will be cast.

    route

    The closure that should return the modified route that will be performed in the retrieved screen container.

    Return Value

    An instance containing the new action.

  • presenting Extension method

    Retrieves the modal container that presented the current container.

    Usage examples

    • Dismisses the current container:
    navigator.navigate(from: container) { route in
        route
            .presenting
            .dismiss()
    }
    

    Declaration

    Swift

    public var presenting: ScreenRoute<Root, UIViewController> { get }

    Return Value

    An instance containing the new action.

  • presenting(of:) Extension method

    Retrieves the screen container that presented the current container.

    Usage examples

    • Pops the top screen container from the stack that presented the current container:
    navigator.navigate(from: container) { route in
        route
            .presenting(of: UINavigationController.self)
            .pop()
    }
    

    Declaration

    Swift

    public func presenting<Output: UIViewController>(
        of type: Output.Type
    ) -> ScreenRoute<Root, Output>

    Parameters

    type

    The type to which the container will be cast.

    Return Value

    An instance containing the new action.

  • presenting(of:route:) Extension method

    Performs a route on the screen container that presented the current container.

    Usage examples

    • Pops the top screen container from the stack that presented the current container:
    let nestedRoute = ScreenStackRoute.pop()
    
    navigator.navigate(from: container) { route in
        route.presenting(of: UINavigationController.self, route: nestedRoute)
    }
    
    • Dismisses the current container:
    let nestedRoute = ScreenModalRoute.dismiss()
    
    navigator.navigate(from: container) { route in
        route.presenting(route: nestedRoute)
    }
    

    Declaration

    Swift

    public func presenting<Output: UIViewController, Next: ScreenContainer>(
        of type: Output.Type = Output.self,
        route: ScreenRoute<Output, Next>
    ) -> Self

    Parameters

    type

    The type to which the container will be cast.

    route

    The route that will be performed in the retrieved screen container.

    Return Value

    An instance containing the new action.

  • presenting(of:route:) Extension method

    Performs a route on the screen container that presented the current container.

    Usage examples

    • Pops the top screen container from the stack that presented the current container:
    navigator.navigate(from: container) { route in
        route.presenting(of: UINavigationController.self) { $0.pop() }
    }
    
    • Dismisses the current container:
    navigator.navigate(from: self) { route in
        route.presenting { $0.dismiss() }
    }
    

    Declaration

    Swift

    public func presenting<Output: UIViewController>(
        of type: Output.Type = Output.self,
        route: (_ route: ScreenRootRoute<Output>) -> ScreenRouteConvertible
    ) -> Self

    Parameters

    type

    The type to which the container will be cast.

    route

    The closure that should return the modified route that will be performed in the retrieved screen container.

    Return Value

    An instance containing the new action.

  • stack Extension method

    Retrieves the nearest ancestor in the container hierarchy that is a stack container.

    Usage examples

    • Pops the top screen container from the stack of the current container:
    navigator.navigate(from: container) { route in
        route
            .stack
            .pop()
    }
    

    Declaration

    Swift

    public var stack: ScreenRoute<Root, UINavigationController> { get }

    Return Value

    An instance containing the new action.

  • stack(of:) Extension method

    Retrieves the nearest ancestor in the container hierarchy that is a stack container.

    Usage examples

    • Pops the top screen container from the stack of the current container:
    navigator.navigate(from: container) { route in
        route
            .stack(of: MyNavigationController.self)
            .pop()
    }
    

    Declaration

    Swift

    public func stack<Output: UINavigationController>(
        of type: Output.Type
    ) -> ScreenRoute<Root, Output>

    Parameters

    type

    The type to which the container will be cast.

    Return Value

    An instance containing the new action.

  • stack(of:route:) Extension method

    Performs a route on the nearest ancestor in the container hierarchy that is a stack container.

    Usage examples

    • Pops the top screen container from the stack of the current container:
    let nestedRoute = ScreenStackRoute.pop()
    
    navigator.navigate(from: container) { route in
        route.stack(route: nestedRoute)
    }
    

    Declaration

    Swift

    public func stack<Output: UINavigationController, Route: ScreenThenable>(
        of type: Output.Type = Output.self,
        route: Route
    ) -> Self where Route.Root == Output

    Parameters

    type

    The type to which the container will be cast.

    route

    The route that will be performed in the retrieved screen container.

    Return Value

    An instance containing the new action.

  • stack(of:route:) Extension method

    Performs a route on the nearest ancestor in the container hierarchy that is a stack container.

    Usage examples

    • Pops the top screen container from the stack of the current container:
    navigator.navigate(from: container) { route in
        route.stack { $0.pop() }
    }
    

    Declaration

    Swift

    public func stack<Output: UINavigationController>(
        of type: Output.Type = Output.self,
        route: (_ route: ScreenRootRoute<Output>) -> ScreenRouteConvertible
    ) -> Self

    Parameters

    type

    The type to which the container will be cast.

    route

    The closure that should return the modified route that will be performed in the retrieved screen container.

    Return Value

    An instance containing the new action.

  • tabs Extension method

    Retrieves the nearest ancestor in the container hierarchy that is a tabs container.

    Usage examples

    • Selects tab from the tab container of the current container:
    navigator.navigate(from: container) { route in
        route
            .tabs
            .selectTab(with: .index(1))
    }
    

    Declaration

    Swift

    public var tabs: ScreenRoute<Root, UITabBarController> { get }

    Return Value

    An instance containing the new action.

  • tabs(of:) Extension method

    Retrieves the nearest ancestor in the container hierarchy that is a tabs container.

    Usage examples

    • Selects tab from the tab container of the current container:
    navigator.navigate(from: container) { route in
        route
            .tabs(of: MyTabBarController.self)
            .selectTab(with: .index(1))
    }
    

    Declaration

    Swift

    public func tabs<Output: UITabBarController>(
        of type: Output.Type
    ) -> ScreenRoute<Root, Output>

    Parameters

    type

    The type to which the container will be cast.

    Return Value

    An instance containing the new action.

  • tabs(of:route:) Extension method

    Retrieves the nearest ancestor in the container hierarchy that is a tabs container.

    Usage examples

    • Selects tab from the tab container of the current container:
    let nestedRoute = ScreenTabsRoute.selectTab(with: .index(1))
    
    navigator.navigate(from: container) { route in
        route.tabs(route: nestedRoute)
    }
    

    Declaration

    Swift

    public func tabs<Output: UITabBarController, Route: ScreenThenable>(
        of type: Output.Type = Output.self,
        route: Route
    ) -> Self where Route.Root == Output

    Parameters

    type

    The type to which the container will be cast.

    route

    The route that will be performed in the retrieved screen container.

    Return Value

    An instance containing the new action.

  • tabs(of:route:) Extension method

    Retrieves the nearest ancestor in the container hierarchy that is a tabs container.

    Usage examples

    • Selects tab from the tab container of the current container:
    navigator.navigate(from: container) { route in
        route.tabs(route: nestedRoute) { $0.selectTab(with: .index(1)) }
    }
    

    Declaration

    Swift

    public func tabs<Output: UITabBarController>(
        of type: Output.Type = Output.self,
        route: (_ route: ScreenRootRoute<Output>) -> ScreenRouteConvertible
    ) -> Self

    Parameters

    type

    The type to which the container will be cast.

    route

    The closure that should return the modified route that will be performed in the retrieved screen container.

    Return Value

    An instance containing the new action.

Available where Current: UINavigationController

Available where Current: UITabBarController

Available where Current: UIWindow