Skip to content

Commit

Permalink
feature(tab bar coordinator): some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdrobne committed Jun 24, 2024
1 parent 2a87d7c commit bf25e0e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,4 @@ enum TabsCoordinatorRoute: TabBarNavigationRoute {
)
}
}

var action: TransitionAction? {
return nil
}
}
10 changes: 4 additions & 6 deletions Sources/SwiftUICoordinator/Routing/Route/NavigationRoute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import UIKit

@MainActor
public protocol NavigationRoute {
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class RouteHostingController<Content: View>: UIHostingController<Content>
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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit bf25e0e

Please sign in to comment.