Skip to content

Commit 06b31b8

Browse files
authored
Merge pull request #8738 from woocommerce/issue/8397-ipp-learn-more-link-payment-methods
Issue/8397 ipp learn more link payment methods
2 parents e7e1677 + afd42ec commit 06b31b8

File tree

3 files changed

+30
-35
lines changed

3 files changed

+30
-35
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsMenuViewController.swift

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ final class InPersonPaymentsMenuViewController: UIViewController {
2020
countryCode: viewModel.cardPresentPaymentsConfiguration.countryCode))
2121
}()
2222

23+
private lazy var inPersonPaymentsLearnMoreViewModel = LearnMoreViewModel.inPersonPayments()
24+
2325
private let viewModel: InPersonPaymentsMenuViewModel = InPersonPaymentsMenuViewModel()
2426

2527
private let cashOnDeliveryToggleRowViewModel: InPersonPaymentsCashOnDeliveryToggleRowViewModel
@@ -41,30 +43,10 @@ final class InPersonPaymentsMenuViewController: UIViewController {
4143

4244
private var activityIndicator: UIActivityIndicatorView?
4345

44-
private var inPersonPaymentsLearnMoreButtonTitle: NSAttributedString? {
45-
let result = NSMutableAttributedString(
46-
string: .localizedStringWithFormat(
47-
Localization.learnMoreText,
48-
Localization.learnMoreLink
49-
),
50-
attributes: [.foregroundColor: UIColor.textSubtle]
51-
)
52-
result.replaceFirstOccurrence(
53-
of: Localization.learnMoreLink,
54-
with: NSAttributedString(
55-
string: Localization.learnMoreLink,
56-
attributes: [
57-
.foregroundColor: UIColor.textLink
58-
]
59-
))
60-
result.addAttribute(.font, value: UIFont.footnote, range: NSRange(location: 0, length: result.length))
61-
return result
62-
}
63-
6446
private var inPersonPaymentsLearnMoreButton: UIButton {
6547
let button = UIButton()
6648
button.addTarget(self, action: #selector(learnMoreAboutInPersonPaymentsButtonWasTapped), for: .touchUpInside)
67-
button.setAttributedTitle(inPersonPaymentsLearnMoreButtonTitle, for: .normal)
49+
button.setAttributedTitle(inPersonPaymentsLearnMoreViewModel.learnMoreAttributedString, for: .normal)
6850
button.naturalContentHorizontalAlignment = .leading
6951
button.configuration = UIButton.Configuration.plain()
7052

@@ -424,7 +406,7 @@ extension InPersonPaymentsMenuViewController {
424406
}
425407

426408
@objc func learnMoreAboutInPersonPaymentsButtonWasTapped() {
427-
WebviewHelper.launch(WooConstants.URLs.inPersonPaymentsLearnMoreWCPay.asURL(), with: self)
409+
WebviewHelper.launch(inPersonPaymentsLearnMoreViewModel.url, with: self)
428410
}
429411

430412
}
@@ -568,19 +550,6 @@ private extension InPersonPaymentsMenuViewController {
568550
This is the link to the website, and forms part of a longer sentence which it should be considered a part of.
569551
"""
570552
)
571-
572-
static let learnMoreText = NSLocalizedString(
573-
"cardPresent.modalScanningForReader.learnMore.text",
574-
value: "%1$@ about In‑Person Payments",
575-
comment: """
576-
A label prompting users to learn more about In-Person Payments.
577-
The hyphen in "In‑Person" is a non-breaking hyphen (U+2011).
578-
If your translation of that term also happens to contains a hyphen, please be sure to use the non-breaking hyphen character for it.
579-
%1$@ is a placeholder that always replaced with \"Learn more\" string,
580-
which should be translated separately and considered part of this sentence.
581-
"""
582-
)
583-
584553
}
585554
}
586555

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/LearnMoreViewModel.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,24 @@ private enum Localization {
6363
which should be translated separately and considered part of this sentence.
6464
"""
6565
)
66+
67+
static let inPersonPaymentslearnMoreText = NSLocalizedString(
68+
"cardPresent.modalScanningForReader.learnMore.text",
69+
value: "%1$@ about In‑Person Payments",
70+
comment: """
71+
A label prompting users to learn more about In-Person Payments.
72+
The hyphen in "In‑Person" is a non-breaking hyphen (U+2011).
73+
If your translation of that term also happens to contains a hyphen, please be sure to use the non-breaking hyphen character for it.
74+
%1$@ is a placeholder that always replaced with \"Learn more\" string,
75+
which should be translated separately and considered part of this sentence.
76+
"""
77+
)
78+
}
79+
80+
extension LearnMoreViewModel {
81+
static func inPersonPayments() -> LearnMoreViewModel {
82+
LearnMoreViewModel(url: WooConstants.URLs.inPersonPaymentsLearnMoreWCPay.asURL(),
83+
linkText: Localization.learnMoreLink,
84+
formatText: Localization.inPersonPaymentslearnMoreText)
85+
}
6686
}

WooCommerce/Classes/ViewRelated/Orders/Payment Methods/PaymentMethodsView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ struct PaymentMethodsView: View {
2323

2424
@State private var showingPurchaseCardReaderView = false
2525

26+
private let learnMoreViewModel = LearnMoreViewModel.inPersonPayments()
27+
2628
/// Environment safe areas
2729
///
2830
@Environment(\.safeAreaInsets) var safeAreaInsets: EdgeInsets
@@ -87,6 +89,10 @@ struct PaymentMethodsView: View {
8789
.padding(.horizontal, insets: safeAreaInsets)
8890
.background(Color(.listForeground(modal: false)))
8991
}
92+
93+
NavigationLink(destination: WebView(isPresented: .constant(true), url: learnMoreViewModel.url)) {
94+
AttributedText(learnMoreViewModel.learnMoreAttributedString)
95+
}.padding(.horizontal)
9096
}
9197

9298
// Pushes content to the top

0 commit comments

Comments
 (0)