Skip to content

Commit a192370

Browse files
committed
8080 Add cancel button to reader choice screen
1 parent 710acfd commit a192370

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

WooCommerce/Classes/ViewModels/CardPresentPayments/CardPresentModalSelectSearchType.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ final class CardPresentModalSelectSearchType: CardPresentPaymentsModalViewModel
2828

2929
private var bluetoothProximityAction: (() -> Void)
3030

31+
private var cancelAction: (() -> Void)
32+
3133
func didTapPrimaryButton(in viewController: UIViewController?) {
3234
tapOnIphoneAction()
3335
}
@@ -37,16 +39,20 @@ final class CardPresentModalSelectSearchType: CardPresentPaymentsModalViewModel
3739
}
3840

3941
func didTapAuxiliaryButton(in viewController: UIViewController?) {
40-
//no-op
42+
cancelAction()
4143
}
4244

43-
init(tapOnIPhoneAction: @escaping () -> Void, bluetoothAction: @escaping () -> Void) {
45+
init(tapOnIPhoneAction: @escaping () -> Void,
46+
bluetoothAction: @escaping () -> Void,
47+
cancelAction: @escaping () -> Void) {
4448
textMode = .fullInfo
45-
actionsMode = .twoAction
49+
actionsMode = .twoActionAndAuxiliary
4650
primaryButtonTitle = CardReaderDiscoveryMethod.localMobile.name
4751
self.tapOnIphoneAction = tapOnIPhoneAction
4852
secondaryButtonTitle = CardReaderDiscoveryMethod.bluetoothProximity.name
4953
self.bluetoothProximityAction = bluetoothAction
54+
auxiliaryButtonTitle = Localization.cancel
55+
self.cancelAction = cancelAction
5056
}
5157
}
5258

@@ -61,6 +67,10 @@ private extension CardPresentModalSelectSearchType {
6167
"Your iPhone can be used as a card reader, or you can connect to an external reader via bluetooth.",
6268
comment: "The description on the alert shown when connecting a card reader, asking the user to choose a " +
6369
"reader type. Only shown when supported on their device.")
70+
71+
static let cancel = NSLocalizedString(
72+
"Cancel",
73+
comment: "Cancel button title")
6474
}
6575
}
6676

WooCommerce/Classes/ViewRelated/CardPresentPayments/CardPresentPaymentPreflightController.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ final class CardPresentPaymentPreflightController {
113113
guard let self = self else { return }
114114
self.connectionController.searchAndConnect(
115115
onCompletion: self.handleConnectionResult)
116+
},
117+
cancelAction: { [weak self] in
118+
guard let self = self else { return }
119+
self.alertsPresenter.dismiss()
120+
self.handleConnectionResult(.success(.canceled))
116121
}))
117122
}
118123

0 commit comments

Comments
 (0)