Skip to content
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// periphery:ignore:all
import Foundation
import Yosemite
import Experiments
Expand Down
46 changes: 46 additions & 0 deletions WooCommerce/Classes/Bookings/BookingsTabView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import SwiftUI

/// Hosting view for `BookingsTabView`
///
final class BookingsTabViewHostingController: UIHostingController<BookingsTabView> {
// periphery: ignore
init(siteID: Int64) {
super.init(rootView: BookingsTabView())
configureTabBarItem()
}

@MainActor @preconcurrency required dynamic init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override var shouldShowOfflineBanner: Bool {
return true
}

func didSwitchStore(id: Int64) {
// TODO: update view
}
}

private extension BookingsTabViewHostingController {
func configureTabBarItem() {
tabBarItem.image = UIImage(systemName: "calendar")
tabBarItem.title = "Bookings"
tabBarItem.accessibilityIdentifier = "tab-bar-bookings-item"
}
}

/// Main content of the Bookings tab
///
struct BookingsTabView: View {
@State private var visibility: NavigationSplitViewVisibility = .all

var body: some View {
NavigationSplitView(columnVisibility: $visibility) {
Text("Booking List")
} detail: {
Text("Booking Detail Screen")
}
.navigationSplitViewStyle(.balanced)
}
}
49 changes: 46 additions & 3 deletions WooCommerce/Classes/POS/TabBar/POSTabCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class POSTabViewController: UIViewController {
/// Coordinator for the Point of Sale tab.
///
final class POSTabCoordinator {
private let siteID: Int64
private(set) var siteID: Int64
private let tabContainerController: TabContainerController
private let viewControllerToPresent: UIViewController
private let storesManager: StoresManager
Expand Down Expand Up @@ -107,12 +107,55 @@ final class POSTabCoordinator {
}

func onTabSelected() {
presentPOSView()
presentPOSView(siteID: siteID)
}

func didSwitchStore(id: Int64) {
self.siteID = id

// Resets lazy properties so they get recreated with new siteID
posItemFetchStrategyFactory = PointOfSaleItemFetchStrategyFactory(
siteID: siteID,
credentials: credentials,
selectedSite: defaultSitePublisher,
appPasswordSupportState: isAppPasswordSupported
)

posPopularItemFetchStrategyFactory =
PointOfSaleFixedItemFetchStrategyFactory(
fixedStrategy: posItemFetchStrategyFactory.popularStrategy()
)

posCouponFetchStrategyFactory = PointOfSaleCouponFetchStrategyFactory(
siteID: siteID,
currencySettings: currencySettings,
credentials: credentials,
selectedSite: defaultSitePublisher,
appPasswordSupportState: isAppPasswordSupported,
storage: storageManager
)

posCouponProvider = PointOfSaleCouponService(
siteID: siteID,
currencySettings: currencySettings,
credentials: credentials,
selectedSite: defaultSitePublisher,
appPasswordSupportState: isAppPasswordSupported,
storage: storageManager
)

barcodeScanService = PointOfSaleBarcodeScanService(
siteID: siteID,
credentials: credentials,
selectedSite: defaultSitePublisher,
appPasswordSupportState: isAppPasswordSupported,
currencySettings: currencySettings
)
}
}

private extension POSTabCoordinator {
func presentPOSView() {
func presentPOSView(siteID: Int64) {
Task { @MainActor [weak self] in
guard let self else { return }
let serviceAdaptor = POSServiceLocatorAdaptor()
Expand Down
Loading