-
Notifications
You must be signed in to change notification settings - Fork 121
[Mobile Payments] Specific alert provider for built-in reader connections #8299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
joshheald
merged 2 commits into
trunk
from
issue/8082-add-specific-alertprovider-for-built-in-reader-connections
Dec 5, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ce/Classes/ViewModels/CardPresentPayments/CardPresentModalBuiltInConnectingToReader.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import UIKit | ||
|
|
||
| /// Modal presented when we are connecting to a reader | ||
| /// | ||
| final class CardPresentModalBuiltInConnectingToReader: CardPresentPaymentsModalViewModel { | ||
| let textMode: PaymentsModalTextMode = .reducedBottomInfo | ||
| let actionsMode: PaymentsModalActionsMode = .none | ||
|
|
||
| let topTitle: String = Localization.title | ||
|
|
||
| var topSubtitle: String? | ||
|
|
||
| let image: UIImage = .tempBuiltInReaderCheck | ||
|
|
||
| let primaryButtonTitle: String? = nil | ||
|
|
||
| let secondaryButtonTitle: String? = nil | ||
|
|
||
| let auxiliaryButtonTitle: String? = nil | ||
|
|
||
| let bottomTitle: String? = Localization.instruction | ||
|
|
||
| var bottomSubtitle: String? | ||
|
|
||
| var accessibilityLabel: String? { | ||
| return topTitle + Localization.instruction | ||
| } | ||
|
|
||
| init() {} | ||
|
|
||
| func didTapPrimaryButton(in viewController: UIViewController?) {} | ||
|
|
||
| func didTapSecondaryButton(in viewController: UIViewController?) {} | ||
|
|
||
| func didTapAuxiliaryButton(in viewController: UIViewController?) {} | ||
| } | ||
|
|
||
| private extension CardPresentModalBuiltInConnectingToReader { | ||
| enum Localization { | ||
| static let title = NSLocalizedString( | ||
| "Preparing iPhone card reader...", | ||
| comment: "Title label for modal dialog that appears when connecting to a built in card reader" | ||
| ) | ||
|
|
||
| static let instruction = NSLocalizedString( | ||
| "The first time you connect, you may be prompted to accept Apple's Terms of Service.", | ||
| comment: "Label within the modal dialog that appears when connecting to a built in card reader" | ||
| ) | ||
| } | ||
| } | ||
122 changes: 122 additions & 0 deletions
122
...s/ViewModels/CardPresentPayments/CardPresentModalBuiltInReaderCheckingDeviceSupport.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| import UIKit | ||
|
|
||
| /// Modal presented when we are scanning for a reader to connect to | ||
| /// | ||
| final class CardPresentModalBuiltInReaderCheckingDeviceSupport: CardPresentPaymentsModalViewModel { | ||
| /// Called when cancel button is tapped | ||
| private let cancelAction: () -> Void | ||
|
|
||
| let textMode: PaymentsModalTextMode = .reducedBottomInfo | ||
| let actionsMode: PaymentsModalActionsMode = .secondaryActionAndAuxiliaryButton | ||
|
|
||
| let topTitle: String = Localization.title | ||
|
|
||
| var topSubtitle: String? | ||
|
|
||
| let image: UIImage = .tempBuiltInReaderPrepare | ||
|
|
||
| let primaryButtonTitle: String? = nil | ||
|
|
||
| let secondaryButtonTitle: String? = Localization.cancel | ||
|
|
||
| let auxiliaryButtonTitle: String? = nil | ||
|
|
||
| let auxiliaryButtonimage: UIImage? = .infoOutlineImage | ||
|
|
||
| var auxiliaryAttributedButtonTitle: NSAttributedString? { | ||
| let result = NSMutableAttributedString( | ||
| string: .localizedStringWithFormat( | ||
| Localization.learnMoreText, | ||
| Localization.learnMoreLink | ||
| ), | ||
| attributes: [.foregroundColor: UIColor.text] | ||
| ) | ||
| result.replaceFirstOccurrence( | ||
| of: Localization.learnMoreLink, | ||
| with: NSAttributedString( | ||
| string: Localization.learnMoreLink, | ||
| attributes: [ | ||
| .foregroundColor: UIColor.accent, | ||
| .underlineStyle: NSUnderlineStyle.single.rawValue | ||
| ] | ||
| )) | ||
| result.addAttribute(.font, value: UIFont.footnote, range: NSRange(location: 0, length: result.length)) | ||
| return result | ||
| } | ||
|
|
||
| let bottomTitle: String? = Localization.instruction | ||
|
|
||
| var bottomSubtitle: String? | ||
|
|
||
| var accessibilityLabel: String? { | ||
| guard let bottomTitle = bottomTitle else { | ||
| return topTitle | ||
| } | ||
| return topTitle + bottomTitle | ||
| } | ||
|
|
||
| init(cancel: @escaping () -> Void) { | ||
| self.cancelAction = cancel | ||
| } | ||
|
|
||
| func didTapPrimaryButton(in viewController: UIViewController?) {} | ||
|
|
||
| func didTapSecondaryButton(in viewController: UIViewController?) { | ||
| cancelAction() | ||
| } | ||
|
|
||
| func didTapAuxiliaryButton(in viewController: UIViewController?) { | ||
| ServiceLocator.analytics.track(.cardPresentOnboardingLearnMoreTapped) | ||
| guard let viewController = viewController else { | ||
| return | ||
| } | ||
| WebviewHelper.launch(Constants.learnMoreURL.asURL(), with: viewController) | ||
| } | ||
| } | ||
|
|
||
| private extension CardPresentModalBuiltInReaderCheckingDeviceSupport { | ||
| enum Constants { | ||
| static let learnMoreURL = WooConstants.URLs.inPersonPaymentsLearnMoreWCPay | ||
| } | ||
|
|
||
| enum Localization { | ||
| static let title = NSLocalizedString( | ||
| "cardPresent.builtIn.modalCheckingDeviceSupport.title", | ||
| value: "Checking device", | ||
| comment: "Title label for modal dialog that appears when searching for a card reader" | ||
| ) | ||
|
|
||
| static let instruction = NSLocalizedString( | ||
| "cardPresent.builtIn.modalCheckingDeviceSupport.instruction", | ||
| value: "Please wait while we check that your device is ready for Tap to Pay on iPhone.", | ||
| comment: "Label within the modal dialog that appears when checking the built in card reader" | ||
| ) | ||
|
|
||
| static let cancel = NSLocalizedString( | ||
| "cardPresent.builtIn.modalCheckingDeviceSupport.cancelButton", | ||
| value: "Cancel", | ||
| comment: "Label for a cancel button" | ||
| ) | ||
|
|
||
| static let learnMoreLink = NSLocalizedString( | ||
| "cardPresent.builtIn.modalCheckingDeviceSupport.learnMore.link", | ||
| value: "Learn more", | ||
| comment: """ | ||
| A label prompting users to learn more about In-Person Payments. | ||
| This is the link to the website, and forms part of a longer sentence which it should be considered a part of. | ||
| """ | ||
| ) | ||
|
|
||
| static let learnMoreText = NSLocalizedString( | ||
| "cardPresent.builtIn.modalCheckingDeviceSupport.learnMore.text", | ||
| value: "%1$@ about In‑Person Payments", | ||
| comment: """ | ||
| A label prompting users to learn more about In-Person Payments. | ||
| The hyphen in "In‑Person" is a non-breaking hyphen (U+2011). | ||
| If your translation of that term also happens to contains a hyphen, please be sure to use the non-breaking hyphen character for it. | ||
| %1$@ is a placeholder that always replaced with \"Learn more\" string, | ||
| which should be translated separately and considered part of this sentence. | ||
| """ | ||
| ) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A non-blocker suggestion here, I would make these namings easier to understand, perhaps
CardPresentBuiltInConnectingToReaderModalViewModelandCardPresentBuiltInReaderCheckingDeviceSupportModalViewModel? I see they are long, so I leave it to your discernment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I'll put a note on the issue to update these when we have finalised strings and images for the screens: there's not really a lot of clarity over what the SDK is actually doing at each point, so naming them based on the message is probably the clearest approach.