diff --git a/Example/SwiftUICoordinatorExample/SwiftUICoordinatorExample/Coordinators/Tabs/TabsCoordinatorRoute.swift b/Example/SwiftUICoordinatorExample/SwiftUICoordinatorExample/Coordinators/Tabs/TabsCoordinatorRoute.swift index 73786af..2bb8001 100644 --- a/Example/SwiftUICoordinatorExample/SwiftUICoordinatorExample/Coordinators/Tabs/TabsCoordinatorRoute.swift +++ b/Example/SwiftUICoordinatorExample/SwiftUICoordinatorExample/Coordinators/Tabs/TabsCoordinatorRoute.swift @@ -35,8 +35,4 @@ enum TabsCoordinatorRoute: TabBarNavigationRoute { ) } } - - var action: TransitionAction? { - return nil - } } diff --git a/Sources/SwiftUICoordinator/Routing/Route/NavigationRoute.swift b/Sources/SwiftUICoordinator/Routing/Route/NavigationRoute.swift index a68d81e..5e75e5d 100644 --- a/Sources/SwiftUICoordinator/Routing/Route/NavigationRoute.swift +++ b/Sources/SwiftUICoordinator/Routing/Route/NavigationRoute.swift @@ -6,7 +6,6 @@ // import Foundation -import UIKit @MainActor public protocol NavigationRoute { @@ -33,9 +32,8 @@ public extension NavigationRoute { var attachCoordinator: Bool { return true } -} - -@MainActor -public protocol TabBarNavigationRoute: NavigationRoute, Hashable { - var tabBarItem: UITabBarItem { get } + + var action: TransitionAction? { + return nil + } } diff --git a/Sources/SwiftUICoordinator/Routing/Route/TabBarNavigationRoute.swift b/Sources/SwiftUICoordinator/Routing/Route/TabBarNavigationRoute.swift new file mode 100644 index 0000000..d442813 --- /dev/null +++ b/Sources/SwiftUICoordinator/Routing/Route/TabBarNavigationRoute.swift @@ -0,0 +1,13 @@ +// +// TabBarNavigationRoute.swift +// +// +// Created by Erik Drobne on 24. 6. 24. +// + +import UIKit + +@MainActor +public protocol TabBarNavigationRoute: NavigationRoute, Hashable { + var tabBarItem: UITabBarItem { get } +} diff --git a/Sources/SwiftUICoordinator/Routing/RouteHostingController.swift b/Sources/SwiftUICoordinator/Routing/RouteHostingController.swift index a698a61..1aa8a39 100644 --- a/Sources/SwiftUICoordinator/Routing/RouteHostingController.swift +++ b/Sources/SwiftUICoordinator/Routing/RouteHostingController.swift @@ -21,7 +21,7 @@ public class RouteHostingController: UIHostingController self.route = route super.init(rootView: rootView) - if let tabBarRoute = route as? (any TabBarNavigationRoute) { + if let tabBarRoute = route as? any TabBarNavigationRoute { self.tabBarItem = tabBarRoute.tabBarItem } } diff --git a/Sources/SwiftUICoordinator/TabBarCoordinator/TabBarCoordinator.swift b/Sources/SwiftUICoordinator/TabBarCoordinator/TabBarCoordinator.swift index 6c46b22..1c924da 100644 --- a/Sources/SwiftUICoordinator/TabBarCoordinator/TabBarCoordinator.swift +++ b/Sources/SwiftUICoordinator/TabBarCoordinator/TabBarCoordinator.swift @@ -8,9 +8,13 @@ public protocol TabBarCoordinator: ObservableObject { associatedtype Route: TabBarNavigationRoute var navigationController: NavigationController { get } + /// The tab bar controller that manages the tab bar interface. var tabBarController: UITabBarController { get } + /// The tabs available in the tab bar interface, represented by `Route` types. var tabs: [Route] { get } - /// This method should be called to show the `tabBarController` + /// This method should be called to show the `tabBarController`. + /// + /// - Parameter action:The type of transition can be customized by providing a `TransitionAction`. func start(with action: TransitionAction) }