ContainerAdapter
public protocol ContainerAdapter
Provides universal properties and methods of the ContainerViewController
instance.
ContainerViewController
s 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.
-
All
UIViewController
instances that adaptingContainerViewController
currently has in the stackDeclaration
Swift
var containedViewControllers: [UIViewController] { get }
-
The
UIViewController
instances out of thecontainedViewControllers
that are currently visible on the screen ThevisibleViewControllers
are the subset of thecontainedViewControllers
.Declaration
Swift
var visibleViewControllers: [UIViewController] { get }
-
Each container view controller adapter should implement this method for the
Router
to know how to make its particular child view controller visible.NB:
completion
block must be called.Declaration
Swift
func makeVisible(_ viewController: UIViewController, animated: Bool, completion: @escaping (RoutingResult) -> Void)
Parameters
viewController
The
UIViewController
to make active (visible).animated
If
ContainerViewController
is able to do so - make container active animated or not. -
Each container view controller adapter should implement this method for the
Router
to know how to replace all the view controllers in this particular container view controller.NB:
completion
block must be called.Declaration
Swift
func setContainedViewControllers(_ containedViewControllers: [UIViewController], animated: Bool, completion: @escaping (RoutingResult) -> Void)
Parameters
containedViewControllers
A
UIViewController
instances to replace.animated
If
ContainerViewController
is 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
func contains(_ viewController: UIViewController) -> Bool
Parameters
viewController
UIViewController
instanceReturn Value
true
if present,false
otherwise. -
isVisible(_:
Extension method) Checks if the provided view controller is present amongst the visible view controllers.
Declaration
Swift
func isVisible(_ viewController: UIViewController) -> Bool
Parameters
viewController
UIViewController
instanceReturn Value
true
if present,false
otherwise.