Skip to content

Commit f29c579

Browse files
committed
Show hint when we don’t get a test scan within 10s
1 parent 74eec0b commit f29c579

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupStepViews.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,29 @@ private extension PointOfSaleBarcodeScannerPairingView {
9393
@available(iOS 17.0, *)
9494
struct PointOfSaleBarcodeScannerTestBarcodeView: View {
9595
let scanTester: PointOfSaleBarcodeScannerSetupScanTester
96+
@State private var timerCompleted = false
97+
@State private var timer: Timer?
9698

9799
var body: some View {
98-
PointOfSaleBarcodeScannerBarcodeView(title: Localization.title,
99-
instruction: Localization.instruction,
100+
PointOfSaleBarcodeScannerBarcodeView(title: timerCompleted ? Localization.timeoutTitle : Localization.title,
101+
instruction: timerCompleted ? Localization.timeoutInstruction : Localization.instruction,
100102
barcode: scanTester.barcode)
101103
.barcodeScanning { result in
102104
scanTester.handleScan(result)
103105
}
106+
.onAppear {
107+
startTimer()
108+
}
109+
.onDisappear {
110+
timer?.invalidate()
111+
timer = nil
112+
}
113+
}
114+
115+
private func startTimer() {
116+
timer = Timer.scheduledTimer(withTimeInterval: 10.0, repeats: false) { _ in
117+
timerCompleted = true
118+
}
104119
}
105120
}
106121

@@ -109,6 +124,8 @@ private extension PointOfSaleBarcodeScannerTestBarcodeView {
109124
enum Localization {
110125
static let title = "Test your scanner"
111126
static let instruction = "Scan the barcode to test your scanner"
127+
static let timeoutTitle = "No scan data found yet"
128+
static let timeoutInstruction = "Scan the barcode to test your scanner. If the issue continues, please check Bluetooth settings and try again."
112129
}
113130
}
114131

0 commit comments

Comments
 (0)