Skip to content

Commit 91bdd40

Browse files
authored
Merge branch 'trunk' into woomob-1430-mobile-paymentsios-enable-card-payments-using-stripe-gateway
2 parents ab76921 + fdc5938 commit 91bdd40

19 files changed

+68
-41
lines changed

Modules/Sources/PointOfSale/Models/PointOfSaleAggregateModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protocol PointOfSaleAggregateModelProtocol {
4343
let popularPurchasableItemsController: PointOfSaleItemsControllerProtocol
4444
let couponsController: PointOfSaleCouponsControllerProtocol
4545
let couponsSearchController: PointOfSaleSearchingItemsControllerProtocol
46-
let settingsController: PointOfSaleSettingsControllerProtocol
46+
let settingsController: POSSettingsControllerProtocol
4747

4848
private let cardPresentPaymentService: CardPresentPaymentFacade
4949
private let orderController: PointOfSaleOrderControllerProtocol
@@ -79,7 +79,7 @@ protocol PointOfSaleAggregateModelProtocol {
7979
couponsSearchController: PointOfSaleSearchingItemsControllerProtocol,
8080
cardPresentPaymentService: CardPresentPaymentFacade,
8181
orderController: PointOfSaleOrderControllerProtocol,
82-
settingsController: PointOfSaleSettingsControllerProtocol,
82+
settingsController: POSSettingsControllerProtocol,
8383
analytics: POSAnalyticsProviding,
8484
collectOrderPaymentAnalyticsTracker: POSCollectOrderPaymentAnalyticsTracking,
8585
searchHistoryService: POSSearchHistoryProviding,

Modules/Sources/PointOfSale/Models/PointOfSaleSettingsController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import protocol Storage.GRDBManagerProtocol
1111
import protocol Yosemite.POSCatalogSyncCoordinatorProtocol
1212
import class Yosemite.POSCatalogSettingsService
1313

14-
protocol PointOfSaleSettingsControllerProtocol {
14+
protocol POSSettingsControllerProtocol {
1515
var connectedCardReader: CardPresentPaymentCardReader? { get }
1616
var storeViewModel: POSSettingsStoreViewModel { get }
1717
var localCatalogViewModel: POSSettingsLocalCatalogViewModel? { get }
1818
var isLocalCatalogEligible: Bool { get }
1919
}
2020

21-
@Observable final class PointOfSaleSettingsController: PointOfSaleSettingsControllerProtocol {
21+
@Observable final class PointOfSaleSettingsController: POSSettingsControllerProtocol {
2222
private(set) var connectedCardReader: CardPresentPaymentCardReader?
2323
private var cancellables: AnyCancellable?
2424

@@ -72,7 +72,7 @@ protocol PointOfSaleSettingsControllerProtocol {
7272
}
7373

7474
#if DEBUG
75-
final class PointOfSaleSettingsPreviewController: PointOfSaleSettingsControllerProtocol {
75+
final class POSSettingsPreviewController: POSSettingsControllerProtocol {
7676
var connectedCardReader: CardPresentPaymentCardReader? = CardPresentPaymentCardReader(
7777
name: "WisePad 3",
7878
batteryLevel: 0.75
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import SwiftUI
22

3-
struct PointOfSaleBarcodeScannerSetup: View {
3+
struct POSBarcodeScannerSetup: View {
44
@Binding var isPresented: Bool
55
@State private var flowManager: PointOfSaleBarcodeScannerSetupFlowManager
66
@Environment(\.posModalParentSize) var parentSize
@@ -91,7 +91,7 @@ private enum Constants {
9191
}
9292

9393
// MARK: - Private Localization Extension
94-
private extension PointOfSaleBarcodeScannerSetup {
94+
private extension POSBarcodeScannerSetup {
9595
enum Localization {
9696
static let starBSH20BTitle = NSLocalizedString(
9797
"pos.barcodeScannerSetup.starBSH20B.title",
@@ -120,7 +120,7 @@ private extension PointOfSaleBarcodeScannerSetup {
120120

121121
#if DEBUG
122122
#Preview {
123-
PointOfSaleBarcodeScannerSetup(isPresented: .constant(true), analytics: EmptyPOSAnalytics())
123+
POSBarcodeScannerSetup(isPresented: .constant(true), analytics: EmptyPOSAnalytics())
124124
}
125125
#endif
126126

Modules/Sources/PointOfSale/Presentation/CartView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct CartView: View {
6969
}
7070
}
7171
.posModal(isPresented: $showBarcodeScanningModal) {
72-
PointOfSaleBarcodeScannerSetup(isPresented: $showBarcodeScanningModal, analytics: analytics)
72+
POSBarcodeScannerSetup(isPresented: $showBarcodeScanningModal, analytics: analytics)
7373
}
7474
.animation(Constants.cartAnimation, value: posModel.cart.isEmpty)
7575
.frame(maxWidth: .infinity)

Modules/Sources/PointOfSale/Presentation/POSFloatingControlView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct POSFloatingControlView: View {
5555
SimpleProductsOnlyInformation(isPresented: $showProductRestrictionsModal)
5656
}
5757
.posModal(isPresented: $showBarcodeScanningModal) {
58-
PointOfSaleBarcodeScannerSetup(isPresented: $showBarcodeScanningModal, analytics: analytics)
58+
POSBarcodeScannerSetup(isPresented: $showBarcodeScanningModal, analytics: analytics)
5959
}
6060
.posFullScreenCover(isPresented: $showOrders) {
6161
POSOrdersView(isPresented: $showOrders)

Modules/Sources/PointOfSale/Presentation/PointOfSaleEntryPointView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public struct PointOfSaleEntryPointView: View {
3333
private let couponsSearchController: PointOfSaleSearchingItemsControllerProtocol
3434
private let cardPresentPaymentService: CardPresentPaymentFacade
3535
private let orderController: PointOfSaleOrderControllerProtocol
36-
private let settingsController: PointOfSaleSettingsControllerProtocol
36+
private let settingsController: POSSettingsControllerProtocol
3737
private let collectOrderPaymentAnalyticsTracker: POSCollectOrderPaymentAnalyticsTracking
3838
private let searchHistoryService: POSSearchHistoryProviding
3939
private let popularPurchasableItemsController: PointOfSaleItemsControllerProtocol

Modules/Sources/PointOfSale/Presentation/Reusable Views/POSModalViewModifier.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ extension EnvironmentValues {
251251
}
252252
}
253253
.posModal(isPresented: $showModal) {
254-
PointOfSaleBarcodeScannerSetup(isPresented: $showModal, analytics: EmptyPOSAnalytics())
254+
POSBarcodeScannerSetup(isPresented: $showModal, analytics: EmptyPOSAnalytics())
255255
}
256256
.posRootModal()
257257
.environmentObject(modalManager)
Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import SwiftUI
22
import struct WooFoundation.SafariView
33

4-
struct PointOfSaleSettingsHardwareDetailView: View {
4+
struct POSSettingsHardwareDetailView: View {
55
@Environment(PointOfSaleAggregateModel.self) private var posModel
66
@Environment(\.posFeatureFlags) private var featureFlags
77
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
88
@Environment(\.posAnalytics) private var analytics
99

10-
let settingsController: PointOfSaleSettingsControllerProtocol
10+
let settingsController: POSSettingsControllerProtocol
1111

1212
@State private var navigationPath: [NavigationDestination] = []
1313
@State private var showBarcodeScanningSetupModal: Bool = false
@@ -36,6 +36,7 @@ struct PointOfSaleSettingsHardwareDetailView: View {
3636
}
3737

3838
var body: some View {
39+
@Bindable var posModel = posModel
3940
NavigationStack(path: $navigationPath) {
4041
POSPageHeaderView(title: Localization.hardwareTitle)
4142
.foregroundColor(.posSurface)
@@ -81,25 +82,25 @@ struct PointOfSaleSettingsHardwareDetailView: View {
8182
scannersView
8283
}
8384
}
85+
.posModal(item: $posModel.cardPresentPaymentAlertViewModel, onDismiss: {
86+
posModel.cardPresentPaymentAlertViewModel?.onDismiss?()
87+
}, content: { alertType in
88+
PointOfSaleCardPresentPaymentAlert(alertType: alertType)
89+
.posInteractiveDismissDisabled(alertType.isDismissDisabled)
90+
})
8491
.posModal(isPresented: $showBarcodeScanningSetupModal) {
85-
PointOfSaleBarcodeScannerSetup(isPresented: $showBarcodeScanningSetupModal, analytics: analytics)
92+
POSBarcodeScannerSetup(isPresented: $showBarcodeScanningSetupModal, analytics: analytics)
8693
}
8794
.posFullScreenCover(isPresented: $showBarcodeScanningDocumentationModal) {
8895
SafariView(url: POSConstants.URLs.pointOfSaleBarcodeScannerDocumentation.asURL())
8996
}
9097
}
9198
}
99+
}
92100

93-
private func handleScannerDestination(_ destination: ScannerDestination) {
94-
switch destination {
95-
case .setup:
96-
showBarcodeScanningSetupModal = true
97-
case .documentation:
98-
showBarcodeScanningDocumentationModal = true
99-
}
100-
}
101-
102-
private var legacyCardReadersView: some View {
101+
// MARK: - Views
102+
private extension POSSettingsHardwareDetailView {
103+
var legacyCardReadersView: some View {
103104
VStack(spacing: POSSpacing.none) {
104105
POSPageHeaderView(
105106
title: Localization.cardReadersTitle,
@@ -168,7 +169,7 @@ struct PointOfSaleSettingsHardwareDetailView: View {
168169
}
169170
}
170171

171-
private var cardReadersView: some View {
172+
var cardReadersView: some View {
172173
VStack(spacing: POSSpacing.none) {
173174
POSPageHeaderView(
174175
title: Localization.cardReadersTitle,
@@ -224,7 +225,7 @@ struct PointOfSaleSettingsHardwareDetailView: View {
224225
}
225226
}
226227

227-
private var scannersView: some View {
228+
var scannersView: some View {
228229
VStack(spacing: POSSpacing.none) {
229230
POSPageHeaderView(
230231
title: Localization.scannersTitle,
@@ -268,7 +269,7 @@ struct PointOfSaleSettingsHardwareDetailView: View {
268269
}
269270

270271
// MARK: - Navigation
271-
private extension PointOfSaleSettingsHardwareDetailView {
272+
private extension POSSettingsHardwareDetailView {
272273
enum HardwareDestination: Identifiable, CaseIterable {
273274
case cardReaders
274275
case scanners
@@ -340,9 +341,19 @@ private extension PointOfSaleSettingsHardwareDetailView {
340341
}
341342
}
342343
}
344+
345+
func handleScannerDestination(_ destination: ScannerDestination) {
346+
switch destination {
347+
case .setup:
348+
showBarcodeScanningSetupModal = true
349+
case .documentation:
350+
showBarcodeScanningDocumentationModal = true
351+
}
352+
}
343353
}
344354

345-
private extension PointOfSaleSettingsHardwareDetailView {
355+
// MARK: - Constants
356+
private extension POSSettingsHardwareDetailView {
346357
enum Localization {
347358
static let readerModelTitle = NSLocalizedString(
348359
"pointOfSaleSettingsHardwareDetailView.readerModelTitle",
@@ -460,6 +471,6 @@ private extension PointOfSaleSettingsHardwareDetailView {
460471

461472
#if DEBUG
462473
#Preview {
463-
PointOfSaleSettingsHardwareDetailView(settingsController: PointOfSaleSettingsPreviewController())
474+
POSSettingsHardwareDetailView(settingsController: POSSettingsPreviewController())
464475
}
465476
#endif

Modules/Sources/PointOfSale/Presentation/Settings/PointOfSaleSettingsStoreDetailView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ private extension PointOfSaleSettingsStoreDetailView {
198198

199199
#if DEBUG
200200
#Preview {
201-
let controller = PointOfSaleSettingsPreviewController()
201+
let controller = POSSettingsPreviewController()
202202
PointOfSaleSettingsStoreDetailView(viewModel: controller.storeViewModel)
203203
}
204204
#endif

Modules/Sources/PointOfSale/Presentation/Settings/PointOfSaleSettingsView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct PointOfSaleSettingsView: View {
55
@Environment(\.posAnalytics) private var analytics
66
@State private var selection: SidebarNavigation? = .store
77

8-
let settingsController: PointOfSaleSettingsControllerProtocol
8+
let settingsController: POSSettingsControllerProtocol
99

1010
var body: some View {
1111
GeometryReader { geometry in
@@ -86,7 +86,7 @@ extension PointOfSaleSettingsView {
8686
case .store:
8787
PointOfSaleSettingsStoreDetailView(viewModel: settingsController.storeViewModel)
8888
case .hardware:
89-
PointOfSaleSettingsHardwareDetailView(settingsController: settingsController)
89+
POSSettingsHardwareDetailView(settingsController: settingsController)
9090
case .localCatalog:
9191
if let viewModel = settingsController.localCatalogViewModel {
9292
POSSettingsLocalCatalogDetailView(viewModel: viewModel)
@@ -250,6 +250,6 @@ extension PointOfSaleSettingsView {
250250

251251
#if DEBUG
252252
#Preview {
253-
PointOfSaleSettingsView(settingsController: PointOfSaleSettingsPreviewController())
253+
PointOfSaleSettingsView(settingsController: POSSettingsPreviewController())
254254
}
255255
#endif

0 commit comments

Comments
 (0)