TabBarViewDestinationable
@MainActor
public protocol TabBarViewDestinationable<DestinationType, ContentType, TabType> : GroupedViewDestinationable
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<DestinationType, ContentType, TabType>? { get set } -
A closure to be run when the
selectedTabproperty 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
destinationIDThe 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
typeThe type of tab.
Return Value
A tab model, if one was found in the
activeTabsarray. -
tabIndex(for:Default implementation) Returns the index of the specified tab in the
activeTabsarray.Default Implementation
Declaration
Swift
@MainActor func tabIndex(for type: TabType) -> Int?Parameters
typeThe 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
closureThe closure to run.
-
updateSelectedTab(type:Default implementation) Update the currently selected tab.
Default Implementation
Declaration
Swift
@MainActor func updateSelectedTab(type: TabType) throwsParameters
tabThe 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<DestinationType, ContentType, TabType>)?Parameters
tabThe 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
Viewin a tab, but is instead theViewwhich 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<DestinationType, ContentType, TabType>)?Parameters
tabA 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<DestinationType, ContentType, TabType>, in tab: TabType, shouldUpdateSelectedTab: Bool, presentationOptions: NavigationStackPresentationOptions?, removeDestinationFromFlowClosure: RemoveDestinationFromFlowClosure?) throwsParameters
destinationA SwiftUI-based Destination to be presented.
tabThe tab type to present this Destination in.
shouldUpdateSelectedTabDetermines whether the selected tab should be updated.
presentationOptionsA 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<DestinationType, ContentType, TabType>)Parameters
closureThe 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
tabThe 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
destinationIDsAn array of Destination identifiers
tabsThe tabs whose
Viewstacks should be replaced. -
supportsIgnoringCurrentDestinationStatusExtension methodUndocumented
Declaration
Swift
@MainActor var supportsIgnoringCurrentDestinationStatus: Bool { get } -
replaceChild(currentID:Extension methodwith: removeDestinationFromFlowClosure: ) Declaration
Swift
@MainActor func replaceChild(currentID: UUID, with newDestination: any Destinationable<DestinationType, ContentType, TabType>, removeDestinationFromFlowClosure: RemoveDestinationFromFlowClosure? = nil) -
updateChildren()Extension methodDeclaration
Swift
@MainActor func updateChildren()
View on GitHub