-
Notifications
You must be signed in to change notification settings - Fork 121
[Woo POS][Barcodes] Partial setup flow for Star BSH-20B #15893
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
Merged
joshheald
merged 7 commits into
trunk
from
woomob-696-woo-posbarcodes-set-up-flow-mid-range-star-bsh-2032-b
Jul 11, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ff587e1
Move welcome view to new file
joshheald b900359
Add Star set up code view in set up flow
joshheald 8553d97
Add pairing barcode scanner set up step
joshheald b180138
Avoid setting the frame on every step view
joshheald 6f9cd77
Add test barcode scanner setup step
joshheald 74eec0b
Add basic success view
joshheald f29c579
Show hint when we don’t get a test scan within 10s
joshheald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...ses/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupScanTester.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import Foundation | ||
|
|
||
| struct PointOfSaleBarcodeScannerSetupScanTester { | ||
| private let onTestPass: () -> Void | ||
| private let onTestFailure: () -> Void | ||
| private let barcodeDefinition: PointOfSaleBarcodeScannerTestBarcode | ||
|
|
||
| init(onTestPass: @escaping () -> Void, onTestFailure: @escaping () -> Void, barcodeDefinition: PointOfSaleBarcodeScannerTestBarcode) { | ||
| self.onTestPass = onTestPass | ||
| self.onTestFailure = onTestFailure | ||
| self.barcodeDefinition = barcodeDefinition | ||
| } | ||
|
|
||
| var barcode: PointOfSaleAssets { | ||
| barcodeDefinition.barcodeAsset | ||
| } | ||
|
|
||
| func handleScan(_ scanResult: Result<String, Error>) { | ||
| switch scanResult { | ||
| case .success(barcodeDefinition.expectedValue): | ||
| onTestPass() | ||
| case .success, .failure: | ||
| onTestFailure() | ||
| } | ||
| } | ||
| } |
196 changes: 196 additions & 0 deletions
196
...sses/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupStepViews.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| import SwiftUI | ||
|
|
||
| // TODO: Remove this view when all flows are complete | ||
| struct PointOfSaleBarcodeScannerWelcomeView: View { | ||
| let title: String | ||
|
|
||
| var body: some View { | ||
| VStack(spacing: POSSpacing.medium) { | ||
| Text(title) | ||
| .font(.posBodyLargeBold) | ||
| .foregroundColor(.posOnSurface) | ||
|
|
||
| Text("TODO: Implement \(title) setup flow") | ||
| .font(.posBodyMediumRegular()) | ||
| .foregroundColor(.posOnSurfaceVariantHighest) | ||
| .multilineTextAlignment(.center) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| struct PointOfSaleBarcodeScannerBarcodeView: View { | ||
| let title: String | ||
| let instruction: String | ||
| let barcode: PointOfSaleAssets | ||
|
|
||
| var body: some View { | ||
| VStack(spacing: POSSpacing.xLarge) { | ||
| VStack(alignment: .center, spacing: POSSpacing.small) { | ||
| Text(title) | ||
| .font(.posHeadingBold) | ||
| .foregroundColor(.posOnSurface) | ||
| .accessibilityAddTraits(.isHeader) | ||
|
|
||
| Text(instruction) | ||
| .font(.posBodyMediumRegular()) | ||
| .foregroundColor(.posOnSurfaceVariantHighest) | ||
| .multilineTextAlignment(.center) | ||
| } | ||
|
|
||
| Image(barcode.imageName) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| struct PointOfSaleBarcodeScannerPairingView: View { | ||
| let scanner: PointOfSaleBarcodeScannerType | ||
|
|
||
| var body: some View { | ||
| VStack(spacing: POSSpacing.xLarge) { | ||
| // Temporary image until finalised assets are available | ||
| Image(systemName: "gearshape") | ||
| .font(.system(size: 78)) | ||
| .accessibilityHidden(true) | ||
|
|
||
| VStack(alignment: .center, spacing: POSSpacing.small) { | ||
| Text(Localization.title) | ||
| .font(.posHeadingBold) | ||
| .foregroundColor(.posOnSurface) | ||
| .accessibilityAddTraits(.isHeader) | ||
|
|
||
| Text(instruction) | ||
| .font(.posBodyMediumRegular()) | ||
| .foregroundColor(.posOnSurfaceVariantHighest) | ||
| .multilineTextAlignment(.center) | ||
| } | ||
|
|
||
| Button { | ||
| guard let targetURL = URL(string: UIApplication.openSettingsURLString) else { | ||
| return | ||
| } | ||
| UIApplication.shared.open(targetURL) | ||
| } label: { | ||
| Text(Localization.settingsButtonTitle) | ||
| } | ||
| .buttonStyle(POSOutlinedButtonStyle(size: .extraSmall)) | ||
| } | ||
| } | ||
|
|
||
| private var instruction: String { | ||
| String(format: Localization.instructionFormat, scanner.name) | ||
| } | ||
| } | ||
|
|
||
| private extension PointOfSaleBarcodeScannerPairingView { | ||
| //TODO: WOOMOB-792 | ||
| enum Localization { | ||
| static let settingsButtonTitle = "Go to settings" | ||
| static let title = "Pair your device" | ||
| static let instructionFormat = "Enable Bluetooth and select your %1$@ scanner in iOS Settings." | ||
| } | ||
| } | ||
|
|
||
| @available(iOS 17.0, *) | ||
| struct PointOfSaleBarcodeScannerTestBarcodeView: View { | ||
| let scanTester: PointOfSaleBarcodeScannerSetupScanTester | ||
| @State private var timerCompleted = false | ||
| @State private var timer: Timer? | ||
|
|
||
| var body: some View { | ||
| PointOfSaleBarcodeScannerBarcodeView(title: timerCompleted ? Localization.timeoutTitle : Localization.title, | ||
| instruction: timerCompleted ? Localization.timeoutInstruction : Localization.instruction, | ||
| barcode: scanTester.barcode) | ||
| .barcodeScanning { result in | ||
| scanTester.handleScan(result) | ||
| } | ||
| .onAppear { | ||
| startTimer() | ||
| } | ||
| .onDisappear { | ||
| timer?.invalidate() | ||
| timer = nil | ||
| } | ||
| } | ||
|
|
||
| private func startTimer() { | ||
| timer = Timer.scheduledTimer(withTimeInterval: 10.0, repeats: false) { _ in | ||
| timerCompleted = true | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @available(iOS 17.0, *) | ||
| private extension PointOfSaleBarcodeScannerTestBarcodeView { | ||
| enum Localization { | ||
| static let title = "Test your scanner" | ||
| static let instruction = "Scan the barcode to test your scanner" | ||
| static let timeoutTitle = "No scan data found yet" | ||
| static let timeoutInstruction = "Scan the barcode to test your scanner. If the issue continues, please check Bluetooth settings and try again." | ||
| } | ||
| } | ||
|
|
||
| struct PointOfSaleBarcodeScannerSetupCompleteView: View { | ||
| var body: some View { | ||
| VStack(spacing: POSSpacing.xLarge) { | ||
| // Temporary image until finalised assets are available | ||
| successIcon | ||
| .accessibilityHidden(true) | ||
|
|
||
| VStack(alignment: .center, spacing: POSSpacing.small) { | ||
| Text(Localization.title) | ||
| .font(.posHeadingBold) | ||
| .foregroundColor(.posOnSurface) | ||
| .accessibilityAddTraits(.isHeader) | ||
|
|
||
| Text(Localization.instruction) | ||
| .font(.posBodyMediumRegular()) | ||
| .foregroundColor(.posOnSurfaceVariantHighest) | ||
| .multilineTextAlignment(.center) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @ViewBuilder private var successIcon: some View { | ||
| ZStack { | ||
| Circle() | ||
| .frame(width: 104, height: 104) | ||
| .foregroundColor(.posSuccess) | ||
| Image(PointOfSaleAssets.successCheck.imageName) | ||
| .renderingMode(.template) | ||
| .resizable() | ||
| .frame(width: 48, height: 48) | ||
| .foregroundColor(.posOnSuccess) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private extension PointOfSaleBarcodeScannerSetupCompleteView { | ||
| enum Localization { | ||
| //TODO: WOOMOB-792 | ||
| static let title = "Scanner set up!" | ||
| static let instruction = "You are ready to start scanning products. \n" + | ||
| "Read more about barcode and QR code scanner support." | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Button Customizations | ||
| @available(iOS 17.0, *) | ||
| struct PointOfSaleBarcodeScannerWelcomeButtonCustomization: PointOfSaleBarcodeScannerButtonCustomization { | ||
| func customizeButtons(for flow: PointOfSaleBarcodeScannerSetupFlow) -> PointOfSaleFlowButtonConfiguration { | ||
| return PointOfSaleFlowButtonConfiguration( | ||
| primaryButton: PointOfSaleFlowButtonConfiguration.ButtonConfig( | ||
| title: Localization.doneButtonTitle, | ||
| action: { flow.nextStep() } | ||
| ), | ||
| secondaryButton: nil | ||
| ) | ||
| } | ||
|
|
||
| private enum Localization { | ||
| static let doneButtonTitle = NSLocalizedString( | ||
| "pos.barcodeScannerSetup.done.button.title", | ||
| value: "Done", | ||
| comment: "Title for the done button in barcode scanner setup navigation" | ||
| ) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It's a bit annoying because we want to open General or Bluetooth settings, but this URL opens the app's specific settings. I looked up, there's an option to use
URL(string: "App-Prefs:root=General", but from some comments, it could be rejected, so maybe it's not worth risking.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.
Yep, that was my finding as well