ContainerAdapter
@MainActor
public protocol ContainerAdapter
Provides universal properties and methods of the ContainerViewController instance.
ContainerViewControllers are different from the simple ones in that they can contain child view controllers which
are also containers or simple ones. These view controllers are available out of the box: UINavigationController,
UITabBarController and so on, but there can be custom ones created as well.
All the container view controller have the following properties:
- The list of all the view controllers that they contain.
- One or more view controllers are currently visible.
- They can make one of these view controllers visible.
- They can replace all of their contained view controllers.
-
overriddenParentViewControllerDefault implementationProvides an ability to override default parent.
nilmeans use default parent of theUIViewController.Default Implementation
Defaults to
nil.Declaration
Swift
@MainActor var overriddenParentViewController: UIViewController? { get } -
All
UIViewControllerinstances that adaptingContainerViewControllercurrently has in the stackDeclaration
Swift
@MainActor var containedViewControllers: [UIViewController] { get } -
The
UIViewControllerinstances out of thecontainedViewControllersthat are currently visible on the screen ThevisibleViewControllersare the subset of thecontainedViewControllers.Declaration
Swift
@MainActor var visibleViewControllers: [UIViewController] { get }
-
Each container view controller adapter should implement this method for the
Routerto know how to make its particular child view controller visible.NB:
completionblock must be called.Declaration
Swift
@MainActor func makeVisible(_ viewController: UIViewController, animated: Bool, completion: @escaping (RoutingResult) -> Void)Parameters
viewControllerThe
UIViewControllerto make active (visible).animatedIf
ContainerViewControlleris able to do so - make container active animated or not. -
Each container view controller adapter should implement this method for the
Routerto know how to replace all the view controllers in this particular container view controller.NB:
completionblock must be called.Declaration
Swift
@MainActor func setContainedViewControllers(_ containedViewControllers: [UIViewController], animated: Bool, completion: @escaping (RoutingResult) -> Void)Parameters
containedViewControllersA
UIViewControllerinstances to replace.animatedIf
ContainerViewControlleris able to do so - replace contained view controllers animated or not.
-
contains(_:Extension method) Checks if the provided view controller is present amongst the contained view controllers.
Declaration
Swift
@MainActor func contains(_ viewController: UIViewController) -> BoolParameters
viewControllerUIViewControllerinstanceReturn Value
trueif present,falseotherwise. -
isVisible(_:Extension method) Checks if the provided view controller is present amongst the visible view controllers.
Declaration
Swift
@MainActor func isVisible(_ viewController: UIViewController) -> BoolParameters
viewControllerUIViewControllerinstanceReturn Value
trueif present,falseotherwise.