Skip to content

Commit 7af11a0

Browse files
committed
move HardwareDestination to concrete view
1 parent 9fdcf36 commit 7af11a0

File tree

2 files changed

+60
-59
lines changed

2 files changed

+60
-59
lines changed

WooCommerce/Classes/POS/Presentation/Settings/PointOfSaleSettingsHardwareDetailView.swift

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct PointOfSaleSettingsHardwareDetailView: View {
1010

1111
var body: some View {
1212
NavigationStack(path: $navigationPath) {
13-
List(PointOfSaleSettingsView.HardwareDestination.allCases) { destination in
13+
List(HardwareDestination.allCases) { destination in
1414
NavigationLink(value: NavigationDestination.hardware(destination)) {
1515
HStack(alignment: .firstTextBaseline) {
1616
Image(systemName: destination.icon)
@@ -145,8 +145,42 @@ struct PointOfSaleSettingsHardwareDetailView: View {
145145
}
146146

147147
extension PointOfSaleSettingsHardwareDetailView {
148+
enum HardwareDestination: Identifiable, CaseIterable {
149+
case cardReaders
150+
case scanners
151+
152+
var id: Self { self }
153+
154+
var title: String {
155+
switch self {
156+
case .cardReaders:
157+
return Localization.hardwareNavigationCardReaderTitle
158+
case .scanners:
159+
return Localization.hardwareNavigationBarcodeTitle
160+
}
161+
}
162+
163+
var subtitle: String {
164+
switch self {
165+
case .cardReaders:
166+
return Localization.hardwareNavigationCardReaderSubtitle
167+
case .scanners:
168+
return Localization.hardwareNavigationBarcodeSubtitle
169+
}
170+
}
171+
172+
var icon: String {
173+
switch self {
174+
case .cardReaders:
175+
return "creditcard"
176+
case .scanners:
177+
return "qrcode.viewfinder"
178+
}
179+
}
180+
}
181+
148182
enum NavigationDestination: Hashable {
149-
case hardware(PointOfSaleSettingsView.HardwareDestination)
183+
case hardware(HardwareDestination)
150184
}
151185

152186
enum ScannerDestination: Identifiable, CaseIterable {
@@ -257,5 +291,29 @@ private extension PointOfSaleSettingsHardwareDetailView {
257291
value: "Learn more about accepting mobile payments",
258292
comment: "Subtitle describing card reader documentation in Point of Sale settings."
259293
)
294+
295+
static let hardwareNavigationBarcodeTitle = NSLocalizedString(
296+
"pointOfSaleSettingsHardwareDetailView.hardwareNavigationBarcodeTitle",
297+
value: "Barcode scanners",
298+
comment: "Navigation title of Barcode scanner settings."
299+
)
300+
301+
static let hardwareNavigationCardReaderTitle = NSLocalizedString(
302+
"pointOfSaleSettingsHardwareDetailView.hardwareNavigationCardReaderTitle",
303+
value: "Card readers",
304+
comment: "Navigation title of Card reader settings."
305+
)
306+
307+
static let hardwareNavigationCardReaderSubtitle = NSLocalizedString(
308+
"pointOfSaleSettingsHardwareDetailView.hardwareNavigationCardReaderSubtitle",
309+
value: "Manage card reader connections",
310+
comment: "Description of Card reader settings for connections."
311+
)
312+
313+
static let hardwareNavigationBarcodeSubtitle = NSLocalizedString(
314+
"pointOfSaleSettingsHardwareDetailView.hardwareNavigationBarcodeSubtitle",
315+
value: "Configure barcode scanner settings",
316+
comment: "Description of Barcode scanner settings configuration."
317+
)
260318
}
261319
}

WooCommerce/Classes/POS/Presentation/Settings/PointOfSaleSettingsView.swift

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -93,39 +93,6 @@ extension PointOfSaleSettingsView {
9393
enum Constants {
9494
static let sidebarWidthFraction: CGFloat = 0.35
9595
}
96-
enum HardwareDestination: Identifiable, CaseIterable {
97-
case cardReaders
98-
case scanners
99-
100-
var id: Self { self }
101-
102-
var title: String {
103-
switch self {
104-
case .cardReaders:
105-
return Localization.hardwareNavigationCardReaderTitle
106-
case .scanners:
107-
return Localization.hardwareNavigationBarcodeTitle
108-
}
109-
}
110-
111-
var subtitle: String {
112-
switch self {
113-
case .cardReaders:
114-
return Localization.hardwareNavigationCardReaderSubtitle
115-
case .scanners:
116-
return Localization.hardwareNavigationBarcodeSubtitle
117-
}
118-
}
119-
120-
var icon: String {
121-
switch self {
122-
case .cardReaders:
123-
return "creditcard"
124-
case .scanners:
125-
return "qrcode.viewfinder"
126-
}
127-
}
128-
}
12996
}
13097

13198
private extension PointOfSaleSettingsView {
@@ -203,30 +170,6 @@ private extension PointOfSaleSettingsView {
203170
value: "Get help and support",
204171
comment: "Description of the Help section in Point of Sale settings."
205172
)
206-
207-
static let hardwareNavigationBarcodeTitle = NSLocalizedString(
208-
"pointOfSaleSettingsView.hardwareNavigationBarcodeTitle",
209-
value: "Barcode scanners",
210-
comment: "Navigation title of Barcode scanner settings."
211-
)
212-
213-
static let hardwareNavigationCardReaderTitle = NSLocalizedString(
214-
"pointOfSaleSettingsView.hardwareNavigationCardReaderTitle",
215-
value: "Card readers",
216-
comment: "Navigation title of Card reader settings."
217-
)
218-
219-
static let hardwareNavigationCardReaderSubtitle = NSLocalizedString(
220-
"pointOfSaleSettingsView.hardwareNavigationCardReaderSubtitle",
221-
value: "Manage card reader connections",
222-
comment: "Description of Card reader settings for connections."
223-
)
224-
225-
static let hardwareNavigationBarcodeSubtitle = NSLocalizedString(
226-
"pointOfSaleSettingsView.hardwareNavigationBarcodeSubtitle",
227-
value: "Configure barcode scanner settings",
228-
comment: "Description of Barcode scanner settings configuration."
229-
)
230173
}
231174
}
232175

0 commit comments

Comments
 (0)