DestinationPresentation
@MainActor
public final class DestinationPresentation<DestinationType, ContentType, TabType> 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.
navigationStack(type: NavigationPresentationType)This presentation type will add and present a Destination in a navigation stack such as aUINavigationControlleror SwiftUI’sNavigationStack.tabBar(tab: TabType)This presentation type will present a Destination in the specified tab of a tab bar component, such as aUITabBarControlleror SwiftUI’sTabView. If nodestinationTypeis present in theDestinationPresentationmodel, 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 aUISplitViewControlleror SwiftUI’sNavigationSplitView.addToCurrentThis presentation type adds a Destination as a child of the currently-presented Destination. Note that this type only works with UIKit and utilizesUIViewController‘saddChildmethod.replaceCurrentThis 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. Theoptionsparameter allows you to customize how the sheet is presented, configuring SwiftUI-specific options with aViewSheetPresentationOptionsmodel and UIKit-specific options with aControllerSheetPresentationOptionsmodel.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. Thepresentationparameter allows you to use aCustomPresentationmodel with specialized closures to provide whatever functionality you need.
-
An enum which defines all routable Destinations in the app.
Declaration
Swift
public typealias DestinationType = DestinationType -
An enum which defines the types of content that are able to be sent through Destinations.
Declaration
Swift
public typealias ContentType = ContentType -
An enum which defines types of tabs in a tab bar.
Declaration
Swift
public typealias TabType = TabType -
A
DestinationPresentationTypeconfigured for this configuration object.Declaration
Swift
public typealias PresentationType = DestinationPresentationType<DestinationType, ContentType, 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 var presentationType: DestinationPresentationType<DestinationType, ContentType, TabType> -
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
InterfaceActionassistant 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
DestinationPathNavigatingobject associated with the Destination to be presented.Declaration
Swift
@MainActor public weak var navigator: (any DestinationPathNavigating)? -
An options model that configures how a Destination is presented within a navigation stack, either for SwiftUI’s
NavigationStackor 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
TabBarViewDestinationableobject, should one currently exist in the UI hierarchy.Declaration
Swift
@MainActor public weak var tabBarDestination: (any TabBarViewDestinationable<DestinationType, ContentType, TabType>)? -
A reference to a
TabBarControllerDestinationableobject, should one currently exist in the UI hierarchy.Declaration
Swift
@MainActor public weak var tabBarControllerDestination: (any TabBarControllerDestinationable<DestinationType, ContentType, TabType>)? -
A Boolean which determines whether the activation of the presentation’s completion closure, referenced in the
completionClosureproperty, 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
FlowableandGroupedDestinationableobjects 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
GroupedDestinationableobject, 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 tofalsecan have side effects on the presentation of future Destinations withinGroupedDestinationableobjects whose placement depends on the location of a previous Destination. For example, if you present a Destination in a non-active child of aGroupedDestinationableobject with this property set tofalse, then present another Destination with apresentationTypeofnavigationStack, 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 apresentationTypeon 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)? -
Undocumented
Declaration
Swift
@MainActor public var removalClosure: (() -> 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
destinationTypeThe type of Destination to present.
presentationTypeThe type of Destination presentation.
contentTypeThe type of content.
actionTypeThe type of presentation action.
actionTargetIDThe target identifier for the presentation action.
assistantTypeThe type of assistant for the presentation.
currentDestinationIDThe identifier of the currently presented Destination.
parentDestinationIDThe identifier of the parent of the current Destination.
navigatorThe
DestinationPathNavigatingobject associated with the Destination to be presented.shouldDelayCompletionActivationDetermines whether the activation of the presentation’s completion closure, referenced in the
completionClosureproperty, should be delayed.completionClosureA completion closure which should be run upon completion of the presentation of the Destination.
-
Undocumented
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<DestinationType, ContentType, TabType>)? = nil, currentDestination: (any ViewDestinationable<DestinationType, ContentType, TabType>)?, parentOfCurrentDestination: (any ViewDestinationable)?, removeDestinationClosure: RemoveDestinationFromFlowClosure?)Parameters
destinationToPresentThe
ViewDestinationableDestination to present.currentDestinationA
ViewDestinationableobject, representing the currently presented Destination.parentOfCurrentDestinationA
ViewDestinationableobject, representing the parent of the current Destination.removeDestinationClosureAn 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<DestinationType, ContentType, TabType>)? = nil, rootController: (any ControllerDestinationInterfacing)? = nil, currentDestination: (any ControllerDestinationable)? = nil, parentOfCurrentDestination: (any ControllerDestinationable)? = nil, removeDestinationClosure: RemoveDestinationFromFlowClosure? = nil)Parameters
destinationToPresentThe
ControllerDestinationableDestination to present.rootControllerA
ControllerDestinationInterfacingobject representing the root of the UI hierarchy.currentDestinationA
ControllerDestinationableobject, representing the currently presented Destination.parentOfCurrentDestinationA
ControllerDestinationableobject, representing the parent of the current Destination.removeDestinationClosureAn 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
View on GitHub