MwxCoordinator
public class MwxCoordinator<VM> : AnyCoordinator, ObservableObject where VM : AnyViewModel
You define the coordinator that manages the navigation
lifecycle of a view by coordinating its corresponding view model.
Implement the required viewModelType
property to provide
the view model type.
-
The published activator property which manages the the active state of link and sheet coordinators.
Note
Only works with link and sheet coordinators.Declaration
Swift
@Published public var activator: Bool { get set }
-
The published selection property which manages the the selection state of tab coordinators.
Note
Only works with tab coordinators.Declaration
Swift
@Published public var selection: Int { get set }
-
The type of view model for this coordinator.
When you create a coordinator, Swift infers this type from the generic
VM
type property.Declaration
Swift
public var viewModelType: VM.Type
-
The presentation use by the coordinator to present the view for the corresponding view model.
Declaration
Swift
public var presentation: MwxPresentation
-
The input used to initialize this view model and passed from presenting view models.
Declaration
Swift
public var input: MwxInput?
-
The callback closure that is invoked when the view for the corresponding view model disappears.
Declaration
Swift
public var onDisappear: (() -> Void)?
-
The managing coordinator that presented and is used to manage the current coordinator.
Declaration
Swift
public var managingCoordinator: AnyCoordinator?
-
The wrapper factory of the view coordinated by current defined coordinator.
Declaration
Swift
public var wrappedView: some MwxView { get }
-
The view that is of the coordinator manages its navigation lifecycle by coordinating its corresponding view model.
Declaration
Swift
public lazy var view: AnyView { get set }
-
Creates an instance of this coordinator.
Declaration
Swift
public required init(viewModelType: VM.Type, presentation: MwxPresentation, managingCoordinator: AnyCoordinator? = nil, input: MwxInput? = nil, onDisappear: @escaping () -> Void)
Parameters
viewModelType
A
Type
indicates the view type of the coordinator.presentation
A
MwxPresentation
indicates the presentation of the coordinator.managingCoordinator
A
AnyCoordinator
indicates managing coordinator of the coordinator.input
A
MwxInput
indicates the input data store of the coordinator.onDisappear
A
() -> Void
indicates the disappearance callback closure of the coordinator.
-
Call this function to show the coordinator by changing its activator state property.
Note
Only works with link and sheet coordinators.Declaration
Swift
public func show()
-
Call this function to deactivate the coordinator by changing its activator state property.
Note
Only works with link coordinators.Declaration
Swift
public func pop()
-
Call this function to deactivate the coordinator by changing its activator state property.
Note
Only works with sheet coordinators.Declaration
Swift
public func dismiss()
-
Call this function to select the tab coordinator by changing its selection state property.
Note
Works with current tab coordinator or its managing coordinator hierarchy.Declaration
Swift
public func select(tab selection: Int)
Parameters
selection
A
Int
indicates the index tag of the selected tab view item.
-
Call this function to deactivate the coordinator by changing its activator state property.
Declaration
Swift
public func deactivate()
-
Call this function to select the tab coordinator by changing its selection state property.
Note
Only works with the current tab coordinator.Declaration
Swift
public func setSelection(tab selection: Int)
Parameters
selection
A
Int
indicates the index tag of the selected tab view item.
-
Creates an instance of this coordinator.
Declaration
Swift
func onDisappear(_ onDisappear: @escaping () -> Void) -> MwxCoordinator
Parameters
onDisappear
A
() -> Void
indicates the disappearance callback closure of the coordinator.