Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access MainTabBarController through an abstraction #14062

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WooCommerce/Classes/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

/// Tab Bar Controller
///
var tabBarController: MainTabBarController? {
var tabBarController: MainTabBarControllerProtocol? {
appCoordinator?.tabBarController
}

Expand Down Expand Up @@ -203,7 +203,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
switch quickAction {
case QuickAction.addProduct:
MainTabBarController.presentAddProductFlow()
tabBarController.presentAddProductFlow()
completionHandler(true)
case QuickAction.addOrder:
tabBarController.navigate(to: OrdersDestination.createOrder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private extension StorePickerCoordinator {
switchStoreUseCase.switchStore(with: storeID) { [weak self] siteChanged in
guard let self = self else { return }
if self.selectedConfiguration == .login {
MainTabBarController.switchToMyStoreTab(animated: true)
AppDelegate.shared.tabBarController?.switchToMyStoreTab(animated: true)
}

if siteChanged {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private extension DefaultBlazeLocalNotificationScheduler {
guard let self, await isEligibleForBlaze() else {
return
}
MainTabBarController.navigateToBlazeCampaignCreation(for: siteID)
AppDelegate.shared.tabBarController?.navigateToBlazeCampaignCreation(for: siteID)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import Combine

extension UniversalLinkRouter {
static func justInTimeMessagesUniversalLinkRouter(tabBarController: MainTabBarController?,
static func justInTimeMessagesUniversalLinkRouter(tabBarController: MainTabBarControllerProtocol?,
urlOpener: URLOpener) -> UniversalLinkRouter {
UniversalLinkRouter(routes: Self.defaultRoutes(navigator: tabBarController),
bouncingURLOpener: urlOpener,
Expand Down
2 changes: 1 addition & 1 deletion WooCommerce/Classes/Notifications/ApplicationAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension UIApplication: ApplicationAdapter {
/// Presents the Details for the specified Notification
///
func presentNotificationDetails(notification: WooCommerce.PushNotification) {
MainTabBarController.switchStoreIfNeededAndPresentNotificationDetails(notification: notification)
AppDelegate.shared.tabBarController?.switchStoreIfNeededAndPresentNotificationDetails(notification: notification)
}

/// Presents a given Message with an "In App" notification
Expand Down
8 changes: 4 additions & 4 deletions WooCommerce/Classes/Spotlight/SpotlightManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ struct SpotlightManager {
var type: WooActivityType?
switch userActivity.activityType {
case WooActivityType.dashboard.rawValue:
MainTabBarController.switchToMyStoreTab()
AppDelegate.shared.tabBarController?.switchToMyStoreTab(animated: false)
type = WooActivityType.dashboard
case WooActivityType.orders.rawValue:
MainTabBarController.switchToOrdersTab()
AppDelegate.shared.tabBarController?.switchToOrdersTab(completion: nil)
type = WooActivityType.orders
case WooActivityType.products.rawValue:
MainTabBarController.switchToProductsTab()
AppDelegate.shared.tabBarController?.switchToProductsTab(completion: nil)
type = WooActivityType.products
case WooActivityType.payments.rawValue:
MainTabBarController.presentPayments()
AppDelegate.shared.tabBarController?.presentPayments()
type = WooActivityType.payments
default:
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct MyStoreRoute: Route {
}

func perform(for subPath: String, with parameters: [String: String]) -> Bool {
MainTabBarController.switchToMyStoreTab()
AppDelegate.shared.tabBarController?.switchToMyStoreTab(animated: false)

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct OrderDetailsRoute: Route {
return false
}

MainTabBarController.navigateToOrderDetails(with: orderId, siteID: storeId)
AppDelegate.shared.tabBarController?.navigateToOrderDetails(with: orderId, siteID: storeId)

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct UniversalLinkRouter {
return false
}

static func defaultUniversalLinkRouter(tabBarController: MainTabBarController) -> UniversalLinkRouter {
static func defaultUniversalLinkRouter(tabBarController: MainTabBarControllerProtocol) -> UniversalLinkRouter {
UniversalLinkRouter(routes: UniversalLinkRouter.defaultRoutes(navigator: tabBarController))
}

Expand Down
2 changes: 1 addition & 1 deletion WooCommerce/Classes/ViewRelated/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import protocol Storage.StorageManagerType
import protocol WooFoundation.Analytics

final class AppCoordinator {
let tabBarController: MainTabBarController
let tabBarController: MainTabBarControllerProtocol

private let window: UIWindow
private let stores: StoresManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ final class CustomerDetailViewModel: ObservableObject {
guard canCreateNewOrder else {
return
}
MainTabBarController.presentOrderCreationFlow(for: customerID, billing: billing, shipping: shipping)
AppDelegate.shared.tabBarController?.presentOrderCreationFlow(for: customerID, billing: billing, shipping: shipping)
ServiceLocator.analytics.track(event: .CustomersHub.customerDetailNewOrder())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,12 @@ private extension DashboardViewHostingController {
private extension DashboardViewHostingController {
func configureLastOrdersView() {
rootView.onViewAllOrders = {
MainTabBarController.switchToOrdersTab()
AppDelegate.shared.tabBarController?.switchToOrdersTab(completion: nil)
}

rootView.onViewOrderDetail = { [weak self] order in
guard let self else { return }
MainTabBarController.navigateToOrderDetails(with: order.orderID, siteID: viewModel.siteID)
AppDelegate.shared.tabBarController?.navigateToOrderDetails(with: order.orderID, siteID: viewModel.siteID)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class PrivacyBannerPresenter {
case .success(let destination):
viewController.dismiss(animated: true)
if destination == .settings {
MainTabBarController.navigateToPrivacySettings()
AppDelegate.shared.tabBarController?.navigateToPrivacySettings()
}

case .failure(let error):
Expand All @@ -57,7 +57,7 @@ final class PrivacyBannerPresenter {
/// Even if we fail, we should redirect the user to settings screen so they can further customize their privacy settings
///
if intendedDestination == .settings {
MainTabBarController.navigateToPrivacySettings()
AppDelegate.shared.tabBarController?.navigateToPrivacySettings()
}
}
}
Expand Down
Loading