TabBarControllerDestinationable
@MainActor
public protocol TabBarControllerDestinationable<DestinationType, ContentType, TabType> : GroupedControllerDestinationable
This protocol represents a Destination whose interface is a UITabBarController.
-
A dictionary of Destination identifiers whose keys are their associated tab types.
Declaration
Swift
@MainActor var destinationIDsForTabs: [TabType : UUID] { get set } -
A representation of the tab types that are currently active.
Declaration
Swift
@MainActor var activeTabs: [TabModel<TabType>] { get set } -
The currently selected tab type.
Declaration
Swift
@MainActor var selectedTab: TabModel<TabType> { get set } -
Update the currently selected tab.
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 ControllerDestinationable<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
UIViewControllerin a tab, but is instead theUIViewControllerwhich is at the root level of the column, such as aUINavigationController.This method should be used when building the tabs for a
UITabViewController.Default Implementation
Declaration
Swift
@MainActor func rootDestination(for tab: TabType) -> (any ControllerDestinationable<DestinationType, ContentType, TabType>)?Parameters
tabA tab type.
Return Value
A Destination, if one was found.
-
A closure to be run when the
selectedTabproperty changed.Declaration
Swift
@MainActor var selectedTabUpdatedClosure: TabBarControllerSelectedTabUpdatedClosure<TabType>? { get set } -
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 ControllerDestinationable<DestinationType, ContentType, TabType>, in tab: TabType, shouldUpdateSelectedTab: Bool, presentationOptions: NavigationStackPresentationOptions?, removeDestinationFromFlowClosure: RemoveDestinationFromFlowClosure?) throwsParameters
destinationA UIKit-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 in the
UINavigationControllerwithin the tab, including determining whether the presentation should be animated. -
tab(destinationID:Default implementation) Returns a tab 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. -
tab(containing:Default implementation) Returns the tab which contains the specified
UIViewController.Default Implementation
Declaration
Swift
@MainActor func tab(containing controllerToMatch: UIViewController) -> TabType?Parameters
controllerToMatchA controller to find.
Return Value
A tab type, if one was found.
-
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 TabBarControllerSelectedTabUpdatedClosure<TabType>)Parameters
closureThe closure to run.
-
Updates multiple Destinations in the specified tabs.
Declaration
Swift
@MainActor func updateTabControllers(destinations: [any ControllerDestinationable<DestinationType, ContentType, TabType>], for tabs: [TabModel<TabType>])Parameters
destinationsAn array of Destinations
tabsThe tabs whose
UIViewControllerstacks should be replaced. -
findDestination(typeToFind:Default implementationcurrentLevel: ) Finds a Destination of the specified type within the children of this
UITabBarController.Default Implementation
Declaration
Swift
@MainActor func findDestination(typeToFind: DestinationType, currentLevel: any ControllerDestinationable<DestinationType, ContentType, TabType>) -> (any ControllerDestinationable<DestinationType, ContentType, TabType>)?Parameters
typeToFindThe type of Destination to find.
currentLevelThe current level of the view hierarchy to search at.
Return Value
A Destination of the specified type, if one was found.
-
supportsIgnoringCurrentDestinationStatusExtension methodUndocumented
Declaration
Swift
@MainActor var supportsIgnoringCurrentDestinationStatus: Bool { get } -
Declaration
Swift
@MainActor func addChild(childDestination: any Destinationable<DestinationType, ContentType, TabType>, shouldSetDestinationAsCurrent: Bool? = true, shouldAnimate: Bool? = true) -
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