Skip to content

Commit e68c580

Browse files
authored
[Woo POS][Barcodes] Separate barcode and scanner info screens (#15905)
2 parents 4d633d1 + a71501d commit e68c580

File tree

9 files changed

+236
-171
lines changed

9 files changed

+236
-171
lines changed

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

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ struct PointOfSaleBarcodeScannerSetup: View {
1212

1313
var body: some View {
1414
VStack(spacing: POSSpacing.xxLarge) {
15-
// Header
16-
PointOfSaleModalHeader(isPresented: $isPresented,
17-
title: .constant(AttributedString(currentTitle)))
18-
1915
VStack {
2016
currentContent
2117
.frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -24,8 +20,13 @@ struct PointOfSaleBarcodeScannerSetup: View {
2420
.scrollVerticallyIfNeeded()
2521

2622
// Bottom buttons
27-
PointOfSaleFlowButtonsView(configuration: flowManager.buttonConfiguration)
23+
if flowManager.buttonConfiguration.primaryButton != nil || flowManager.buttonConfiguration.secondaryButton != nil {
24+
PointOfSaleFlowButtonsView(configuration: flowManager.buttonConfiguration)
25+
}
2826
}
27+
.posModalCloseButton(action: {
28+
isPresented = false
29+
})
2930
.padding(POSPadding.xxLarge)
3031
.background(Color.posSurfaceBright)
3132
.containerRelativeFrame([.horizontal, .vertical]) { length, _ in
@@ -37,15 +38,6 @@ struct PointOfSaleBarcodeScannerSetup: View {
3738
}
3839

3940
// MARK: - Computed Properties
40-
private var currentTitle: String {
41-
switch flowManager.currentState {
42-
case .scannerSelection:
43-
return Localization.setupHeading
44-
case .setupFlow:
45-
return flowManager.getCurrentStep()?.title ?? Localization.setupHeading
46-
}
47-
}
48-
4941
@ViewBuilder
5042
private var currentContent: some View {
5143
switch flowManager.currentState {
@@ -64,22 +56,18 @@ struct PointOfSaleBarcodeScannerSetup: View {
6456
[
6557
PointOfSaleBarcodeScannerSetupFlowOption(
6658
title: Localization.socketS720Title,
67-
subtitle: Localization.socketS720Subtitle,
6859
scannerType: .socketS720
6960
),
7061
PointOfSaleBarcodeScannerSetupFlowOption(
7162
title: Localization.starBSH20BTitle,
72-
subtitle: Localization.starBSH20BSubtitle,
7363
scannerType: .starBSH20B
7464
),
7565
PointOfSaleBarcodeScannerSetupFlowOption(
7666
title: Localization.tbcScannerTitle,
77-
subtitle: Localization.tbcScannerSubtitle,
7867
scannerType: .tbcScanner
7968
),
8069
PointOfSaleBarcodeScannerSetupFlowOption(
8170
title: Localization.otherTitle,
82-
subtitle: Localization.otherSubtitle,
8371
scannerType: .other
8472
)
8573
]
@@ -88,59 +76,33 @@ struct PointOfSaleBarcodeScannerSetup: View {
8876

8977
// MARK: - Constants
9078
private enum Constants {
91-
static var modalFrameMaxSmallDimension: CGFloat { 752 }
79+
static var modalFrameMaxSmallDimension: CGFloat { 616 }
9280
}
9381

9482
// MARK: - Private Localization Extension
9583
@available(iOS 17.0, *)
9684
private extension PointOfSaleBarcodeScannerSetup {
9785
enum Localization {
98-
static let setupHeading = NSLocalizedString(
99-
"pos.barcodeScannerSetup.heading",
100-
value: "Barcode Scanner Setup",
101-
comment: "Heading for the barcode scanner setup flow in POS"
102-
)
103-
10486
static let socketS720Title = NSLocalizedString(
10587
"pos.barcodeScannerSetup.socketS720.title",
10688
value: "Socket S720",
10789
comment: "Title for Socket S720 scanner option in barcode scanner setup"
10890
)
109-
static let socketS720Subtitle = NSLocalizedString(
110-
"pos.barcodeScannerSetup.socketS720.subtitle",
111-
value: "Small handheld scanner with a charging dock or stand",
112-
comment: "Subtitle for Socket S720 scanner option in barcode scanner setup"
113-
)
11491
static let starBSH20BTitle = NSLocalizedString(
11592
"pos.barcodeScannerSetup.starBSH20B.title",
11693
value: "Star BSH-20B",
11794
comment: "Title for Star BSH-20B scanner option in barcode scanner setup"
11895
)
119-
static let starBSH20BSubtitle = NSLocalizedString(
120-
"pos.barcodeScannerSetup.starBSH20B.subtitle",
121-
value: "Ergonomic scanner with a stand",
122-
comment: "Subtitle for Star BSH-20B scanner option in barcode scanner setup"
123-
)
12496
static let tbcScannerTitle = NSLocalizedString(
12597
"pos.barcodeScannerSetup.tbcScanner.title",
12698
value: "Scanner TBC",
12799
comment: "Title for TBC scanner option in barcode scanner setup"
128100
)
129-
static let tbcScannerSubtitle = NSLocalizedString(
130-
"pos.barcodeScannerSetup.tbcScanner.subtitle",
131-
value: "Recommended scanner",
132-
comment: "Subtitle for TBC scanner option in barcode scanner setup"
133-
)
134101
static let otherTitle = NSLocalizedString(
135102
"pos.barcodeScannerSetup.other.title",
136103
value: "Other",
137104
comment: "Title for other scanner option in barcode scanner setup"
138105
)
139-
static let otherSubtitle = NSLocalizedString(
140-
"pos.barcodeScannerSetup.other.subtitle",
141-
value: "General scanner setup instructions",
142-
comment: "Subtitle for other scanner option in barcode scanner setup"
143-
)
144106
}
145107
}
146108

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

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ class PointOfSaleBarcodeScannerSetupFlow {
148148
content: {
149149
PointOfSaleBarcodeScannerSetupCompleteView()
150150
},
151+
buttonCustomization: PointOfSaleBarcodeScannerOptionalScannerInformationButtonCustomization(),
151152
transitions: [
152-
.back: .test
153+
.next: .information,
153154
]),
154155
.testFailed: PointOfSaleBarcodeScannerSetupStep(
155156
content: {
@@ -160,8 +161,11 @@ class PointOfSaleBarcodeScannerSetupFlow {
160161
.retry: .start,
161162
.back: .test
162163
]
164+
),
165+
.information: PointOfSaleBarcodeScannerSetupStep(
166+
content: { ProductBarcodeSetupInformation() },
167+
buttonCustomization: PointOfSaleBarcodeScannerNoButtonsButtonCustomization()
163168
)
164-
// TODO: Add optional error step and documentation step for Star BSH-20B WOOMOB-696
165169
]
166170
case .tbcScanner:
167171
return [
@@ -171,8 +175,13 @@ class PointOfSaleBarcodeScannerSetupFlow {
171175
case .other:
172176
return [
173177
.start: PointOfSaleBarcodeScannerSetupStep(
174-
title: "General Scanner Setup",
175-
content: { BarcodeScannerInformationContent() }
178+
content: { BarcodeScannerInformation() },
179+
transitions: [.next: .information]
180+
),
181+
.information: PointOfSaleBarcodeScannerSetupStep(
182+
content: { ProductBarcodeSetupInformation() },
183+
buttonCustomization: PointOfSaleBarcodeScannerBackOnlyButtonCustomization(),
184+
transitions: [.back: .start]
176185
)
177186
]
178187
}
@@ -237,6 +246,31 @@ struct PointOfSaleBarcodeScannerErrorButtonCustomization: PointOfSaleBarcodeScan
237246
}
238247
}
239248

249+
@available(iOS 17.0, *)
250+
struct PointOfSaleBarcodeScannerOptionalScannerInformationButtonCustomization: PointOfSaleBarcodeScannerButtonCustomization {
251+
func customizeButtons(for flow: PointOfSaleBarcodeScannerSetupFlow) -> PointOfSaleFlowButtonConfiguration {
252+
return PointOfSaleFlowButtonConfiguration(
253+
primaryButton: nil,
254+
secondaryButton: PointOfSaleFlowButtonConfiguration.ButtonConfig(
255+
title: Localization.informationButtonTitle,
256+
action: { flow.transition(to: .next) }
257+
)
258+
)
259+
}
260+
261+
private enum Localization {
262+
static let informationButtonTitle = "How to set up barcodes on products"
263+
}
264+
}
265+
266+
@available(iOS 17.0, *)
267+
struct PointOfSaleBarcodeScannerNoButtonsButtonCustomization: PointOfSaleBarcodeScannerButtonCustomization {
268+
func customizeButtons(for flow: PointOfSaleBarcodeScannerSetupFlow) -> PointOfSaleFlowButtonConfiguration {
269+
return PointOfSaleFlowButtonConfiguration.noButtons()
270+
}
271+
}
272+
273+
240274
// MARK: - Private Localization Extension
241275
@available(iOS 17.0, *)
242276
private extension PointOfSaleBarcodeScannerSetupFlow {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import SwiftUI
44
struct PointOfSaleBarcodeScannerSetupFlowOption: Identifiable {
55
let id = UUID()
66
let title: String
7-
let subtitle: String
87
let scannerType: PointOfSaleBarcodeScannerType
98
}
109

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,19 @@ struct PointOfSaleBarcodeScannerBarcodeView: View {
3838
}
3939

4040
Image(barcode.imageName)
41+
.resizable()
42+
.aspectRatio(contentMode: .fit)
43+
.frame(maxHeight: Constants.maxBarcodeSize)
4144
}
4245
}
4346
}
4447

48+
extension PointOfSaleBarcodeScannerBarcodeView {
49+
enum Constants {
50+
static let maxBarcodeSize: CGFloat = 168
51+
}
52+
}
53+
4554
struct PointOfSaleBarcodeScannerPairingView: View {
4655
let scanner: PointOfSaleBarcodeScannerType
4756

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

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,63 +6,40 @@ struct PointOfSaleBarcodeScannerSetupSelectionView: View {
66
let onSelection: (PointOfSaleBarcodeScannerType) -> Void
77

88
var body: some View {
9-
VStack(alignment: .leading, spacing: POSSpacing.medium) {
10-
Text(Localization.setupIntroMessage)
11-
.font(.posBodyLargeRegular())
12-
.foregroundStyle(Color.posOnSurface)
13-
.multilineTextAlignment(.leading)
14-
.fixedSize(horizontal: false, vertical: true)
15-
9+
VStack(spacing: POSSpacing.large) {
1610
VStack(spacing: POSSpacing.small) {
11+
Text(Localization.setupHeading)
12+
.accessibilityAddTraits(.isHeader)
13+
.font(.posHeadingBold)
14+
Text(Localization.setupIntroMessage)
15+
.font(.posBodyLargeRegular())
16+
}
17+
.foregroundStyle(Color.posOnSurface)
18+
.multilineTextAlignment(.leading)
19+
.fixedSize(horizontal: false, vertical: true)
20+
21+
VStack(spacing: POSSpacing.medium) {
1722
ForEach(options) { option in
1823
Button {
1924
onSelection(option.scannerType)
2025
} label: {
21-
PointOfSaleBarcodeScannerOptionView(
22-
title: option.title,
23-
subtitle: option.subtitle
24-
)
26+
Text(option.title)
2527
}
26-
.buttonStyle(PlainButtonStyle())
28+
.buttonStyle(POSOutlinedButtonStyle(size: .normal))
2729
}
2830
}
2931
}
3032
}
3133
}
3234

33-
// MARK: - Scanner Option View
34-
struct PointOfSaleBarcodeScannerOptionView: View {
35-
let title: String
36-
let subtitle: String
37-
38-
var body: some View {
39-
HStack {
40-
VStack(alignment: .leading, spacing: POSSpacing.xSmall) {
41-
Text(title)
42-
.font(.posBodyLargeBold)
43-
.foregroundColor(.posOnSurface)
44-
Text(subtitle)
45-
.font(.posBodyMediumRegular())
46-
.foregroundColor(.posOnSurfaceVariantHighest)
47-
}
48-
Spacer()
49-
Image(systemName: "chevron.forward")
50-
.font(.posBodyMediumBold)
51-
.foregroundColor(.posOnSurfaceVariantHighest)
52-
}
53-
.padding(POSPadding.medium)
54-
.background(Color.posSurfaceDim)
55-
.clipShape(RoundedRectangle(cornerRadius: POSCornerRadiusStyle.medium.value))
56-
}
57-
}
58-
5935
// MARK: - Private Localization Extensions
6036
private extension PointOfSaleBarcodeScannerSetupSelectionView {
6137
enum Localization {
62-
static let setupIntroMessage = NSLocalizedString(
63-
"pos.barcodeScannerSetup.introMessage",
64-
value: "Choose your barcode scanner to get started with the setup process.",
65-
comment: "Introductory message in the barcode scanner setup flow in POS"
66-
)
38+
//TODO: WOOMOB-792
39+
// Note that "pos.barcodeScannerSetup.introMessage" was previously sent for translation, so don't reuse that.
40+
static let setupIntroMessage = "Select a model from the list:"
41+
42+
// Note that "pos.barcodeScannerSetup.heading" was previously sent to translation – don't reuse
43+
static let setupHeading = "Set up a barcode scanner"
6744
}
6845
}

WooCommerce/Classes/POS/Presentation/PointOfSaleAssets.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ enum PointOfSaleAssets: CaseIterable {
1515
case successCheck
1616
case coupons
1717
case gears
18+
case barcodeFieldScreenshot
1819
//TODO: WOOMOB-793 Update the imagesets for these barcodes to vector/dark mode friendly images
1920
case starBsh20SetupBarcode
2021
case testEan13Barcode
@@ -49,6 +50,8 @@ enum PointOfSaleAssets: CaseIterable {
4950
"coupons"
5051
case .gears:
5152
"pos-gears"
53+
case .barcodeFieldScreenshot:
54+
"barcode-field-screenshot"
5255
case .starBsh20SetupBarcode:
5356
"star-bsh20-setup-barcode"
5457
case .testEan13Barcode:

0 commit comments

Comments
 (0)