-
Notifications
You must be signed in to change notification settings - Fork 121
[Woo POS][Settings] i2: Reader connection modal flow (2) #16290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
c5ef164
79e3a0d
d4eca92
d27d197
85fc3e9
3b4822d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| import SwiftUI | ||
| import struct WooFoundation.SafariView | ||
|
|
||
| struct PointOfSaleSettingsHardwareDetailView: View { | ||
| struct POSSettingsHardwareDetailView: View { | ||
| @Environment(PointOfSaleAggregateModel.self) private var posModel | ||
| @Environment(\.posFeatureFlags) private var featureFlags | ||
| @Environment(\.dynamicTypeSize) private var dynamicTypeSize | ||
| @Environment(\.posAnalytics) private var analytics | ||
|
|
||
| let settingsController: PointOfSaleSettingsControllerProtocol | ||
| let settingsController: POSSettingsControllerProtocol | ||
|
|
||
| @State private var navigationPath: [NavigationDestination] = [] | ||
| @State private var showBarcodeScanningSetupModal: Bool = false | ||
|
|
@@ -36,6 +36,7 @@ struct PointOfSaleSettingsHardwareDetailView: View { | |
| } | ||
|
|
||
| var body: some View { | ||
| @Bindable var posModel = posModel | ||
| NavigationStack(path: $navigationPath) { | ||
| POSPageHeaderView(title: Localization.hardwareTitle) | ||
| .foregroundColor(.posSurface) | ||
|
|
@@ -81,25 +82,25 @@ struct PointOfSaleSettingsHardwareDetailView: View { | |
| scannersView | ||
| } | ||
| } | ||
| .posModal(item: $posModel.cardPresentPaymentAlertViewModel, onDismiss: { | ||
| posModel.cardPresentPaymentAlertViewModel?.onDismiss?() | ||
| }, content: { alertType in | ||
| PointOfSaleCardPresentPaymentAlert(alertType: alertType) | ||
| .posInteractiveDismissDisabled(alertType.isDismissDisabled) | ||
| }) | ||
| .posModal(isPresented: $showBarcodeScanningSetupModal) { | ||
| PointOfSaleBarcodeScannerSetup(isPresented: $showBarcodeScanningSetupModal, analytics: analytics) | ||
| POSBarcodeScannerSetup(isPresented: $showBarcodeScanningSetupModal, analytics: analytics) | ||
| } | ||
| .posFullScreenCover(isPresented: $showBarcodeScanningDocumentationModal) { | ||
| SafariView(url: POSConstants.URLs.pointOfSaleBarcodeScannerDocumentation.asURL()) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private func handleScannerDestination(_ destination: ScannerDestination) { | ||
| switch destination { | ||
| case .setup: | ||
| showBarcodeScanningSetupModal = true | ||
| case .documentation: | ||
| showBarcodeScanningDocumentationModal = true | ||
| } | ||
| } | ||
|
|
||
| private var legacyCardReadersView: some View { | ||
| // MARK: - Views | ||
| private extension POSSettingsHardwareDetailView { | ||
| var legacyCardReadersView: some View { | ||
| VStack(spacing: POSSpacing.none) { | ||
| POSPageHeaderView( | ||
| title: Localization.cardReadersTitle, | ||
|
|
@@ -168,7 +169,7 @@ struct PointOfSaleSettingsHardwareDetailView: View { | |
| } | ||
| } | ||
|
|
||
| private var cardReadersView: some View { | ||
| var cardReadersView: some View { | ||
| VStack(spacing: POSSpacing.none) { | ||
| POSPageHeaderView( | ||
| title: Localization.cardReadersTitle, | ||
|
|
@@ -224,7 +225,7 @@ struct PointOfSaleSettingsHardwareDetailView: View { | |
| } | ||
| } | ||
|
|
||
| private var scannersView: some View { | ||
| var scannersView: some View { | ||
| VStack(spacing: POSSpacing.none) { | ||
| POSPageHeaderView( | ||
| title: Localization.scannersTitle, | ||
|
|
@@ -268,7 +269,7 @@ struct PointOfSaleSettingsHardwareDetailView: View { | |
| } | ||
|
|
||
| // MARK: - Navigation | ||
| private extension PointOfSaleSettingsHardwareDetailView { | ||
| private extension POSSettingsHardwareDetailView { | ||
| enum HardwareDestination: Identifiable, CaseIterable { | ||
| case cardReaders | ||
| case scanners | ||
|
|
@@ -340,9 +341,19 @@ private extension PointOfSaleSettingsHardwareDetailView { | |
| } | ||
| } | ||
| } | ||
|
|
||
| private func handleScannerDestination(_ destination: ScannerDestination) { | ||
| switch destination { | ||
| case .setup: | ||
| showBarcodeScanningSetupModal = true | ||
| case .documentation: | ||
| showBarcodeScanningDocumentationModal = true | ||
| } | ||
| } | ||
|
||
| } | ||
|
|
||
| private extension PointOfSaleSettingsHardwareDetailView { | ||
| // MARK: - Constants | ||
| private extension POSSettingsHardwareDetailView { | ||
| enum Localization { | ||
| static let readerModelTitle = NSLocalizedString( | ||
| "pointOfSaleSettingsHardwareDetailView.readerModelTitle", | ||
|
|
@@ -460,6 +471,6 @@ private extension PointOfSaleSettingsHardwareDetailView { | |
|
|
||
| #if DEBUG | ||
| #Preview { | ||
| PointOfSaleSettingsHardwareDetailView(settingsController: PointOfSaleSettingsPreviewController()) | ||
| POSSettingsHardwareDetailView(settingsController: POSSettingsPreviewController()) | ||
| } | ||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps there could be a shared definition of this somehow? Not if it's difficult; we're not going to use it in that many places, but it's essentially identical to
PointOfSaleDashboardView's use.I think it would have to be a view modifier, something like this:
Though perhaps it would be better named as POS specific, and have the posModal requirement more obvious than using the environment var directly. It might be interesting to try some options for a few minutes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That definitely looks cleaner, thanks! I'll play with this separately and merge this PR for now.