From 23c077320bf44b34cac28df0f19ad7b0a0f42172 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Fri, 26 Sep 2025 16:31:48 +0800 Subject: [PATCH 01/11] Fix a subset of Periphery warnings that are straightforward. --- .../CardPresentPaymentService.swift | 2 +- ...CollectOrderPaymentAnalyticsTracking.swift | 1 - .../POS/Analytics/POSItemFetchAnalytics.swift | 1 - .../WooAnalyticsEvent+PointOfSale.swift | 2 +- .../CardPresentPaymentPreviewService.swift | 2 +- .../CardPresentPaymentTransaction.swift | 2 +- .../PointOfSaleOrderController.swift | 1 - WooCommerce/Classes/POS/Models/Cart.swift | 15 +++-------- .../Classes/POS/Models/ItemListState.swift | 27 ------------------- .../Models/PointOfSaleAggregateModel.swift | 20 -------------- .../POS/Models/PointOfSaleErrorState.swift | 1 - ...aleBarcodeScannerButtonCustomization.swift | 7 ++--- .../PointOfSaleBarcodeScannerSetupFlow.swift | 4 --- ...OfSaleBarcodeScannerSetupFlowManager.swift | 10 +------ .../PointOfSaleItemListErrorLayout.swift | 1 - .../PointOfSalePaymentSuccessView.swift | 4 --- .../Classes/POS/Presentation/CartView.swift | 6 ----- .../Item Selector/ChildItemList.swift | 10 ------- .../POS/Presentation/ItemListView.swift | 13 ++------- .../POS/Presentation/ItemRowView.swift | 1 - ...SaleOrderSyncCouponsErrorMessageView.swift | 2 -- ...PointOfSaleOrderSyncErrorMessageView.swift | 2 -- .../PointOfSaleCollectCashView.swift | 4 --- .../Reusable Views/POSItemImageView.swift | 6 ----- .../WavesProgressViewStyle.swift | 3 +-- .../SimpleProductsOnlyInformation.swift | 5 ---- .../Classes/POS/Presentation/TotalsView.swift | 8 ------ .../Utils/Audio/PointOfSaleSoundPlayer.swift | 1 - .../Classes/POS/Utils/POSShadowStyle.swift | 4 --- .../Classes/POS/Utils/PreviewHelpers.swift | 2 -- .../AsyncPaginationTracker.swift | 5 ---- .../Mocks/MockCardPresentPaymentService.swift | 2 +- ...SCollectOrderPaymentAnalyticsTracker.swift | 4 --- 33 files changed, 14 insertions(+), 164 deletions(-) diff --git a/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift b/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift index 32062a73f7a..1f53863ca59 100644 --- a/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift +++ b/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift @@ -157,7 +157,7 @@ final class CardPresentPaymentService: CardPresentPaymentFacade { switch try await paymentTask.value { case .success: // TODO: fetch the receipt URL to return an accurate value. - let transaction = CardPresentPaymentTransaction(receiptURL: URL(string: "https://example.com")!) + let transaction = CardPresentPaymentTransaction() return .success(transaction) case .cancellation: return .cancellation diff --git a/WooCommerce/Classes/POS/Analytics/POSCollectOrderPaymentAnalyticsTracking.swift b/WooCommerce/Classes/POS/Analytics/POSCollectOrderPaymentAnalyticsTracking.swift index 2a7033743fe..e5814d13075 100644 --- a/WooCommerce/Classes/POS/Analytics/POSCollectOrderPaymentAnalyticsTracking.swift +++ b/WooCommerce/Classes/POS/Analytics/POSCollectOrderPaymentAnalyticsTracking.swift @@ -4,6 +4,5 @@ public protocol POSCollectOrderPaymentAnalyticsTracking { func trackCardReaderReady() func trackCardReaderTapped() func trackCheckoutTapped() - func resetCheckoutTapCountTracker() func trackSuccessfulCashPayment() } diff --git a/WooCommerce/Classes/POS/Analytics/POSItemFetchAnalytics.swift b/WooCommerce/Classes/POS/Analytics/POSItemFetchAnalytics.swift index 50c8ef394b2..727014568cd 100644 --- a/WooCommerce/Classes/POS/Analytics/POSItemFetchAnalytics.swift +++ b/WooCommerce/Classes/POS/Analytics/POSItemFetchAnalytics.swift @@ -1,5 +1,4 @@ import Foundation -import WooFoundation import enum Yosemite.POSItemType import protocol Yosemite.POSItemFetchAnalyticsTracking diff --git a/WooCommerce/Classes/POS/Analytics/WooAnalyticsEvent+PointOfSale.swift b/WooCommerce/Classes/POS/Analytics/WooAnalyticsEvent+PointOfSale.swift index cae9ebe3f57..b1ecb702d70 100644 --- a/WooCommerce/Classes/POS/Analytics/WooAnalyticsEvent+PointOfSale.swift +++ b/WooCommerce/Classes/POS/Analytics/WooAnalyticsEvent+PointOfSale.swift @@ -378,7 +378,7 @@ extension WooAnalyticsEvent { properties: [Key.scanner: scanner.analyticsName]) } - static func barcodeScannerSetupScannerConnected(scanner: PointOfSaleBarcodeScannerType, step: String) -> WooAnalyticsEvent { + static func barcodeScannerSetupScannerConnected(scanner: PointOfSaleBarcodeScannerType) -> WooAnalyticsEvent { WooAnalyticsEvent(statName: .pointOfSaleBarcodeScannerSetupScannerConnected, properties: [Key.scanner: scanner.analyticsName]) } diff --git a/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentPreviewService.swift b/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentPreviewService.swift index a1cea225df3..099f96cc202 100644 --- a/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentPreviewService.swift +++ b/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentPreviewService.swift @@ -29,7 +29,7 @@ final class CardPresentPaymentPreviewService: CardPresentPaymentFacade { func collectPayment(for order: Yosemite.Order, using connectionMethod: CardReaderConnectionMethod, channel: PaymentChannel) async throws -> CardPresentPaymentResult { - .success(CardPresentPaymentTransaction(receiptURL: URL(string: "https://example.net/receipts/123")!)) + .success(CardPresentPaymentTransaction()) } func cancelPayment() { diff --git a/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentTransaction.swift b/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentTransaction.swift index b96b4b085eb..f79dd91aa0b 100644 --- a/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentTransaction.swift +++ b/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentTransaction.swift @@ -2,5 +2,5 @@ import Foundation /// A completed, paid transaction. public struct CardPresentPaymentTransaction { - let receiptURL: URL + public init() {} } diff --git a/WooCommerce/Classes/POS/Controllers/PointOfSaleOrderController.swift b/WooCommerce/Classes/POS/Controllers/PointOfSaleOrderController.swift index fdc704ad42a..dab69558286 100644 --- a/WooCommerce/Classes/POS/Controllers/PointOfSaleOrderController.swift +++ b/WooCommerce/Classes/POS/Controllers/PointOfSaleOrderController.swift @@ -246,7 +246,6 @@ extension PointOfSaleInternalOrderState: Equatable { extension PointOfSaleOrderController { enum PointOfSaleOrderControllerError: Error { - case noSiteID case noOrder } } diff --git a/WooCommerce/Classes/POS/Models/Cart.swift b/WooCommerce/Classes/POS/Models/Cart.swift index 6172fc4ce3f..1aa8ee114d5 100644 --- a/WooCommerce/Classes/POS/Models/Cart.swift +++ b/WooCommerce/Classes/POS/Models/Cart.swift @@ -34,15 +34,6 @@ extension Cart { case loaded(POSOrderableItem) case loading case error - - var isLoading: Bool { - switch self { - case .loading: - return true - default: - return false - } - } } var formattedPrice: String? { @@ -95,7 +86,7 @@ extension Cart { extension Cart { mutating func add(_ posItem: POSItem) { - if let purchasableItem = createPurchasableItem(id: UUID(), from: posItem) { + if let purchasableItem = createPurchasableItem(from: posItem) { purchasableItems.insert(purchasableItem, at: purchasableItems.startIndex) } else if case .coupon(let coupon) = posItem { let couponItem = Cart.CouponItem(id: coupon.id, code: coupon.code, summary: coupon.summary) @@ -103,7 +94,7 @@ extension Cart { } } - private func createPurchasableItem(id: UUID, from posItem: POSItem) -> Cart.PurchasableItem? { + private func createPurchasableItem(from posItem: POSItem) -> Cart.PurchasableItem? { switch posItem { case .simpleProduct(let simpleProduct): return PurchasableItem(id: UUID(), item: simpleProduct, title: simpleProduct.name, subtitle: nil, quantity: 1) @@ -125,7 +116,7 @@ extension Cart { mutating func updateLoadingItem(id: UUID, with posItem: POSItem) -> Cart.PurchasableItem? { guard let index = purchasableItems.firstIndex(where: { $0.id == id }) else { return nil } - if let productItem = createPurchasableItem(id: id, from: posItem) { + if let productItem = createPurchasableItem(from: posItem) { purchasableItems[index] = productItem return productItem } else { diff --git a/WooCommerce/Classes/POS/Models/ItemListState.swift b/WooCommerce/Classes/POS/Models/ItemListState.swift index a89576a3e33..3f42528ae02 100644 --- a/WooCommerce/Classes/POS/Models/ItemListState.swift +++ b/WooCommerce/Classes/POS/Models/ItemListState.swift @@ -12,15 +12,6 @@ enum ItemListState { case pagination } - var isLoading: Bool { - switch self { - case .loading: - return true - default: - return false - } - } - var isLoaded: Bool { switch self { case .loaded: @@ -30,24 +21,6 @@ enum ItemListState { } } - var isInlineError: Bool { - switch self { - case .inlineError: - return true - default: - return false - } - } - - var isError: Bool { - switch self { - case .error: - return true - default: - return false - } - } - var isEmpty: Bool { switch self { case .empty: diff --git a/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift b/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift index 03cddc67d67..d2d89e46ef7 100644 --- a/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift +++ b/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift @@ -40,7 +40,6 @@ protocol PointOfSaleAggregateModelProtocol { func startNewCart() func saveSearchTerm(_ term: String, for itemType: POSItemType) - func searchHistory(for itemType: POSItemType) -> [String] var orderState: PointOfSaleOrderState { get } func checkOut() async @@ -265,10 +264,6 @@ extension PointOfSaleAggregateModel { func saveSearchTerm(_ term: String, for itemType: POSItemType) { searchHistoryService.saveSuccessfulSearch(term: term, for: itemType) } - - func searchHistory(for itemType: POSItemType) -> [String] { - return searchHistoryService.searchHistory(for: itemType) - } } // MARK: - Track events @@ -621,18 +616,3 @@ extension PointOfSaleAggregateModel { cancellables.forEach { $0.cancel() } } } - -private extension PointOfSaleAggregateModel { - enum Constants { - static let initialPage: Int = 1 - } -} - -#if DEBUG -extension PointOfSaleAggregateModel { - func setPreviewState(paymentState: PointOfSalePaymentState, inlineMessage: PointOfSaleCardPresentPaymentMessageType?) { - self.paymentState = paymentState - self.cardPresentPaymentInlineMessage = inlineMessage - } -} -#endif diff --git a/WooCommerce/Classes/POS/Models/PointOfSaleErrorState.swift b/WooCommerce/Classes/POS/Models/PointOfSaleErrorState.swift index 7d4c7a3d352..7464961858d 100644 --- a/WooCommerce/Classes/POS/Models/PointOfSaleErrorState.swift +++ b/WooCommerce/Classes/POS/Models/PointOfSaleErrorState.swift @@ -7,7 +7,6 @@ struct PointOfSaleErrorState: Equatable { case variationsLoadError case productsNextPageError case variationsNextPageError - case couponsNotFound case couponsLoadError case couponsDisabled case couponsNextPageError diff --git a/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerButtonCustomization.swift b/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerButtonCustomization.swift index 234db82f951..5c7ec9d5c88 100644 --- a/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerButtonCustomization.swift +++ b/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerButtonCustomization.swift @@ -6,7 +6,7 @@ protocol PointOfSaleBarcodeScannerButtonCustomization { } // MARK: - Transition Types -public enum PointOfSaleBarcodeScannerTransitionType: Hashable { +enum PointOfSaleBarcodeScannerTransitionType: Hashable { case next case retry case back @@ -14,16 +14,13 @@ public enum PointOfSaleBarcodeScannerTransitionType: Hashable { // MARK: - Setup Step struct PointOfSaleBarcodeScannerSetupStep { - let title: String let content: any View let buttonCustomization: PointOfSaleBarcodeScannerButtonCustomization? let transitions: [PointOfSaleBarcodeScannerTransitionType: PointOfSaleBarcodeScannerStepID] - init(title: String = "", - @ViewBuilder content: () -> any View, + init(@ViewBuilder content: () -> any View, buttonCustomization: PointOfSaleBarcodeScannerButtonCustomization? = nil, transitions: [PointOfSaleBarcodeScannerTransitionType: PointOfSaleBarcodeScannerStepID] = [:]) { - self.title = title self.content = content() self.buttonCustomization = buttonCustomization self.transitions = transitions diff --git a/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupFlow.swift b/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupFlow.swift index 0424010f950..2524624732f 100644 --- a/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupFlow.swift +++ b/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupFlow.swift @@ -38,10 +38,6 @@ class PointOfSaleBarcodeScannerSetupFlow { } } - func restartFlow() { - currentStepKey = .setupBarcodeHID - } - // MARK: - Generic Transition Methods func transition(to transitionType: PointOfSaleBarcodeScannerTransitionType) { diff --git a/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupFlowManager.swift b/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupFlowManager.swift index cc104606a6a..efcae663adf 100644 --- a/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupFlowManager.swift +++ b/WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupFlowManager.swift @@ -46,14 +46,6 @@ class PointOfSaleBarcodeScannerSetupFlowManager { currentFlow = nil } - func nextStep() { - currentFlow?.nextStep() - } - - func previousStep() { - currentFlow?.previousStep() - } - func getCurrentStep() -> PointOfSaleBarcodeScannerSetupStep? { currentFlow?.currentStep } @@ -102,6 +94,6 @@ class PointOfSaleBarcodeScannerSetupFlowManager { private func handleKeyboardConnected() { guard case .setupFlow(let scannerType) = currentState, let step = getCurrentSetupStepValue() else { return } - analytics.track(event: WooAnalyticsEvent.PointOfSale.barcodeScannerSetupScannerConnected(scanner: scannerType, step: step)) + analytics.track(event: WooAnalyticsEvent.PointOfSale.barcodeScannerSetupScannerConnected(scanner: scannerType)) } } diff --git a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleItemListErrorLayout.swift b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleItemListErrorLayout.swift index 9c0b50f7d31..3155d99829c 100644 --- a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleItemListErrorLayout.swift +++ b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleItemListErrorLayout.swift @@ -2,5 +2,4 @@ import Foundation enum PointOfSaleItemListErrorLayout { static let headerSpacing: CGFloat = POSSpacing.medium - static let verticalPadding: CGFloat = POSPadding.medium } diff --git a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Reader Messages/PointOfSalePaymentSuccessView.swift b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Reader Messages/PointOfSalePaymentSuccessView.swift index 9371c861272..7d751c46f4d 100644 --- a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Reader Messages/PointOfSalePaymentSuccessView.swift +++ b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Reader Messages/PointOfSalePaymentSuccessView.swift @@ -103,12 +103,8 @@ struct PointOfSalePaymentSuccessView: View { private extension PointOfSalePaymentSuccessView { enum Constants { - static let imageName: String = "checkmark" static let imageSize: CGSize = .init(width: 165, height: 165) static let checkmarkSize: CGFloat = 52 - static let shadowOpacity: CGFloat = 0.16 - static let shadowRadius: CGFloat = 16 - static let shadowSize: CGSize = .init(width: 0, height: 8) static let textSpacing: CGFloat = POSSpacing.small static let animationOffset: CGFloat = 100 } diff --git a/WooCommerce/Classes/POS/Presentation/CartView.swift b/WooCommerce/Classes/POS/Presentation/CartView.swift index 3c968a64975..cb21eb37805 100644 --- a/WooCommerce/Classes/POS/Presentation/CartView.swift +++ b/WooCommerce/Classes/POS/Presentation/CartView.swift @@ -7,7 +7,6 @@ struct CartView: View { @Environment(\.posAnalytics) private var analytics private let viewHelper = CartViewHelper() - @Environment(\.floatingControlAreaSize) var floatingControlAreaSize: CGSize @Environment(\.dynamicTypeSize) var dynamicTypeSize @State private var offSetPosition: CGFloat = 0.0 @@ -24,10 +23,6 @@ struct CartView: View { abs(offSetPosition) < maxOffset } - private var shouldShowCoupons: Bool { - posModel.cart.coupons.isNotEmpty - } - private var isPOSSettingsEnabled: Bool { featureFlags.isFeatureFlagEnabled(.pointOfSaleSettingsi1) } @@ -163,7 +158,6 @@ private extension CartView { } private enum Constants { - static let primaryFont: POSFontStyle = .posHeadingBold static let secondaryFont: POSFontStyle = .posBodyMediumRegular() static let itemsFont: POSFontStyle = .posBodySmallRegular() static let shoppingBagImageSize: CGFloat = 104 diff --git a/WooCommerce/Classes/POS/Presentation/Item Selector/ChildItemList.swift b/WooCommerce/Classes/POS/Presentation/Item Selector/ChildItemList.swift index da218c56b50..b90c143f10c 100644 --- a/WooCommerce/Classes/POS/Presentation/Item Selector/ChildItemList.swift +++ b/WooCommerce/Classes/POS/Presentation/Item Selector/ChildItemList.swift @@ -116,16 +116,6 @@ private extension ChildItemList { } } -private extension ChildItemList { - enum Localization { - static let back = NSLocalizedString( - "pos.childItemList.back", - value: "Back", - comment: "Back button title in the child item list screen." - ) - } -} - #if DEBUG #Preview("Variable product child items") { diff --git a/WooCommerce/Classes/POS/Presentation/ItemListView.swift b/WooCommerce/Classes/POS/Presentation/ItemListView.swift index 78a537270e0..924acdbf197 100644 --- a/WooCommerce/Classes/POS/Presentation/ItemListView.swift +++ b/WooCommerce/Classes/POS/Presentation/ItemListView.swift @@ -3,11 +3,9 @@ import enum Yosemite.POSItem import protocol Yosemite.POSOrderableItem struct ItemListView: View { - @Environment(\.dynamicTypeSize) private var dynamicTypeSize @Environment(\.posAnalytics) private var analytics @Environment(PointOfSaleAggregateModel.self) private var posModel @Environment(\.keyboardObserver) private var keyboardObserver - @Environment(\.posFeatureFlags) private var featureFlags @EnvironmentObject var modalManager: POSModalManager @EnvironmentObject var sheetManager: POSSheetManager @EnvironmentObject var coverManager: POSFullScreenCoverManager @@ -53,9 +51,6 @@ struct ItemListView: View { ) } - @State private var searchTask: Task? - @State private var didFinishSearch = true - private var isAddingCouponAllowed: Bool { guard case .coupons = selectedItemListType else { return false } let itemListState = itemListState(selectedItemListType) @@ -152,7 +147,7 @@ struct ItemListView: View { case .loading(let items), .loaded(let items, _), .inlineError(let items, _, _): - listView(items, itemListType: itemListType) + listView(itemListType: itemListType) case .error(let errorState): errorView(errorState) case .empty: @@ -161,7 +156,7 @@ struct ItemListView: View { } @ViewBuilder - private func listView(_ items: [POSItem], itemListType: ItemListType) -> some View { + private func listView(itemListType: ItemListType) -> some View { ItemList( itemsController: itemsController(itemListType), node: .root, @@ -389,10 +384,6 @@ private extension ItemListView { static let animationDuration: CGFloat = 0.2 } - enum BannerState { - static let isSimpleProductsOnlyBannerDismissedKey = "isSimpleProductsOnlyBannerDismissed" - } - enum Localization { static let productsTitle = NSLocalizedString( "pos.itemlistview.title", diff --git a/WooCommerce/Classes/POS/Presentation/ItemRowView.swift b/WooCommerce/Classes/POS/Presentation/ItemRowView.swift index c83943ace8c..f23a4555280 100644 --- a/WooCommerce/Classes/POS/Presentation/ItemRowView.swift +++ b/WooCommerce/Classes/POS/Presentation/ItemRowView.swift @@ -6,7 +6,6 @@ struct ItemRowView: View { private let onCancelLoading: (() -> Void)? @ScaledMetric private var scale: CGFloat = 1.0 - @Environment(\.dynamicTypeSize) var dynamicTypeSize @Binding private var showProductImage: Bool private var dimension: CGFloat { diff --git a/WooCommerce/Classes/POS/Presentation/Order Messages/PointOfSaleOrderSyncCouponsErrorMessageView.swift b/WooCommerce/Classes/POS/Presentation/Order Messages/PointOfSaleOrderSyncCouponsErrorMessageView.swift index 413944f8e12..de80b3da3e3 100644 --- a/WooCommerce/Classes/POS/Presentation/Order Messages/PointOfSaleOrderSyncCouponsErrorMessageView.swift +++ b/WooCommerce/Classes/POS/Presentation/Order Messages/PointOfSaleOrderSyncCouponsErrorMessageView.swift @@ -71,8 +71,6 @@ struct PointOfSaleOrderSyncCouponsErrorMessageView: View { private extension PointOfSaleOrderSyncCouponsErrorMessageView { enum Constants { - static let headerSpacing: CGFloat = POSSpacing.large - static let textSpacing: CGFloat = POSSpacing.medium static let buttonSidePadding: CGFloat = POSPadding.xxLarge static let buttonBottomPadding: CGFloat = POSPadding.medium } diff --git a/WooCommerce/Classes/POS/Presentation/Order Messages/PointOfSaleOrderSyncErrorMessageView.swift b/WooCommerce/Classes/POS/Presentation/Order Messages/PointOfSaleOrderSyncErrorMessageView.swift index 4f4ee0a9fb3..745bc09e753 100644 --- a/WooCommerce/Classes/POS/Presentation/Order Messages/PointOfSaleOrderSyncErrorMessageView.swift +++ b/WooCommerce/Classes/POS/Presentation/Order Messages/PointOfSaleOrderSyncErrorMessageView.swift @@ -36,8 +36,6 @@ struct PointOfSaleOrderSyncErrorMessageView: View { private extension PointOfSaleOrderSyncErrorMessageView { enum Constants { - static let headerSpacing: CGFloat = POSSpacing.large - static let textSpacing: CGFloat = POSSpacing.medium static let buttonSidePadding: CGFloat = POSPadding.xxLarge static let buttonBottomPadding: CGFloat = POSPadding.medium } diff --git a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift index cca9ad91471..3afaf199740 100644 --- a/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift +++ b/WooCommerce/Classes/POS/Presentation/PointOfSaleCollectCashView.swift @@ -166,10 +166,6 @@ private extension PointOfSaleCollectCashView { return padding } - private var backgroundColor: Color { - .posSurfaceBright - } - enum Localization { static let backNavigationTitle = NSLocalizedString( "pointOfSale.cashview.back.navigation.title", diff --git a/WooCommerce/Classes/POS/Presentation/Reusable Views/POSItemImageView.swift b/WooCommerce/Classes/POS/Presentation/Reusable Views/POSItemImageView.swift index 8ddf1eb6cac..236c0ef7880 100644 --- a/WooCommerce/Classes/POS/Presentation/Reusable Views/POSItemImageView.swift +++ b/WooCommerce/Classes/POS/Presentation/Reusable Views/POSItemImageView.swift @@ -57,12 +57,6 @@ struct POSItemImageView: View { } } -private extension POSItemImageView { - enum Constants { - static let placeholderIconDimension: CGFloat = 38 - } -} - #Preview("Placeholder") { POSItemImageView(imageSource: nil, imageSize: 112, diff --git a/WooCommerce/Classes/POS/Presentation/Reusable Views/WavesProgressViewStyle.swift b/WooCommerce/Classes/POS/Presentation/Reusable Views/WavesProgressViewStyle.swift index f9da3f41b37..9bef53d9876 100644 --- a/WooCommerce/Classes/POS/Presentation/Reusable Views/WavesProgressViewStyle.swift +++ b/WooCommerce/Classes/POS/Presentation/Reusable Views/WavesProgressViewStyle.swift @@ -2,12 +2,11 @@ import SwiftUI struct CardWaveProgressViewStyle: ProgressViewStyle { func makeBody(configuration: Configuration) -> some View { - CardWaveProgressView(configuration: configuration) + CardWaveProgressView() } } private struct CardWaveProgressView: View { - let configuration: ProgressViewStyleConfiguration private let animationDuration: Double = 0.5 private let radii: [CGFloat] = [40.0, 70.0, 100.0] private let inactiveInset: CGFloat = 0.025 diff --git a/WooCommerce/Classes/POS/Presentation/SimpleProductsOnlyInformation.swift b/WooCommerce/Classes/POS/Presentation/SimpleProductsOnlyInformation.swift index 367906d4375..cf2b1a3afc6 100644 --- a/WooCommerce/Classes/POS/Presentation/SimpleProductsOnlyInformation.swift +++ b/WooCommerce/Classes/POS/Presentation/SimpleProductsOnlyInformation.swift @@ -73,11 +73,6 @@ private extension SimpleProductsOnlyInformation { value: "Create an order in store management", comment: "Action text in the simple products information modal in POS" ) - static let okButtonTitle = NSLocalizedString( - "pos.simpleProductsModal.ok.button.title", - value: "OK", - comment: "Title for the OK button on the simple products information modal in POS" - ) } } diff --git a/WooCommerce/Classes/POS/Presentation/TotalsView.swift b/WooCommerce/Classes/POS/Presentation/TotalsView.swift index 86dfa82be16..da8511ca547 100644 --- a/WooCommerce/Classes/POS/Presentation/TotalsView.swift +++ b/WooCommerce/Classes/POS/Presentation/TotalsView.swift @@ -19,8 +19,6 @@ struct TotalsView: View { viewHelper.shouldShowTotalsFields(for: posModel.paymentState) } - @Environment(\.dynamicTypeSize) var dynamicTypeSize - var body: some View { HStack { switch posModel.orderState { @@ -122,13 +120,11 @@ private extension TotalsView { private extension TotalsView { struct PaymentViewLayout { - let backgroundColor: Color let topPadding: CGFloat? let bottomPadding: CGFloat? let sidePadding: CGFloat init(backgroundColor: Color, topPadding: CGFloat?, bottomPadding: CGFloat?, sidePadding: CGFloat = 8) { - self.backgroundColor = backgroundColor self.topPadding = topPadding self.bottomPadding = bottomPadding self.sidePadding = sidePadding @@ -358,8 +354,6 @@ private struct TotalsFieldsContent: View { } private struct SubtotalFieldView: View { - @Environment(\.dynamicTypeSize) private var dynamicTypeSize - let title: String let formattedPrice: String? let shimmeringActive: Bool @@ -392,8 +386,6 @@ private struct SubtotalFieldView: View { } private struct TotalFieldView: View { - @Environment(\.dynamicTypeSize) private var dynamicTypeSize - let formattedPrice: String? let shimmeringActive: Bool diff --git a/WooCommerce/Classes/POS/Utils/Audio/PointOfSaleSoundPlayer.swift b/WooCommerce/Classes/POS/Utils/Audio/PointOfSaleSoundPlayer.swift index 1529934cd10..61467fbb219 100644 --- a/WooCommerce/Classes/POS/Utils/Audio/PointOfSaleSoundPlayer.swift +++ b/WooCommerce/Classes/POS/Utils/Audio/PointOfSaleSoundPlayer.swift @@ -11,7 +11,6 @@ struct PointOfSaleSound: Equatable, Hashable { } protocol PointOfSaleSoundPlayerProtocol { - func playSound(_ sound: PointOfSaleSound, completion: @escaping (() -> Void)) async func playSound(_ sound: PointOfSaleSound) async } diff --git a/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift b/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift index 76b3f05d4bc..04119bd4a8e 100644 --- a/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift +++ b/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift @@ -18,10 +18,6 @@ private struct POSShadowLayer { let offset: CGSize } -private struct POSShadowStyleDefinition { - let shadowLayers: [POSShadowLayer] -} - // MARK: - Main SwiftUI Modifier struct POSShadowStyleModifier: ViewModifier { diff --git a/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift b/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift index 30a1cff82d5..9a96eadd986 100644 --- a/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift +++ b/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift @@ -435,8 +435,6 @@ final class POSCollectOrderPaymentPreviewAnalytics: POSCollectOrderPaymentAnalyt func trackCheckoutTapped() {} - func resetCheckoutTapCountTracker() {} - func trackSuccessfulCashPayment() {} } diff --git a/WooCommerce/Classes/Tools/InfiniteScroll/AsyncPaginationTracker.swift b/WooCommerce/Classes/Tools/InfiniteScroll/AsyncPaginationTracker.swift index b58c1e2048d..0c6026a3dae 100644 --- a/WooCommerce/Classes/Tools/InfiniteScroll/AsyncPaginationTracker.swift +++ b/WooCommerce/Classes/Tools/InfiniteScroll/AsyncPaginationTracker.swift @@ -35,11 +35,6 @@ final class AsyncPaginationTracker { pagesSynced.max() } - /// Returns the highest page number that is currently being synced, if any. - private var highestPageBeingSynced: Int? { - pagesBeingSynced.max() - } - /// Designated Initializer init(pageFirstIndex: Int = Defaults.pageFirstIndex) { self.pageFirstIndex = pageFirstIndex diff --git a/WooCommerce/WooCommerceTests/POS/Mocks/MockCardPresentPaymentService.swift b/WooCommerce/WooCommerceTests/POS/Mocks/MockCardPresentPaymentService.swift index 28ff558c3bb..eab98688e5f 100644 --- a/WooCommerce/WooCommerceTests/POS/Mocks/MockCardPresentPaymentService.swift +++ b/WooCommerce/WooCommerceTests/POS/Mocks/MockCardPresentPaymentService.swift @@ -46,7 +46,7 @@ final class MockCardPresentPaymentService: CardPresentPaymentFacade { collectPaymentChannel = channel onCollectPaymentCalled?() paymentEvent = .show(eventDetails: CardPresentPaymentEventDetails.paymentSuccess(done: {})) - return .success(CardPresentPaymentTransaction(receiptURL: URL(string: "https://example.net/receipts/123")!)) + return .success(CardPresentPaymentTransaction()) } func cancelPayment() { diff --git a/WooCommerce/WooCommerceTests/POS/Mocks/MockPOSCollectOrderPaymentAnalyticsTracker.swift b/WooCommerce/WooCommerceTests/POS/Mocks/MockPOSCollectOrderPaymentAnalyticsTracker.swift index b60cb69b2a1..d4d26cab904 100644 --- a/WooCommerce/WooCommerceTests/POS/Mocks/MockPOSCollectOrderPaymentAnalyticsTracker.swift +++ b/WooCommerce/WooCommerceTests/POS/Mocks/MockPOSCollectOrderPaymentAnalyticsTracker.swift @@ -24,10 +24,6 @@ final class MockPOSCollectOrderPaymentAnalyticsTracker: POSCollectOrderPaymentAn didCallTrackCheckoutTapped = true } - func resetCheckoutTapCountTracker() { - // no-op - } - var didCallTrackSuccessfulCashPayment = false func trackSuccessfulCashPayment() { didCallTrackSuccessfulCashPayment = true From c110fec1ee161d1d3fca060cfaab2c5baa561783 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Fri, 26 Sep 2025 16:50:01 +0800 Subject: [PATCH 02/11] Fix more straightforward Periphery warnings. --- ...ntPaymentCollectOrderPaymentUseCaseAdaptor.swift | 1 - .../CardPresentPaymentService.swift | 1 - ...CardPresentPaymentFoundMultipleReadersView.swift | 8 ++------ .../PointOfSaleCardPresentPaymentAlert.swift | 2 +- ...PointOfSaleCardPresentPaymentInLineMessage.swift | 1 - .../Presentation/Item Search/POSSearchView.swift | 2 -- .../Classes/POS/Presentation/TotalsView.swift | 13 ++++--------- 7 files changed, 7 insertions(+), 21 deletions(-) diff --git a/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentCollectOrderPaymentUseCaseAdaptor.swift b/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentCollectOrderPaymentUseCaseAdaptor.swift index c353570c61b..4dd07b76abc 100644 --- a/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentCollectOrderPaymentUseCaseAdaptor.swift +++ b/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentCollectOrderPaymentUseCaseAdaptor.swift @@ -30,7 +30,6 @@ final class CardPresentPaymentCollectOrderPaymentUseCaseAdaptor { CardPresentPaymentTapToPayReaderConnectionAlertsProvider, CardPresentPaymentBluetoothReaderConnectionAlertsProvider, CardPresentPaymentsAlertPresenterAdaptor>, - onboardingPresenter: CardPresentPaymentsOnboardingPresenting, configuration: CardPresentPaymentsConfiguration, alertsPresenter: CardPresentPaymentsAlertPresenterAdaptor, paymentEventSubject: any Subject, diff --git a/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift b/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift index 1f53863ca59..65b6e289b2e 100644 --- a/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift +++ b/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift @@ -146,7 +146,6 @@ final class CardPresentPaymentService: CardPresentPaymentFacade { using: connectionMethod, siteID: siteID, preflightController: preflightController, - onboardingPresenter: onboardingAdaptor, configuration: cardPresentPaymentsConfiguration, alertsPresenter: paymentAlertsPresenterAdaptor, paymentEventSubject: paymentEventSubject, diff --git a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Connection Alerts/PointOfSaleCardPresentPaymentFoundMultipleReadersView.swift b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Connection Alerts/PointOfSaleCardPresentPaymentFoundMultipleReadersView.swift index a249c8cdbe6..4eca13f3de6 100644 --- a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Connection Alerts/PointOfSaleCardPresentPaymentFoundMultipleReadersView.swift +++ b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Connection Alerts/PointOfSaleCardPresentPaymentFoundMultipleReadersView.swift @@ -5,14 +5,11 @@ struct PointOfSaleCardPresentPaymentFoundMultipleReadersView: View { private let readerIDs: [String] private let connect: (String) -> Void private let cancelSearch: () -> Void - private let animation: POSCardPresentPaymentAlertAnimation - init(viewModel: PointOfSaleCardPresentPaymentFoundMultipleReadersAlertViewModel, - animation: POSCardPresentPaymentAlertAnimation) { + init(viewModel: PointOfSaleCardPresentPaymentFoundMultipleReadersAlertViewModel) { self.readerIDs = viewModel.readerIDs self.connect = viewModel.connect self.cancelSearch = viewModel.cancelSearch - self.animation = animation } var body: some View { @@ -120,7 +117,6 @@ private extension PointOfSaleCardPresentPaymentFoundMultipleReadersView { #Preview { return PointOfSaleCardPresentPaymentFoundMultipleReadersView( viewModel: .init(readerIDs: ["Reader 1", "Reader 2"], - selectionHandler: { _ in }), - animation: .init(namespace: Namespace().wrappedValue) + selectionHandler: { _ in }) ) } diff --git a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleCardPresentPaymentAlert.swift b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleCardPresentPaymentAlert.swift index 03231eb718b..f975e83e553 100644 --- a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleCardPresentPaymentAlert.swift +++ b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleCardPresentPaymentAlert.swift @@ -24,7 +24,7 @@ struct PointOfSaleCardPresentPaymentAlert: View { case .foundReader(let alertViewModel): PointOfSaleCardPresentPaymentFoundReaderView(viewModel: alertViewModel, animation: animation) case .foundMultipleReaders(let alertViewModel): - PointOfSaleCardPresentPaymentFoundMultipleReadersView(viewModel: alertViewModel, animation: animation) + PointOfSaleCardPresentPaymentFoundMultipleReadersView(viewModel: alertViewModel) case .requiredReaderUpdateInProgress(let alertViewModel): PointOfSaleCardPresentPaymentRequiredReaderUpdateInProgressView(viewModel: alertViewModel, animation: animation) case .optionalReaderUpdateInProgress(let alertViewModel): diff --git a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleCardPresentPaymentInLineMessage.swift b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleCardPresentPaymentInLineMessage.swift index edb4bcc3fb2..8f7f9936d79 100644 --- a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleCardPresentPaymentInLineMessage.swift +++ b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleCardPresentPaymentInLineMessage.swift @@ -57,5 +57,4 @@ struct POSCardPresentPaymentInLineMessageAnimation { let iconTransitionId: String = "pos_card_present_payment_in_line_message_icon_matched_geometry_id" let titleTransitionId: String = "pos_card_present_payment_in_line_message_title_matched_geometry_id" let messageTransitionId: String = "pos_card_present_payment_in_line_message_message_matched_geometry_id" - let actionButtonsTransitionId = "pos_card_present_payment_in_line_message_action_buttons_matched_geometry_id" } diff --git a/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchView.swift b/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchView.swift index 4c109f7c1b0..9461504ddba 100644 --- a/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchView.swift +++ b/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchView.swift @@ -24,7 +24,6 @@ struct POSSearchField: View { @FocusState private var isSearchFieldFocused: Bool @State private var searchTask: Task? @State private var didFinishSearch = true - @ScaledMetric private var searchFieldHeight: CGFloat = 56.0 private let searchable: any POSSearchable private let onBack: () -> Void @@ -103,7 +102,6 @@ struct POSSearchField: View { /// A reusable search content view for POS items struct POSSearchContentView: View { - @Environment(\.dynamicTypeSize) private var dynamicTypeSize @Environment(\.posAnalytics) private var analytics private let searchable: any POSSearchable diff --git a/WooCommerce/Classes/POS/Presentation/TotalsView.swift b/WooCommerce/Classes/POS/Presentation/TotalsView.swift index da8511ca547..7cd2e28f308 100644 --- a/WooCommerce/Classes/POS/Presentation/TotalsView.swift +++ b/WooCommerce/Classes/POS/Presentation/TotalsView.swift @@ -124,20 +124,18 @@ private extension TotalsView { let bottomPadding: CGFloat? let sidePadding: CGFloat - init(backgroundColor: Color, topPadding: CGFloat?, bottomPadding: CGFloat?, sidePadding: CGFloat = 8) { + init(topPadding: CGFloat?, bottomPadding: CGFloat?, sidePadding: CGFloat = 8) { self.topPadding = topPadding self.bottomPadding = bottomPadding self.sidePadding = sidePadding } static let primary = PaymentViewLayout( - backgroundColor: .clear, topPadding: nil, bottomPadding: POSPadding.small ) static let outlined = PaymentViewLayout( - backgroundColor: Color(.quaternarySystemFill), topPadding: POSPadding.xxLarge, bottomPadding: POSPadding.xxLarge ) @@ -173,8 +171,7 @@ private extension TotalsView { switch posModel.paymentState.activePaymentMethod { case .cash: - return PaymentViewLayout(backgroundColor: backgroundColor, - topPadding: POSPadding.none, + return PaymentViewLayout(topPadding: POSPadding.none, bottomPadding: posModel.paymentState.cash == .collectingCash ? nil : POSPadding.none, sidePadding: POSPadding.none) case .card: @@ -183,13 +180,11 @@ private extension TotalsView { .paymentIntentCreationError: return .outlined case .paymentError: - return PaymentViewLayout(backgroundColor: backgroundColor, - topPadding: POSPadding.none, + return PaymentViewLayout(topPadding: POSPadding.none, bottomPadding: POSPadding.none, sidePadding: POSPadding.none) case .cardPaymentSuccessful: - return PaymentViewLayout(backgroundColor: backgroundColor, - topPadding: POSPadding.none, + return PaymentViewLayout(topPadding: POSPadding.none, bottomPadding: POSPadding.none, sidePadding: POSPadding.none) case .idle, From 798049b7fee41ae9d5672417eaf310c12ab9b1ff Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Fri, 26 Sep 2025 16:51:22 +0800 Subject: [PATCH 03/11] Fix Periphery warnings that might not be the prettiest or require testing - barcode scanning. --- .../Card Present Payments/CardPresentPaymentService.swift | 2 +- .../Barcode Scanning/GameControllerBarcodeObserver.swift | 2 +- ...fSaleCardPresentPaymentConnectionSuccessAlertViewModel.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift b/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift index 65b6e289b2e..18cf095f0c6 100644 --- a/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift +++ b/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentService.swift @@ -65,7 +65,7 @@ final class CardPresentPaymentService: CardPresentPaymentFacade { let connectedReaderPublisher = await Self.createCardReaderConnectionPublisher(stores: stores) self.connectedReaderPublisher = connectedReaderPublisher - readerConnectionStatusPublisher = connectedReaderPublisher + readerConnectionStatusPublisher = self.connectedReaderPublisher .map({ reader -> CardPresentPaymentReaderConnectionStatus in guard let reader else { return .disconnected diff --git a/WooCommerce/Classes/POS/Presentation/Barcode Scanning/GameControllerBarcodeObserver.swift b/WooCommerce/Classes/POS/Presentation/Barcode Scanning/GameControllerBarcodeObserver.swift index 61db65af04d..db4a103ded8 100644 --- a/WooCommerce/Classes/POS/Presentation/Barcode Scanning/GameControllerBarcodeObserver.swift +++ b/WooCommerce/Classes/POS/Presentation/Barcode Scanning/GameControllerBarcodeObserver.swift @@ -82,7 +82,7 @@ final class GameControllerBarcodeObserver { } /// Handles the disconnection of the keyboard (coalesced). - @objc private func handleKeyboardDidDisconnect(_ notification: Notification) { + @objc private func handleKeyboardDidDisconnect() { cleanupKeyboard() } diff --git a/WooCommerce/Classes/POS/Presentation/Card Present Payments/Connection Alerts/PointOfSaleCardPresentPaymentConnectionSuccessAlertViewModel.swift b/WooCommerce/Classes/POS/Presentation/Card Present Payments/Connection Alerts/PointOfSaleCardPresentPaymentConnectionSuccessAlertViewModel.swift index 9acff9726b3..2abec5a7f1b 100644 --- a/WooCommerce/Classes/POS/Presentation/Card Present Payments/Connection Alerts/PointOfSaleCardPresentPaymentConnectionSuccessAlertViewModel.swift +++ b/WooCommerce/Classes/POS/Presentation/Card Present Payments/Connection Alerts/PointOfSaleCardPresentPaymentConnectionSuccessAlertViewModel.swift @@ -12,7 +12,7 @@ class PointOfSaleCardPresentPaymentConnectionSuccessAlertViewModel: Hashable { scheduler: Scheduler = DefaultScheduler()) { self.scheduler = scheduler - let autoDismissAction = scheduler.schedule(after: 3.0, action: doneAction) + let autoDismissAction = self.scheduler.schedule(after: 3.0, action: doneAction) self.autoDismissAction = autoDismissAction self.buttonViewModel = CardPresentPaymentsModalButtonViewModel( From e5dbdbcd77d80df77422ad7f841bbf748940598d Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Fri, 26 Sep 2025 17:00:35 +0800 Subject: [PATCH 04/11] Fix Periphery warnings from unused functions in `ConnectivityObserver` protocol. --- .../Utilities/Connectivity/ConnectivityObserver.swift | 6 ------ .../Connectivity/DefaultConnectivityObserver.swift | 4 ++-- WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift | 2 -- WooCommerce/Classes/POS/Utils/PreviewHelpers.swift | 3 --- .../WooCommerceTests/Mocks/MockConnectivityObserver.swift | 8 -------- 5 files changed, 2 insertions(+), 21 deletions(-) diff --git a/Modules/Sources/WooFoundation/Utilities/Connectivity/ConnectivityObserver.swift b/Modules/Sources/WooFoundation/Utilities/Connectivity/ConnectivityObserver.swift index 7182a0473ef..6ba2b71ef66 100644 --- a/Modules/Sources/WooFoundation/Utilities/Connectivity/ConnectivityObserver.swift +++ b/Modules/Sources/WooFoundation/Utilities/Connectivity/ConnectivityObserver.swift @@ -8,12 +8,6 @@ public protocol ConnectivityObserver { /// Publisher for connectivity availability. var statusPublisher: AnyPublisher { get } - - /// Starts the observer. - func startObserving() - - /// Stops the observer. - func stopObserving() } /// Defines the various states of network connectivity. diff --git a/Modules/Sources/WooFoundation/Utilities/Connectivity/DefaultConnectivityObserver.swift b/Modules/Sources/WooFoundation/Utilities/Connectivity/DefaultConnectivityObserver.swift index 24ca1ddad1b..1535d2090df 100644 --- a/Modules/Sources/WooFoundation/Utilities/Connectivity/DefaultConnectivityObserver.swift +++ b/Modules/Sources/WooFoundation/Utilities/Connectivity/DefaultConnectivityObserver.swift @@ -29,11 +29,11 @@ public final class DefaultConnectivityObserver: ConnectivityObserver { } } - public func startObserving() { + private func startObserving() { networkMonitor.start(queue: observingQueue) } - public func stopObserving() { + func stopObserving() { networkMonitor.cancel() } diff --git a/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift b/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift index 78e9a6cefea..d9792a73570 100644 --- a/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift +++ b/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift @@ -109,8 +109,6 @@ class EmptyPOSConnectivityProvider: POSConnectivityProviding { class EmptyPOSConnectivity: ConnectivityObserver { @Published private(set) var currentStatus: ConnectivityStatus = .reachable(type: .ethernetOrWiFi) var statusPublisher: AnyPublisher { $currentStatus.eraseToAnyPublisher() } - func startObserving() {} - func stopObserving() {} init() {} } diff --git a/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift b/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift index 9a96eadd986..b0d6f0a1cc2 100644 --- a/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift +++ b/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift @@ -219,9 +219,6 @@ final class POSConnectivityObserverPreview: ConnectivityObserver { var statusPublisher: AnyPublisher { $currentStatus.eraseToAnyPublisher() } - func startObserving() {} - - func stopObserving() {} } struct POSPreviewHelpers { diff --git a/WooCommerce/WooCommerceTests/Mocks/MockConnectivityObserver.swift b/WooCommerce/WooCommerceTests/Mocks/MockConnectivityObserver.swift index e4b2d377262..c5f7a4292cf 100644 --- a/WooCommerce/WooCommerceTests/Mocks/MockConnectivityObserver.swift +++ b/WooCommerce/WooCommerceTests/Mocks/MockConnectivityObserver.swift @@ -9,14 +9,6 @@ final class MockConnectivityObserver: ConnectivityObserver { $currentStatus.eraseToAnyPublisher() } - func startObserving() { - // no-op - } - - func stopObserving() { - // no-op - } - func setStatus(_ status: ConnectivityStatus) { currentStatus = status } From f5f063428cf17baf87d48bdaa9bbc325487be775 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Tue, 30 Sep 2025 16:46:31 +0800 Subject: [PATCH 05/11] Fix build error from accidentally deleted code from merge. --- .../Classes/POS/Models/PointOfSaleAggregateModel.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift b/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift index d2d89e46ef7..81dca596deb 100644 --- a/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift +++ b/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift @@ -616,3 +616,12 @@ extension PointOfSaleAggregateModel { cancellables.forEach { $0.cancel() } } } + +#if DEBUG +extension PointOfSaleAggregateModel { + func setPreviewState(paymentState: PointOfSalePaymentState, inlineMessage: PointOfSaleCardPresentPaymentMessageType?) { + self.paymentState = paymentState + self.cardPresentPaymentInlineMessage = inlineMessage + } +} +#endif From 5483fd90d7f87ae17c33ed7b50d7d1379055d9b6 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 1 Oct 2025 11:04:11 +0800 Subject: [PATCH 06/11] Fix another round of straightforward Periphery warnings. --- .../Models/PointOfSaleAggregateModel.swift | 26 ------ .../Presentation/Item Selector/ItemList.swift | 1 - .../POS/Utils/POSEnvironmentKeys.swift | 4 - .../Classes/POS/Utils/PreviewHelpers.swift | 22 +----- .../Mocks/MockPointOfSaleAggregateModel.swift | 79 ------------------- 5 files changed, 2 insertions(+), 130 deletions(-) diff --git a/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift b/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift index 81dca596deb..32773af7c48 100644 --- a/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift +++ b/WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift @@ -15,36 +15,10 @@ import protocol Yosemite.PointOfSaleBarcodeScanServiceProtocol import enum Yosemite.PointOfSaleBarcodeScanError protocol PointOfSaleAggregateModelProtocol { - var orderStage: PointOfSaleOrderStage { get } - - var cardReaderConnectionStatus: CardPresentPaymentReaderConnectionStatus { get } - func connectCardReader() - func disconnectCardReader() - var paymentState: PointOfSalePaymentState { get } - var cardPresentPaymentAlertViewModel: PointOfSaleCardPresentPaymentAlertType? { get set } - var cardPresentPaymentInlineMessage: PointOfSaleCardPresentPaymentMessageType? { get } - func cancelCardPaymentsOnboarding() - func trackCardPaymentsOnboardingShown() - - var purchasableItemsController: PointOfSaleItemsControllerProtocol { get } - var purchasableItemsSearchController: PointOfSaleSearchingItemsControllerProtocol { get } - var couponsController: PointOfSaleCouponsControllerProtocol { get } - var couponsSearchController: PointOfSaleSearchingItemsControllerProtocol { get } - var cart: Cart { get } - func barcodeScanned(_ result: Result) func addToCart(_ item: POSItem) - func remove(cartItem: CartItem) - func removeAllItemsFromCart(types: [CartItemType]) - func addMoreToCart() - func startNewCart() func saveSearchTerm(_ term: String, for itemType: POSItemType) - - var orderState: PointOfSaleOrderState { get } - func checkOut() async - - func pointOfSaleClosed() } @Observable final class PointOfSaleAggregateModel: PointOfSaleAggregateModelProtocol { diff --git a/WooCommerce/Classes/POS/Presentation/Item Selector/ItemList.swift b/WooCommerce/Classes/POS/Presentation/Item Selector/ItemList.swift index 6b235518aba..11ca3012fbe 100644 --- a/WooCommerce/Classes/POS/Presentation/Item Selector/ItemList.swift +++ b/WooCommerce/Classes/POS/Presentation/Item Selector/ItemList.swift @@ -151,7 +151,6 @@ struct ItemListRow: View { let item: POSItem let itemActionHandler: POSItemActionHandler @Binding var activeNavigationItem: POSItem? - @Environment(PointOfSaleAggregateModel.self) private var posModel var body: some View { switch item { diff --git a/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift b/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift index d9792a73570..44fe15d96bd 100644 --- a/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift +++ b/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift @@ -11,10 +11,6 @@ struct SiteTimezoneKey: EnvironmentKey { static let defaultValue: TimeZone = .current } -struct POSDependenciesKey: EnvironmentKey { - static let defaultValue: POSDependencyProviding? = nil -} - extension EnvironmentValues { var siteTimezone: TimeZone { get { self[SiteTimezoneKey.self] } diff --git a/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift b/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift index b0d6f0a1cc2..89f1a7183cf 100644 --- a/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift +++ b/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift @@ -82,17 +82,11 @@ final class PointOfSalePreviewItemService: PointOfSaleItemServiceProtocol { .init(items: mockVariationItems, hasMorePages: true, totalItems: nil) } - func providePointOfSaleItems() -> [POSItem] { - return mockItems - } - func providePointOfSaleItem() -> POSOrderableItem { POSProductPreview(id: UUID(), name: "Product 1", formattedPrice: "$1.00") } - - var fetchStrategy: PointOfSalePurchasableItemFetchStrategy = PointOfSalePreviewPurchasableItemFetchStrategy() } struct PointOfSalePreviewPurchasableItemFetchStrategy: PointOfSalePurchasableItemFetchStrategy { @@ -121,15 +115,14 @@ final class PointOfSalePreviewItemsController: PointOfSaleSearchingItemsControll @Published var itemsViewState: ItemsViewState = ItemsViewState(containerState: .loading, itemsStack: ItemsStackState(root: .loading([]), itemStates: [:])) - var itemsViewStatePublisher: any Publisher { $itemsViewState } func loadItems(base: ItemListBaseItem) async { switch base { case .root: itemsViewState = ItemsViewState(containerState: .content, itemsStack: ItemsStackState(root: .loaded(mockItems, hasMoreItems: true), itemStates: [:])) - case .parent(let parent): - await loadInitialChildItems(for: parent) + case .parent: + break } } @@ -145,10 +138,6 @@ final class PointOfSalePreviewItemsController: PointOfSaleSearchingItemsControll itemsViewState = ItemsViewState(containerState: .content, itemsStack: ItemsStackState(root: .loading(mockItems), itemStates: [:])) } - - private func loadInitialChildItems(for parent: POSItem) async { - // Set `itemsViewState` instead. - } } final class PointOfSalePreviewItemActionHandler: POSItemActionHandler { @@ -214,13 +203,6 @@ private var mockVariationItems: [POSItem] { ] } -final class POSConnectivityObserverPreview: ConnectivityObserver { - @Published private(set) var currentStatus: ConnectivityStatus = .unknown - var statusPublisher: AnyPublisher { - $currentStatus.eraseToAnyPublisher() - } -} - struct POSPreviewHelpers { static func makePreviewAggregateModel( itemsController: PointOfSaleItemsControllerProtocol = PointOfSalePreviewItemsController(), diff --git a/WooCommerce/WooCommerceTests/POS/Mocks/MockPointOfSaleAggregateModel.swift b/WooCommerce/WooCommerceTests/POS/Mocks/MockPointOfSaleAggregateModel.swift index 9f48d27d292..19c47adb185 100644 --- a/WooCommerce/WooCommerceTests/POS/Mocks/MockPointOfSaleAggregateModel.swift +++ b/WooCommerce/WooCommerceTests/POS/Mocks/MockPointOfSaleAggregateModel.swift @@ -5,88 +5,9 @@ import protocol Yosemite.POSOrderableItem import enum Yosemite.POSItemType final class MockPointOfSaleAggregateModel: PointOfSaleAggregateModelProtocol { - var cardReaderConnectionStatus: CardPresentPaymentReaderConnectionStatus - - func connectCardReader() { } - - func disconnectCardReader() { } - - var paymentState: WooCommerce.PointOfSalePaymentState - - var cardPresentPaymentAlertViewModel: WooCommerce.PointOfSaleCardPresentPaymentAlertType? - - var cardPresentPaymentInlineMessage: WooCommerce.PointOfSaleCardPresentPaymentMessageType? - - var cardPresentPaymentOnboardingViewContainer: WooCommerce.CardPresentPaymentOnboardingViewContainer? - - func cancelCardPaymentsOnboarding() { } - - func trackCardPaymentsOnboardingShown() { } - - var orderStage: PointOfSaleOrderStage - - var orderState: WooCommerce.PointOfSaleOrderState - - var purchasableItemsController: any WooCommerce.PointOfSaleItemsControllerProtocol - - var purchasableItemsSearchController: any WooCommerce.PointOfSaleSearchingItemsControllerProtocol - - var couponsController: any WooCommerce.PointOfSaleCouponsControllerProtocol - - var couponsSearchController: any WooCommerce.PointOfSaleSearchingItemsControllerProtocol - - var blockReturnToItemSelection: Bool = false - - init(cardReaderConnectionStatus: CardPresentPaymentReaderConnectionStatus = .disconnected, - purchasableItemsController: PointOfSaleItemsControllerProtocol = MockPointOfSaleItemsController(), - purchasableItemsSearchController: PointOfSaleSearchingItemsControllerProtocol = MockPointOfSalePurchasableItemsSearchController(), - couponsController: PointOfSaleCouponsControllerProtocol = MockPointOfSaleCouponsController(), - couponsSearchController: PointOfSaleSearchingItemsControllerProtocol = MockPointOfSaleCouponsController(), - orderStage: PointOfSaleOrderStage = .building, - orderState: PointOfSaleOrderState = .idle, - paymentState: PointOfSalePaymentState = .idle) { - self.cardReaderConnectionStatus = cardReaderConnectionStatus - self.purchasableItemsController = purchasableItemsController - self.purchasableItemsSearchController = purchasableItemsSearchController - self.couponsController = couponsController - self.couponsSearchController = couponsSearchController - self.orderStage = orderStage - self.orderState = orderState - self.paymentState = paymentState - } - - func loadItems(base: ItemListBaseItem) async { } - - func loadNextItems(base: ItemListBaseItem) async { } - var cart: Cart = .init() - func barcodeScanned(_ result: Result) { } - func addToCart(_ item: POSItem) { } - func remove(cartItem: CartItem) { } - - var removeAllItemsFromCartCalled = false - func removeAllItemsFromCart() { - removeAllItemsFromCartCalled = true - } - - func removeAllItemsFromCart(types: [CartItemType]) { } - - func checkOut() async { } - - func addMoreToCart() { } - - func startNewCart() { } - - func pointOfSaleClosed() { } - func saveSearchTerm(_ term: String, for itemType: POSItemType) { } - - func searchHistory(for itemType: Yosemite.POSItemType) -> [String] { - return [] - } - - func loadPopularItems(type: Yosemite.POSItemType) async { } } From 59b41b3b47a8108d7ebd44a29c3be2e4df45fc6e Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 1 Oct 2025 12:44:55 +0800 Subject: [PATCH 07/11] Fix more Periphery warnings. To test: POS search history, shadow. --- .../PointOfSale/POSSearchHistoryService.swift | 16 ---------- .../POSSearchHistoryServiceTests.swift | 32 ------------------- .../Classes/POS/Utils/POSShadowStyle.swift | 3 -- .../Classes/POS/Utils/PreviewHelpers.swift | 4 --- .../Mocks/MockPOSSearchHistoryService.swift | 4 --- 5 files changed, 59 deletions(-) diff --git a/Modules/Sources/Yosemite/PointOfSale/POSSearchHistoryService.swift b/Modules/Sources/Yosemite/PointOfSale/POSSearchHistoryService.swift index 94c01a8462b..821d1754a59 100644 --- a/Modules/Sources/Yosemite/PointOfSale/POSSearchHistoryService.swift +++ b/Modules/Sources/Yosemite/PointOfSale/POSSearchHistoryService.swift @@ -4,8 +4,6 @@ import Storage public protocol POSSearchHistoryProviding { func saveSuccessfulSearch(term: String, for itemType: POSItemType) func searchHistory(for itemType: POSItemType) -> [String] - func clearSearchHistory(for itemType: POSItemType) - func clearAllSearchHistory() } /// Service for managing search history in the Point of Sale @@ -60,18 +58,4 @@ public final class POSSearchHistoryService: POSSearchHistoryProviding { public func searchHistory(for itemType: POSItemType) -> [String] { return siteSpecificAppSettingsStoreMethods.getSearchTerms(for: itemType, siteID: siteID) } - - /// Clears the search history for a specific item type - /// - Parameter itemType: The type of item to clear search history for - public func clearSearchHistory(for itemType: POSItemType) { - siteSpecificAppSettingsStoreMethods.setSearchTerms([], for: itemType, siteID: siteID) - } - - /// Clears all search history - public func clearAllSearchHistory() { - // Clear search history for all item types - POSItemType.allCases.forEach { itemType in - clearSearchHistory(for: itemType) - } - } } diff --git a/Modules/Tests/YosemiteTests/PointOfSale/POSSearchHistoryServiceTests.swift b/Modules/Tests/YosemiteTests/PointOfSale/POSSearchHistoryServiceTests.swift index 5c14aff59cb..a9468ee1a79 100644 --- a/Modules/Tests/YosemiteTests/PointOfSale/POSSearchHistoryServiceTests.swift +++ b/Modules/Tests/YosemiteTests/PointOfSale/POSSearchHistoryServiceTests.swift @@ -89,38 +89,6 @@ struct POSSearchHistoryServiceTests { #expect(history.isEmpty) } - @Test func clearSearchHistory_clears_history_for_specific_item_type() throws { - // Given - sut.saveSuccessfulSearch(term: "product", for: .product) - sut.saveSuccessfulSearch(term: "coupon", for: .coupon) - - // When - sut.clearSearchHistory(for: .product) - - // Then - let productsSearchHistory = try #require(mockStoreMethods.mockSearchTerms[.product]) - let couponsSearchHistory = try #require(mockStoreMethods.mockSearchTerms[.coupon]) - #expect(productsSearchHistory.isEmpty) - #expect(couponsSearchHistory.count == 1) - #expect(couponsSearchHistory.first == "coupon") - } - - @Test func clearAllSearchHistory_clears_all_history() throws { - // Given - mockStoreMethods.mockSearchTerms[.product] = ["product"] - mockStoreMethods.mockSearchTerms[.coupon] = ["coupon"] - - // When - sut.clearAllSearchHistory() - - // Then - #expect(mockStoreMethods.setSearchTermsCalled) - let productsSearchHistory = try #require(mockStoreMethods.mockSearchTerms[.product]) - let couponsSearchHistory = try #require(mockStoreMethods.mockSearchTerms[.coupon]) - #expect(productsSearchHistory.isEmpty) - #expect(couponsSearchHistory.isEmpty) - } - @Test func search_history_is_separate_for_different_item_types() { // Given mockStoreMethods.mockSearchTerms[.product] = ["product"] diff --git a/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift b/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift index 04119bd4a8e..24d3a247144 100644 --- a/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift +++ b/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift @@ -108,7 +108,6 @@ extension View { private class MultiShadowView: UIView { var cornerRadius: CGFloat = 0 var shadowLayers: [POSShadowLayer] = [] - var fillColor: UIColor = .clear override func layoutSubviews() { super.layoutSubviews() @@ -141,14 +140,12 @@ private struct RasterizedShadowBackground: UIViewRepresentable { let view = MultiShadowView() view.cornerRadius = cornerRadius view.shadowLayers = shadowLayers - view.fillColor = backgroundColor return view } func updateUIView(_ uiView: MultiShadowView, context: Context) { uiView.cornerRadius = cornerRadius uiView.shadowLayers = shadowLayers - uiView.fillColor = backgroundColor uiView.setNeedsLayout() } } diff --git a/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift b/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift index 89f1a7183cf..6d817850d14 100644 --- a/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift +++ b/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift @@ -150,10 +150,6 @@ final class PointOfSalePreviewHistoryService: POSSearchHistoryProviding { func searchHistory(for itemType: POSItemType) -> [String] { return [] } - - func clearSearchHistory(for itemType: POSItemType) {} - - func clearAllSearchHistory() {} } private var mockItems: [POSItem] { diff --git a/WooCommerce/WooCommerceTests/POS/Mocks/MockPOSSearchHistoryService.swift b/WooCommerce/WooCommerceTests/POS/Mocks/MockPOSSearchHistoryService.swift index 27db1cb7d00..3896b58c9e0 100644 --- a/WooCommerce/WooCommerceTests/POS/Mocks/MockPOSSearchHistoryService.swift +++ b/WooCommerce/WooCommerceTests/POS/Mocks/MockPOSSearchHistoryService.swift @@ -7,8 +7,4 @@ struct MockPOSSearchHistoryService: POSSearchHistoryProviding { func searchHistory(for itemType: POSItemType) -> [String] { return [] } - - func clearSearchHistory(for itemType: POSItemType) {} - - func clearAllSearchHistory() {} } From 56c0346eb241de958d1f6e3fbda8e3f4eec99c8b Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 1 Oct 2025 12:45:36 +0800 Subject: [PATCH 08/11] Refactor `POSSearchTextFieldStyle` to a view modifier to avoid using private API `_body`. --- .../Item Search/POSSearchTextFieldStyle.swift | 16 +++++++++++----- .../Presentation/Item Search/POSSearchView.swift | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchTextFieldStyle.swift b/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchTextFieldStyle.swift index b9708d6f3c8..f0a8809022b 100644 --- a/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchTextFieldStyle.swift +++ b/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchTextFieldStyle.swift @@ -1,8 +1,8 @@ import SwiftUI import WooFoundation -/// Text field style for search fields that includes a magnifier icon and clear button -struct POSSearchTextFieldStyle: TextFieldStyle { +/// View modifier for search fields that includes a magnifier icon and clear button +struct POSSearchTextFieldModifier: ViewModifier { private let focused: Bool @Binding private var searchTerm: String @ScaledMetric private var searchFieldHeight: CGFloat = 56.0 @@ -12,8 +12,8 @@ struct POSSearchTextFieldStyle: TextFieldStyle { self._searchTerm = searchTerm } - func _body(configuration: TextField) -> some View { - configuration + func body(content: Content) -> some View { + content .textFieldStyle(WooRoundedBorderTextFieldStyle( focused: focused, focusedBorderColor: .posPrimary, @@ -49,7 +49,13 @@ struct POSSearchTextFieldStyle: TextFieldStyle { } } -private extension POSSearchTextFieldStyle { +extension View { + func posSearchTextFieldStyle(focused: Bool, searchTerm: Binding) -> some View { + modifier(POSSearchTextFieldModifier(focused: focused, searchTerm: searchTerm)) + } +} + +private extension POSSearchTextFieldModifier { enum Localization { static let searchFieldClearButtonAccessibilityLabel = NSLocalizedString( "pos.searchview.searchField.clearButton.accessibilityLabel", diff --git a/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchView.swift b/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchView.swift index 9461504ddba..974b7d09868 100644 --- a/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchView.swift +++ b/WooCommerce/Classes/POS/Presentation/Item Search/POSSearchView.swift @@ -47,8 +47,8 @@ struct POSSearchField: View { TextField(text: $searchTerm) { Text(searchable.searchFieldPlaceholder) } - .textFieldStyle(POSSearchTextFieldStyle(focused: isSearchFieldFocused, - searchTerm: $searchTerm)) + .posSearchTextFieldStyle(focused: isSearchFieldFocused, + searchTerm: $searchTerm) .font(.posBodyLargeBold) .autocorrectionDisabled() .textInputAutocapitalization(.never) From 9ed70d3986b96b598da51986531333e8dbb034ce Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 1 Oct 2025 13:07:16 +0800 Subject: [PATCH 09/11] Remove unused `RasterizedShadowBackground.backgroundColor`. --- WooCommerce/Classes/POS/Utils/POSShadowStyle.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift b/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift index 24d3a247144..c0860ed3e6e 100644 --- a/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift +++ b/WooCommerce/Classes/POS/Utils/POSShadowStyle.swift @@ -31,8 +31,7 @@ struct POSShadowStyleModifier: ViewModifier { let shadowLayers = shadowLayers(for: style) RasterizedShadowBackground( cornerRadius: cornerRadius, - shadowLayers: shadowLayers, - backgroundColor: UIColor.clear + shadowLayers: shadowLayers ) .frame(width: geometry.size.width, height: geometry.size.height) } @@ -134,7 +133,6 @@ private class MultiShadowView: UIView { private struct RasterizedShadowBackground: UIViewRepresentable { let cornerRadius: CGFloat let shadowLayers: [POSShadowLayer] - let backgroundColor: UIColor func makeUIView(context: Context) -> MultiShadowView { let view = MultiShadowView() From bbcbc9265b1afc88b0658f392b58746533ef35ca Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 1 Oct 2025 13:10:05 +0800 Subject: [PATCH 10/11] Remove unused `DynamicHStack` and `DynamicVStack`. --- .../Classes/POS/Utils/DynamicHStack.swift | 34 ------------------- .../Classes/POS/Utils/DynamicVStack.swift | 34 ------------------- .../WooCommerce.xcodeproj/project.pbxproj | 8 ----- 3 files changed, 76 deletions(-) delete mode 100644 WooCommerce/Classes/POS/Utils/DynamicHStack.swift delete mode 100644 WooCommerce/Classes/POS/Utils/DynamicVStack.swift diff --git a/WooCommerce/Classes/POS/Utils/DynamicHStack.swift b/WooCommerce/Classes/POS/Utils/DynamicHStack.swift deleted file mode 100644 index 3b455abb160..00000000000 --- a/WooCommerce/Classes/POS/Utils/DynamicHStack.swift +++ /dev/null @@ -1,34 +0,0 @@ -import SwiftUI - -/// HStack that turns into VStack with large accessibility sizes -struct DynamicHStack: View { - @Environment(\.dynamicTypeSize) var dynamicTypeSize - - let horizontalAlignment: HorizontalAlignment - let verticalAlignment: VerticalAlignment - let spacing: CGFloat - let content: () -> Content - - init(horizontalAlignment: HorizontalAlignment = .leading, - verticalAlignment: VerticalAlignment = .center, - spacing: CGFloat = 0, - @ViewBuilder content: @escaping () -> Content) { - self.horizontalAlignment = horizontalAlignment - self.verticalAlignment = verticalAlignment - self.spacing = spacing - self.content = content - } - - @ViewBuilder - var body: some View { - dynamicLayout(content) - } - - private var dynamicLayout: AnyLayout { - if dynamicTypeSize.isAccessibilitySize { - AnyLayout(VStackLayout(alignment: horizontalAlignment, spacing: spacing)) - } else { - AnyLayout(HStackLayout(alignment: verticalAlignment, spacing: spacing)) - } - } -} diff --git a/WooCommerce/Classes/POS/Utils/DynamicVStack.swift b/WooCommerce/Classes/POS/Utils/DynamicVStack.swift deleted file mode 100644 index 6c47ca83fd4..00000000000 --- a/WooCommerce/Classes/POS/Utils/DynamicVStack.swift +++ /dev/null @@ -1,34 +0,0 @@ -import SwiftUI - -/// VStack that turns into HStack with large accessibility sizes -struct DynamicVStack: View { - @Environment(\.dynamicTypeSize) var dynamicTypeSize - - let horizontalAlignment: HorizontalAlignment - let verticalAlignment: VerticalAlignment - let spacing: CGFloat - let content: () -> Content - - init(horizontalAlignment: HorizontalAlignment = .leading, - verticalAlignment: VerticalAlignment = .center, - spacing: CGFloat = 0, - @ViewBuilder content: @escaping () -> Content) { - self.horizontalAlignment = horizontalAlignment - self.verticalAlignment = verticalAlignment - self.spacing = spacing - self.content = content - } - - @ViewBuilder - var body: some View { - dynamicLayout(content) - } - - private var dynamicLayout: AnyLayout { - if dynamicTypeSize.isAccessibilitySize { - AnyLayout(HStackLayout(alignment: verticalAlignment, spacing: spacing)) - } else { - AnyLayout(VStackLayout(alignment: horizontalAlignment, spacing: spacing)) - } - } -} diff --git a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj index 39d7eae2202..b3838caad63 100644 --- a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj +++ b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj @@ -146,7 +146,6 @@ 01F935532DFC0B9900B50B03 /* PointOfSaleSoundPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F935522DFC0B9700B50B03 /* PointOfSaleSoundPlayer.swift */; }; 01F935572DFC0C6400B50B03 /* pos_scan_failure.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 01F935562DFC0C6400B50B03 /* pos_scan_failure.mp3 */; }; 01F935592DFC0D4C00B50B03 /* MockPointOfSaleSoundPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F935582DFC0D4800B50B03 /* MockPointOfSaleSoundPlayer.swift */; }; - 01FB19582C6E901800A44FF0 /* DynamicHStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01FB19572C6E901800A44FF0 /* DynamicHStack.swift */; }; 0202B68D23876BC100F3EBE0 /* ProductsTabProductViewModel+ProductVariation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0202B68C23876BC100F3EBE0 /* ProductsTabProductViewModel+ProductVariation.swift */; }; 0202B6922387AB0C00F3EBE0 /* WooTab+Tag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0202B6912387AB0C00F3EBE0 /* WooTab+Tag.swift */; }; 0202B6952387AD1B00F3EBE0 /* UITabBar+Order.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0202B6942387AD1B00F3EBE0 /* UITabBar+Order.swift */; }; @@ -1640,7 +1639,6 @@ 685A30612E60908C001E667B /* POSSettingsStoreViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 685A30602E60908B001E667B /* POSSettingsStoreViewModel.swift */; }; 68600A8F2C65BC5500252EDD /* POSListErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68600A8E2C65BC5500252EDD /* POSListErrorView.swift */; }; 68600A912C65BC9C00252EDD /* POSListEmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68600A902C65BC9C00252EDD /* POSListEmptyView.swift */; }; - 68625DE62D4134D70042B231 /* DynamicVStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68625DE52D4134D50042B231 /* DynamicVStack.swift */; }; 68674D312B6C895D00E93FBD /* ReceiptEligibilityUseCaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68674D302B6C895D00E93FBD /* ReceiptEligibilityUseCaseTests.swift */; }; 686A71B62DC9E5C10006E835 /* POSItemActionHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 686A71B52DC9E5C10006E835 /* POSItemActionHandlerTests.swift */; }; 686A71B82DC9EB710006E835 /* MockPOSSearchHistoryService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 686A71B72DC9EB6D0006E835 /* MockPOSSearchHistoryService.swift */; }; @@ -3376,7 +3374,6 @@ 01F935522DFC0B9700B50B03 /* PointOfSaleSoundPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointOfSaleSoundPlayer.swift; sourceTree = ""; }; 01F935562DFC0C6400B50B03 /* pos_scan_failure.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = pos_scan_failure.mp3; sourceTree = ""; }; 01F935582DFC0D4800B50B03 /* MockPointOfSaleSoundPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPointOfSaleSoundPlayer.swift; sourceTree = ""; }; - 01FB19572C6E901800A44FF0 /* DynamicHStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicHStack.swift; sourceTree = ""; }; 0202B68C23876BC100F3EBE0 /* ProductsTabProductViewModel+ProductVariation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProductsTabProductViewModel+ProductVariation.swift"; sourceTree = ""; }; 0202B6912387AB0C00F3EBE0 /* WooTab+Tag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WooTab+Tag.swift"; sourceTree = ""; }; 0202B6942387AD1B00F3EBE0 /* UITabBar+Order.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabBar+Order.swift"; sourceTree = ""; }; @@ -4854,7 +4851,6 @@ 685A30602E60908B001E667B /* POSSettingsStoreViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = POSSettingsStoreViewModel.swift; sourceTree = ""; }; 68600A8E2C65BC5500252EDD /* POSListErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = POSListErrorView.swift; sourceTree = ""; }; 68600A902C65BC9C00252EDD /* POSListEmptyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = POSListEmptyView.swift; sourceTree = ""; }; - 68625DE52D4134D50042B231 /* DynamicVStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicVStack.swift; sourceTree = ""; }; 68674D302B6C895D00E93FBD /* ReceiptEligibilityUseCaseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiptEligibilityUseCaseTests.swift; sourceTree = ""; }; 686A71B52DC9E5C10006E835 /* POSItemActionHandlerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = POSItemActionHandlerTests.swift; sourceTree = ""; }; 686A71B72DC9EB6D0006E835 /* MockPOSSearchHistoryService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPOSSearchHistoryService.swift; sourceTree = ""; }; @@ -7298,8 +7294,6 @@ 68E4E8B42C0EF39D00CFA0C3 /* PreviewHelpers.swift */, DA4104392C247B6900E8456A /* PointOfSalePreviewOrderController.swift */, 01664F9D2C50E685007CB5DD /* POSFontStyle.swift */, - 01FB19572C6E901800A44FF0 /* DynamicHStack.swift */, - 68625DE52D4134D50042B231 /* DynamicVStack.swift */, 02055B132D5DAB6400E51059 /* POSCornerRadiusStyle.swift */, 020564972D5DC96600E51059 /* POSShadowStyle.swift */, 02F3884B2D6C38BB00619396 /* POSErrorAndAlertIconSize.swift */, @@ -16442,7 +16436,6 @@ CEE006082077D14C0079161F /* OrderDetailsViewController.swift in Sources */, 01B744E22D2FCA1400AEB3F4 /* PushNotificationBackgroundSynchronizerFactory.swift in Sources */, CE4ECA582BC5B66A005F9386 /* WCAnalyticsStatsTotals+UI.swift in Sources */, - 01FB19582C6E901800A44FF0 /* DynamicHStack.swift in Sources */, AEB73C0C25CD734200A8454A /* AttributePickerViewModel.swift in Sources */, 2005D3F32DC13D6900E12021 /* PointOfSaleItemListAnalyticsTracker.swift in Sources */, D8752EF7265E60F4008ACC80 /* PaymentCaptureCelebration.swift in Sources */, @@ -17204,7 +17197,6 @@ 45D1CF4523BAC2A500945A36 /* ProductTaxClassListSelectorDataSource.swift in Sources */, 68600A912C65BC9C00252EDD /* POSListEmptyView.swift in Sources */, 319A626127ACAE3400BC96C3 /* InPersonPaymentsPluginChoicesView.swift in Sources */, - 68625DE62D4134D70042B231 /* DynamicVStack.swift in Sources */, 0365986729AFAEFC00F297D3 /* SetUpTapToPayViewModelsOrderedList.swift in Sources */, DEDA8D992B04643E0076BF0F /* ProductSubscription+Empty.swift in Sources */, 6856D31F941A33BAE66F394D /* KeyboardFrameAdjustmentProvider.swift in Sources */, From 33f6e09354d1db7c268636ac4a25d23dd12b0727 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 1 Oct 2025 13:29:42 +0800 Subject: [PATCH 11/11] Recover a comment about how to test different states in previews. --- WooCommerce/Classes/POS/Utils/PreviewHelpers.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift b/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift index 6d817850d14..4c66879f878 100644 --- a/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift +++ b/WooCommerce/Classes/POS/Utils/PreviewHelpers.swift @@ -122,6 +122,7 @@ final class PointOfSalePreviewItemsController: PointOfSaleSearchingItemsControll itemsViewState = ItemsViewState(containerState: .content, itemsStack: ItemsStackState(root: .loaded(mockItems, hasMoreItems: true), itemStates: [:])) case .parent: + // Set `itemsViewState` instead. break } }