NavigationInstruction
public enum NavigationInstruction
Used by a RoutableWithConfiguration
inside its RoutableWithConfiguration.navigationConfiguration
to describe the kind of navigation to perform when handling a NavigationRequest
.
extension ListViewController: RoutableWithConfiguration {
// needed by the `Routable` protocol
// to identify this ViewController in the hierarchy
var routeIdentifier: RouteElementIdentifier {
return "listScreen"
}
// the `NavigationRequest`s that this ViewController is handling
// with the `NavigationInstruction` to execute
var navigationConfiguration: [NavigationRequest: NavigationInstruction] {
return [
.show("addItemScreen"): .presentModally({ [unowned self] _ in
let vc = AddItemViewController(store: self.store)
return vc
})
]
}
-
Define one of the two possible behaviours when dismissing a modal ViewController:
.soft
: dismiss the ViewController but keep all the presented ViewControllers
See more.hard
: the usual UIKit behaviour, dismiss the ViewController and all the ViewControllers that is presentingDeclaration
Swift
public enum ModalDismissBehaviour
-
Push the ViewController using
UINavigationController.pushViewController(:animated:)
.Declaration
Swift
case push((_ context: Any?) -> UIViewController)
-
Pop the ViewController using
UINavigationController.popViewController(animated:)
.Declaration
Swift
case pop
-
Pops up to the root ViewController using `UINavigationcontroller.popToRootViewController(animated:)
Declaration
Swift
case popToRootViewController
-
Pops up to a ViewController using `UINavigationcontroller.popToViewController(:animated:)
Declaration
Swift
case popToViewController(identifier: RouteElementIdentifier)
-
Present the ViewController modally using
UIViewController.present(:animated:completion:)
.Declaration
Swift
case presentModally((_ context: Any?) -> UIViewController)
-
Dismiss the ViewController presented modally using
UIViewController.dismiss(animated:completion:)
.Declaration
Swift
case dismissModally(behaviour: ModalDismissBehaviour)
-
Define your custom implementation of the navigation.
Declaration
Swift
case custom(CustomNavigationOptionClosure)
-
Define your custom implementation of the navigation. If the closure returns false, the routing continues as if the navigation instruction is not defined
Declaration
Swift
case optionalCustom(OptionalCustomNavigationOptionClosure)