TabBarViewDestinationable
@MainActor
public protocol TabBarViewDestinationable<PresentationConfiguration, TabType> : GroupedDestinationable, ViewDestinationable where Self.TabType == Self.ViewType.TabType, Self.ViewType : TabBarViewDestinationInterfacing
This protocol represents a Destination whose interface view handles a TabBar
.
-
A dictionary of top-level Destination identifiers whose keys are their associated tab types.
Declaration
Swift
@MainActor var destinationIDsForTabs: [TabType : UUID] { get set }
-
A representation of the tabs that are currently active.
Declaration
Swift
@MainActor var activeTabs: [TabModel<TabType>] { get set }
-
The currently selected tab type. This property should be watched by the associated
TabView
‘s selection state.Declaration
Swift
@MainActor var selectedTab: TabModel<TabType> { get set }
-
A closure to be run when a Destination is presented in a tab.
Declaration
Swift
@MainActor var destinationPresentationClosure: TabBarViewDestinationPresentationClosure<PresentationConfiguration>? { get set }
-
A closure to be run when the
selectedTab
property changed.Declaration
Swift
@MainActor var selectedTabUpdatedClosure: TabBarViewSelectedTabUpdatedClosure<TabType>? { get set }
-
tab(destinationID:
Default implementation) Returns a tab type based on its associated Destination identifier.
Default Implementation
Declaration
Swift
@MainActor func tab(destinationID: UUID) -> TabType?
Parameters
destinationID
The Destination identifier.
Return Value
A tab type, if one was found.
-
tab(for:
Default implementation) Returns a tab model for its associated type.
Default Implementation
Declaration
Swift
@MainActor func tab(for type: TabType) -> TabModel<TabType>?
Parameters
type
The type of tab.
Return Value
A tab model, if one was found in the
activeTabs
array. -
tabIndex(for:
Default implementation) Returns the index of the specified tab in the
activeTabs
array.Default Implementation
Declaration
Swift
@MainActor func tabIndex(for type: TabType) -> Int?
Parameters
type
The tab type.
Return Value
An array index, if the tab was found in the array.
-
assignSelectedTabUpdatedClosure(closure:
Default implementation) Assigns the closure to be run when the selected tab changes.
Default Implementation
Declaration
Swift
@MainActor func assignSelectedTabUpdatedClosure(closure: @escaping TabBarViewSelectedTabUpdatedClosure<TabType>)
Parameters
closure
The closure to run.
-
updateSelectedTab(type:
Default implementation) Update the currently selected tab.
Default Implementation
Declaration
Swift
@MainActor func updateSelectedTab(type: TabType) throws
Parameters
tab
The tab type to select.
-
currentDestination(for:
Default implementation) Returns the current Destination for the specified tab.
Default Implementation
Declaration
Swift
@MainActor func currentDestination(for tab: TabType) -> (any ViewDestinationable<PresentationConfiguration>)?
Parameters
tab
The tab type.
Return Value
A
View
-based Destination, if one was found. -
rootDestination(for:
Default implementation) Returns the root Destination for the tab. This is not necessarily the Destination representing the currently visible
View
in a tab, but is instead theView
which is at the root level of the column, such as aNavigationStack
.This method should be used when building the tabs for a
TabView
.Default Implementation
Declaration
Swift
@MainActor func rootDestination(for tab: TabType) -> (any ViewDestinationable<PresentationConfiguration>)?
Parameters
tab
A tab type.
Return Value
A Destination, if one was found.
-
presentDestination(destination:
Default implementationin: shouldUpdateSelectedTab: presentationOptions: removeDestinationFromFlowClosure: ) Presents a Destination in a tab.
Note
This method will throw an error if the requested tab is not found.Default Implementation
Declaration
Swift
@MainActor func presentDestination(destination: any ViewDestinationable<PresentationConfiguration>, in tab: TabType, shouldUpdateSelectedTab: Bool, presentationOptions: NavigationStackPresentationOptions?, removeDestinationFromFlowClosure: RemoveDestinationFromFlowClosure?) throws
Parameters
destination
A SwiftUI-based Destination to be presented.
tab
The tab type to present this Destination in.
shouldUpdateSelectedTab
Determines whether the selected tab should be updated.
presentationOptions
A model which provides options for presenting this Destination within the tab when this tab includes a
NavigationStack
, including determining whether the presentation should be animated. -
assignPresentationClosure(closure:
Default implementation) Assigns a presentation closure to be run when a Destination is presented in a tab.
Default Implementation
Declaration
Swift
@MainActor func assignPresentationClosure(closure: @escaping TabBarViewDestinationPresentationClosure<PresentationConfiguration>)
Parameters
closure
The closure to run.
-
destinationIdentifier(for:
Default implementation) Returns the identifier of the top-level Destination associated with this tab.
Default Implementation
Declaration
Swift
@MainActor func destinationIdentifier(for tab: TabType) -> UUID?
Parameters
tab
The type of tab.
Return Value
An identifier for the Destination, if one was found.
-
updateTabViews(destinationIDs:
Default implementationfor: ) Updates multiple Destinations in the specified tabs.
Default Implementation
Declaration
Swift
@MainActor func updateTabViews(destinationIDs: [UUID], for tabs: [TabModel<TabType>])
Parameters
destinationIDs
An array of Destination identifiers
tabs
The tabs whose
View
stacks should be replaced. -
supportsIgnoringCurrentDestinationStatus
Extension methodDeclaration
Swift
@MainActor var supportsIgnoringCurrentDestinationStatus: Bool { get }
-
replaceChild(currentID:
Extension methodwith: removeDestinationFromFlowClosure: ) Declaration
Swift
@MainActor func replaceChild(currentID: UUID, with newDestination: any Destinationable<PresentationConfiguration>, removeDestinationFromFlowClosure: RemoveDestinationFromFlowClosure? = nil)
-
updateChildren()
Extension methodDeclaration
Swift
@MainActor func updateChildren()