GroupedDestinationable
@MainActor
public protocol GroupedDestinationable<PresentationConfiguration> : AnyObject
This protocol represents a type of Destination which manages child Destinations, such as a NavigationStack
in SwiftUI.
-
An enum which defines all routable Destinations in the app.
Declaration
Swift
associatedtype DestinationType where Self.DestinationType == Self.PresentationConfiguration.DestinationType
-
An enum which defines types of tabs in a tab bar.
Declaration
Swift
associatedtype TabType where Self.TabType == Self.PresentationConfiguration.TabType
-
An enum which defines available Destination presentation types. Typically this is
DestinationPresentationType
.Declaration
Swift
associatedtype PresentationType : DestinationPresentationTypeable
-
An enum which defines the types of content that are able to be sent through Destinations.
Declaration
Swift
associatedtype ContentType where Self.ContentType == Self.PresentationConfiguration.ContentType
-
A model type which configures Destination presentations. Typically this is a
DestinationPresentation
.Declaration
Swift
associatedtype PresentationConfiguration : DestinationPresentationConfiguring
-
The unique identifier for this Destination.
Declaration
Swift
@MainActor var id: UUID { get }
-
An array of the child Destinations this object manages.
Declaration
Swift
@MainActor var childDestinations: [any Destinationable<PresentationConfiguration>] { get set }
-
The child Destination which currently has focus within this Destination’s children.
Declaration
Swift
@MainActor var currentChildDestination: (any Destinationable<PresentationConfiguration>)? { get set }
-
Determines whether this Destination supports the
shouldSetDestinationAsCurrent
parameter of theaddChild
method. If this Destination should ignore requests to not make added children the current Destination, this property should be set tofalse
.Declaration
Swift
@MainActor var supportsIgnoringCurrentDestinationStatus: Bool { get }
-
A closure run when a child Destination is removed from this Group.
Declaration
Swift
@MainActor var childWasRemovedClosure: GroupChildRemovedClosure? { get set }
-
A closure run when the current child Destination has changed.
Declaration
Swift
@MainActor var currentDestinationChangedClosure: GroupCurrentDestinationChangedClosure? { get set }
-
assignChildRemovedClosure(closure:
Default implementation) Assigns a closure to be run when a child Destination is removed from this Group. This closure should be used by an associated Destination to respond to child removals that happened internally.
Default Implementation
Declaration
Swift
@MainActor func assignChildRemovedClosure(closure: @escaping GroupChildRemovedClosure)
Parameters
closure
A closure.
-
assignCurrentDestinationChangedClosure(closure:
Default implementation) Assigns a closure to be run when the current child Destination has changed. This closure should be used by an associated Destination to respond to current Destination changes that happened internally.
Default Implementation
Declaration
Swift
@MainActor func assignCurrentDestinationChangedClosure(closure: @escaping GroupCurrentDestinationChangedClosure)
Parameters
closure
A closure.
-
addChild(childDestination:
Default implementationshouldSetDestinationAsCurrent: shouldAnimate: ) Adds a child Destination to this group.
Default Implementation
Declaration
Swift
@MainActor func addChild(childDestination: any Destinationable<PresentationConfiguration>, shouldSetDestinationAsCurrent: Bool?, shouldAnimate: Bool?)
Parameters
childDestination
A
Destinationable
object to add.shouldSetDestinationAsCurrent
A Boolean which determines whether this Destination should become the current one.
shouldAnimate
A Boolean which determines whether this Destination should be animated when presented in the Group.
-
removeChild(identifier:
Default implementationremoveDestinationFromFlowClosure: ) Removes a child Destination.
Default Implementation
Declaration
Swift
@MainActor func removeChild(identifier: UUID, removeDestinationFromFlowClosure: RemoveDestinationFromFlowClosure?)
Parameters
destinationIdentifier
The identifier of the Destination to remove.
- removeDestinationClosure: A closure that notifies an external object when this Destination has removed one of its children.
Typically this will be passed in when being called from a
DestinationPresentation
object, and handles the removal of the child Destination from the active Flow object. The identifier of the child that was removed should be passed in to the closure.
- removeDestinationClosure: A closure that notifies an external object when this Destination has removed one of its children.
Typically this will be passed in when being called from a
-
removeAllChildren()
Default implementationRemoves all child Destinations from this group.
Default Implementation
Declaration
Swift
@MainActor func removeAllChildren()
-
childForIdentifier(destinationIdentifier:
Default implementation) Returns the child Destination for the specified identifier.
Default Implementation
Declaration
Swift
@MainActor func childForIdentifier(destinationIdentifier: UUID) -> (any Destinationable<PresentationConfiguration>)?
Parameters
destinationIdentifier
The identifier of the child Destination.
Return Value
The child Destination, if one was found.
-
replaceCurrentDestination(with:
Default implementation) Replaces the child Destination that currently has focus.
Default Implementation
Declaration
Swift
@MainActor func replaceCurrentDestination(with newDestination: any Destinationable<PresentationConfiguration>)
Parameters
newDestination
The new
Destinationable
object that should replace the current Destination referenced bycurrentChildDestination
. -
replaceChild(currentID:
Default implementationwith: removeDestinationFromFlowClosure: ) Replaces the current child Destination.
Default Implementation
Declaration
Swift
@MainActor func replaceChild(currentID: UUID, with newDestination: any Destinationable<PresentationConfiguration>, removeDestinationFromFlowClosure: RemoveDestinationFromFlowClosure?)
Parameters
currentID
A
UUID
identifier matching the child Destination which should be replaced.newDestination
A
Destinationable
object to replace an existing child Destination.removeDestinationClosure
A closure that notifies an external object when this Destination has removed one of its children. Typically this will be passed in when being called from a
DestinationPresentation
object, and handles the removal of the child Destination from the active Flow object. The identifier of the child that was removed should be passed in to the closure. -
updateCurrentDestination(destinationID:
Default implementation) Updates the currently active Destination with an identifier of another child.
Default Implementation
Declaration
Swift
@MainActor func updateCurrentDestination(destinationID: UUID)
Parameters
destinationID
The Destination identifier to use. This Destination must be a current child.
-
updateChildren()
Default implementationProvides a method for requesting the children of a Destination group be updated in some way.
Default Implementation
Declaration
Swift
@MainActor func updateChildren()