DestinationPresentation
@MainActor
public final class DestinationPresentation<DestinationType, ContentType, TabType> : DestinationPresentationConfiguring where DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable
extension DestinationPresentation: Hashable, Equatable
This is a model used to configure how a Destination is presented or removed. It contains information such as the type of Destination to present, the type of presentation to be made, and the type of content to pass along. They are typically associated with a particular InterfaceAction
and used to trigger a new presentation when a user interaction is made with the current UI.
Destinations has several built-in presentation types which DestinationPresentation
supports to enable native SwiftUI and UIKit UI navigation, as well as more complex or custom behavior.
navigationController(type: NavigationPresentationType)
This presentation type will add and present a Destination in a navigation stack such as aUINavigationController
or SwiftUI’sNavigationStack
.tabBar(tab: TabType)
This presentation type will present a Destination in the specified tab of a tab bar component, such as aUITabBarController
or SwiftUI’sTabView
. If nodestinationType
is present in theDestinationPresentation
model, the specified tab will simply be selected, becoming the active tab within the interface.splitView(column: SplitViewColumn)
This presentation type will present a Destination in a column of a split view interface, such as aUISplitViewController
or SwiftUI’sNavigationSplitView
.addToCurrent
This presentation type adds a Destination as a child of the currently-presented Destination. Note that this type only works with UIKit and utilizesUIViewController
‘saddChild
method.replaceCurrent
This presentation type replaces the currently-presented Destination with a new Destination in system UI components which allow that.sheet(type: SheetPresentationType, options: SheetPresentationOptions?)
This presentation type presents (or dismisses) a Destination in a sheet. Theoptions
parameter allows you to customize how the sheet is presented, configuring SwiftUI-specific options with aViewSheetPresentationOptions
model and UIKit-specific options with aControllerSheetPresentationOptions
model.destinationPath(path: [DestinationPresentation])
This presentation type presents a path of multiple Destination objects, useful for providing deep linking functionality or building complex state with one user interaction.custom(presentation: CustomPresentation<DestinationPresentation>)
This presentation type enables you to present a custom presentation of a Destination. It can be used to support the presentation of custom UI, as well as system components which Destinations does not directly support. Thepresentation
parameter allows you to use aCustomPresentation
model with specialized closures to provide whatever functionality you need.
-
Declaration
Swift
public typealias DestinationType = DestinationType
-
Declaration
Swift
public typealias ContentType = ContentType
-
Declaration
Swift
public typealias TabType = TabType
-
A unique identifier.
Declaration
Swift
@MainActor public let id: UUID
-
An enum representing the type of Destination to be presented.
Declaration
Swift
@MainActor public var destinationType: DestinationType?
-
An enum type representing the way this Destination should be presented.
Declaration
Swift
@MainActor public let presentationType: DestinationPresentationType<DestinationPresentation>
-
An enum type representing the content to be used with this presentation.
Declaration
Swift
@MainActor public var contentType: ContentType?
-
An enum representing the type of action used with this presentation.
Declaration
Swift
@MainActor public var actionType: DestinationActionType
-
The unique identifier of the target of this presentation, if one exists.
Declaration
Swift
@MainActor public var actionTargetID: UUID?
-
The type of
InterfaceAction
assistant to be used to configure this presentation.Declaration
Swift
@MainActor public var assistantType: ActionAssistantType
-
The unique identifier of the currently presented Destination.
Declaration
Swift
@MainActor public var currentDestinationID: UUID?
-
The unique identifier of the parent of the Destination to be presented.
Declaration
Swift
@MainActor public var parentDestinationID: UUID?
-
The
DestinationPathNavigating
object associated with the Destination to be presented.Declaration
Swift
@MainActor public var navigator: (any DestinationPathNavigating)?
-
An options model that configures how a Destination is presented within a navigation stack, either for SwiftUI’s
NavigationStack
or UIKit’sUINavigationController
. This includes the ability to disable the system animation when the Destination is presented.Declaration
Swift
@MainActor public var navigationStackOptions: NavigationStackPresentationOptions?
-
A reference to a
TabBarViewDestinationable
object, should one currently exist in the UI hierarchy.Declaration
Swift
@MainActor public weak var tabBarDestination: (any TabBarViewDestinationable<DestinationPresentation, TabType>)?
-
A reference to a
TabBarControllerDestinationable
object, should one currently exist in the UI hierarchy.Declaration
Swift
@MainActor public weak var tabBarControllerDestination: (any TabBarControllerDestinationable<DestinationPresentation, TabType>)?
-
A Boolean which determines whether the activation of the presentation’s completion closure, referenced in the
completionClosure
property, should be delayed. The default value of this property isfalse
.Declaration
Swift
@MainActor public var shouldDelayCompletionActivation: Bool
-
A Boolean which determines whether the Destination configured by this presentation should become the current one within the
Flowable
andGroupedDestinationable
objects which manage it. Custom classes which conform to one of these protocols should handle this property appropriately. The default value of this property istrue
.The Destinations protocols and classes which handle UINavigationControllers/NavigationStacks and UITabController/TabBars ignore this property. Custom classes which conform to one of these protocols should handle this property appropriately, though generally speaking if a Destination is added to a
GroupedDestinationable
object, it would be a good user experience for that Destination to become the focus. This may vary based on how your custom group’s children are displayed to the user.Important
Setting this property tofalse
can have side effects on the presentation of future Destinations withinGroupedDestinationable
objects whose placement depends on the location of a previous Destination. For example, if you present a Destination in a non-active child of aGroupedDestinationable
object with this property set tofalse
, then present another Destination with apresentationType
ofnavigationController
, depending on how you handle this property the Destination may not be put into the same child of the group because the active child will be different than if this property had beentrue
. To overcome this, you would need to use apresentationType
on the second presentation that targets the same child directly.Declaration
Swift
@MainActor public var shouldSetDestinationAsCurrent: Bool
-
A completion closure which should be run upon completion of the presentation of the Destination.
Declaration
Swift
@MainActor public var completionClosure: ((Bool) -> Void)?
-
init(destinationType:
presentationType: contentType: actionType: actionTargetID: assistantType: currentDestinationID: parentDestinationID: navigator: navigationStackOptions: shouldDelayCompletionActivation: completionClosure: ) Initializer.
Declaration
Swift
@MainActor public init(destinationType: DestinationType? = nil, presentationType: PresentationType, contentType: ContentType? = nil, actionType: DestinationActionType = .presentation, actionTargetID: UUID? = nil, assistantType: ActionAssistantType, currentDestinationID: UUID? = nil, parentDestinationID: UUID? = nil, navigator: (any DestinationPathNavigating)? = nil, navigationStackOptions: NavigationStackPresentationOptions? = nil, shouldDelayCompletionActivation: Bool? = false, completionClosure: ((Bool) -> Void)? = nil)
Parameters
destinationType
The type of Destination to present.
presentationType
The type of Destination presentation.
contentType
The type of content.
actionType
The type of presentation action.
actionTargetID
The target identifier for the presentation action.
assistantType
The type of assistant for the presentation.
currentDestinationID
The identifier of the currently presented Destination.
parentDestinationID
The identifier of the parent of the current Destination.
navigator
The
DestinationPathNavigating
object associated with the Destination to be presented.shouldDelayCompletionActivation
Determines whether the activation of the presentation’s completion closure, referenced in the
completionClosure
property, should be delayed.completionClosure
A completion closure which should be run upon completion of the presentation of the Destination.
-
Declaration
Swift
@MainActor public func copy() -> DestinationPresentation<DestinationType, ContentType, TabType>
-
handlePresentation(destinationToPresent:
currentDestination: parentOfCurrentDestination: removeDestinationClosure: ) Handles the presentation of a SwiftUI-based Destination.
Declaration
Swift
@MainActor public func handlePresentation(destinationToPresent: (any ViewDestinationable<DestinationPresentation>)? = nil, currentDestination: (any ViewDestinationable<DestinationPresentation>)?, parentOfCurrentDestination: (any ViewDestinationable)?, removeDestinationClosure: RemoveDestinationFromFlowClosure?)
Parameters
destinationToPresent
The
ViewDestinationable
Destination to present.currentDestination
A
ViewDestinationable
object, representing the currently presented Destination.parentOfCurrentDestination
A
ViewDestinationable
object, representing the parent of the current Destination.removeDestinationClosure
An optional closure to the run when the Destination is removed from the UI hierarchy.
-
handlePresentation(destinationToPresent:
rootController: currentDestination: parentOfCurrentDestination: removeDestinationClosure: ) Handles the presentation of a UIKit-based Destination.
Declaration
Swift
@MainActor public func handlePresentation(destinationToPresent: (any ControllerDestinationable<DestinationPresentation>)? = nil, rootController: (any ControllerDestinationInterfacing)? = nil, currentDestination: (any ControllerDestinationable)? = nil, parentOfCurrentDestination: (any ControllerDestinationable)? = nil, removeDestinationClosure: RemoveDestinationFromFlowClosure? = nil)
Parameters
destinationToPresent
The
ControllerDestinationable
Destination to present.rootController
A
ControllerDestinationInterfacing
object representing the root of the UI hierarchy.currentDestination
A
ControllerDestinationable
object, representing the currently presented Destination.parentOfCurrentDestination
A
ControllerDestinationable
object, representing the parent of the current Destination.removeDestinationClosure
An optional closure to the run when the Destination is removed from the UI hierarchy.
-
Declaration
Swift
nonisolated public func hash(into hasher: inout Hasher)
-
Declaration
Swift
nonisolated public static func == (lhs: DestinationPresentation, rhs: DestinationPresentation) -> Bool