Skip to content

Commit 5313d38

Browse files
authored
[POS Settings] Update link to barcode scanner docs (#16069)
2 parents 5df8f98 + 5a94138 commit 5313d38

File tree

7 files changed

+44
-9
lines changed

7 files changed

+44
-9
lines changed

WooCommerce/Classes/POS/Presentation/PointOfSaleBarcodeScannerInformationModal.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct ProductBarcodeSetupInformation: View {
118118
private var productSetupTextWithLink: AttributedString {
119119
let mainContent = Localization.productBarcodeSetupMessage
120120
let linkText = Localization.productBarcodeSetupLinkText
121-
let link = Constants.detailsLink?.absoluteString ?? ""
121+
let link = Constants.detailsLink.absoluteString
122122

123123
let content = String.localizedStringWithFormat(mainContent, linkText)
124124
var attributedText = AttributedString(content)
@@ -136,7 +136,7 @@ struct ProductBarcodeSetupInformation: View {
136136
}
137137

138138
private enum Constants {
139-
static let detailsLink = URL(string: "https://woocommerce.com/document/barcode-and-qr-code-scanner/")
139+
static let detailsLink = POSConstants.URLs.pointOfSaleBarcodeScannerDocumentation.asURL()
140140
}
141141

142142
private enum Localization {

WooCommerce/Classes/POS/Presentation/PointOfSaleDashboardView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private extension PointOfSaleDashboardView {
204204
}
205205

206206
var documentationView: some View {
207-
SafariView(url: WooConstants.URLs.pointOfSaleDocumentation.asURL())
207+
SafariView(url: POSConstants.URLs.pointOfSaleDocumentation.asURL())
208208
}
209209

210210
func paymentsOnboardingView(from onboardingViewModel: CardPresentPaymentsOnboardingViewModel) -> some View {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct PointOfSaleSettingsHardwareDetailView: View {
6767
PointOfSaleBarcodeScannerSetup(isPresented: $showBarcodeScanningSetupModal)
6868
}
6969
.posFullScreenCover(isPresented: $showBarcodeScanningDocumentationModal) {
70-
SafariView(url: WooConstants.URLs.pointOfSaleDocumentation.asURL())
70+
SafariView(url: POSConstants.URLs.pointOfSaleBarcodeScannerDocumentation.asURL())
7171
}
7272
}
7373
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct PointOfSaleSettingsHelpDetailView: View {
8282
.posFullScreenCover(isPresented: $showDocumentation) {
8383
// TODO: Remove copy on PointOfSaleDashboardView.documentationView
8484
// WOOMOB-1168
85-
SafariView(url: WooConstants.URLs.pointOfSaleDocumentation.asURL())
85+
SafariView(url: POSConstants.URLs.pointOfSaleDocumentation.asURL())
8686

8787
}
8888
.posFullScreenCover(isPresented: $showSupport) {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Foundation
2+
3+
enum POSConstants {
4+
enum URLs: String, CaseIterable {
5+
/// Returns the URL version of the receiver
6+
///
7+
func asURL() -> URL {
8+
Self.trustedURL(self.rawValue)
9+
}
10+
11+
/// URL for Point of Sale documentation
12+
///
13+
case pointOfSaleDocumentation = "https://woocommerce.com/document/woo-mobile-app-point-of-sale-mode/"
14+
15+
/// URL for Point of Sale's barcode scanner documentation
16+
///
17+
case pointOfSaleBarcodeScannerDocumentation = "https://woocommerce.com/document/barcode-and-qr-code-scanner/"
18+
}
19+
}
20+
21+
private extension POSConstants.URLs {
22+
/// Convert a `string` to a `URL`. Crash if it is malformed.
23+
///
24+
private static func trustedURL(_ url: String) -> URL {
25+
26+
if let url = URL(string: url) {
27+
return url
28+
} else if let escapedString = url.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed),
29+
let escapedURL = URL(string: escapedString) {
30+
return escapedURL
31+
} else {
32+
fatalError("Expected URL \(url) to be a well-formed URL.")
33+
}
34+
}
35+
}

WooCommerce/Classes/System/WooConstants.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,6 @@ extension WooConstants {
250250
///
251251
case inPersonPaymentsLearnMoreStripe = "https://woocommerce.com/document/stripe/accept-in-person-payments-with-stripe/"
252252

253-
/// URL for Point of Sale documentation
254-
///
255-
case pointOfSaleDocumentation = "https://woocommerce.com/document/woo-mobile-app-point-of-sale-mode/"
256-
257253
/// Temporary redirect URL for authenticated web view when authenticating WPCom automatically
258254
///
259255
case wpcomTempRedirectURL = "https://wordpress.com/mobile-redirect"

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,7 @@
16471647
68DF5A8D2CB38EEA000154C9 /* EditableOrderCouponLineViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68DF5A8C2CB38EEA000154C9 /* EditableOrderCouponLineViewModel.swift */; };
16481648
68DF5A8F2CB38F20000154C9 /* OrderCouponSectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68DF5A8E2CB38F20000154C9 /* OrderCouponSectionView.swift */; };
16491649
68E141DB2D13107400A70D5B /* PointOfSaleCollectCashView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E141DA2D13107200A70D5B /* PointOfSaleCollectCashView.swift */; };
1650+
68E33B2E2E66AAB500CBE921 /* POSConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E33B2D2E66AAAE00CBE921 /* POSConstants.swift */; };
16501651
68E4E8B52C0EF39D00CFA0C3 /* PreviewHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E4E8B42C0EF39D00CFA0C3 /* PreviewHelpers.swift */; };
16511652
68E6749F2A4DA01C0034BA1E /* WooWPComPlan.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E6749E2A4DA01C0034BA1E /* WooWPComPlan.swift */; };
16521653
68E674A12A4DA0B30034BA1E /* InAppPurchasesError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E674A02A4DA0B30034BA1E /* InAppPurchasesError.swift */; };
@@ -4836,6 +4837,7 @@
48364837
68DF5A8C2CB38EEA000154C9 /* EditableOrderCouponLineViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditableOrderCouponLineViewModel.swift; sourceTree = "<group>"; };
48374838
68DF5A8E2CB38F20000154C9 /* OrderCouponSectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCouponSectionView.swift; sourceTree = "<group>"; };
48384839
68E141DA2D13107200A70D5B /* PointOfSaleCollectCashView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointOfSaleCollectCashView.swift; sourceTree = "<group>"; };
4840+
68E33B2D2E66AAAE00CBE921 /* POSConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = POSConstants.swift; sourceTree = "<group>"; };
48394841
68E4E8B42C0EF39D00CFA0C3 /* PreviewHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewHelpers.swift; sourceTree = "<group>"; };
48404842
68E6749E2A4DA01C0034BA1E /* WooWPComPlan.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooWPComPlan.swift; sourceTree = "<group>"; };
48414843
68E674A02A4DA0B30034BA1E /* InAppPurchasesError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppPurchasesError.swift; sourceTree = "<group>"; };
@@ -7182,6 +7184,7 @@
71827184
isa = PBXGroup;
71837185
children = (
71847186
01806E122E2F7F400033363C /* POSBrightnessControl.swift */,
7187+
68E33B2D2E66AAAE00CBE921 /* POSConstants.swift */,
71857188
689F29192DE4557D004DF52B /* POSStockFormatter.swift */,
71867189
681BB5FD2D676060008AF8BB /* POSPadding.swift */,
71877190
681BB5FB2D676043008AF8BB /* POSSpacing.swift */,
@@ -15993,6 +15996,7 @@
1599315996
02C1853D27FF153A00ABD764 /* CardPresentRefundOrchestrator.swift in Sources */,
1599415997
01309A7F2DC4F39E00B77527 /* PointOfSaleCardPresentPaymentCardInsertedMessageViewModel.swift in Sources */,
1599515998
AEC95D432774D07B001571F5 /* CreateOrderAddressFormViewModel.swift in Sources */,
15999+
68E33B2E2E66AAB500CBE921 /* POSConstants.swift in Sources */,
1599616000
024DF31B23742E1C006658FE /* FormatBarItemViewProperties.swift in Sources */,
1599716001
26B119BB24D0B62E00FED5C7 /* SurveyViewController.swift in Sources */,
1599816002
CCD2F51A26D67BB50010E679 /* ShippingLabelServicePackageList.swift in Sources */,

0 commit comments

Comments
 (0)