Skip to content

Commit e25f141

Browse files
authored
Merge pull request #7687 from woocommerce/issue/7686-fix-card-reader-connection-modal-transitions
[Mobile Payments] Fix card reader connection modal transitions
2 parents 0d0862d + 98a6458 commit e25f141

File tree

9 files changed

+49
-26
lines changed

9 files changed

+49
-26
lines changed

RELEASE-NOTES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
10.4
44
-----
55
- [*] Help center: Added help center web page with FAQs for "Pick a WooCommerce Store" screen. [https://github.com/woocommerce/woocommerce-ios/pull/7641]
6+
- [*] In-Person Payments: Fixed a bug where cancelling a card reader connection would temporarily prevent further connections [https://github.com/woocommerce/woocommerce-ios/pull/7689]
7+
- [*] In-Person Payments: Improvements to the card reader connection flow UI [https://github.com/woocommerce/woocommerce-ios/pull/7687]
68
- [*] Login: Users can now set up the Jetpack connection between a self-hosted site and their WP.com account. [https://github.com/woocommerce/woocommerce-ios/pull/7608]
79

810
10.3

WooCommerce/Classes/ViewModels/Order Details/OrderDetailsPaymentAlerts.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ final class OrderDetailsPaymentAlerts: OrderDetailsPaymentAlertsProtocol {
3838
let controller = modalController
3939
controller.setViewModel(viewModel)
4040
if controller.presentingViewController == nil {
41-
controller.modalPresentationStyle = .custom
42-
controller.transitioningDelegate = AppDelegate.shared.tabBarController
41+
controller.prepareForCardReaderModalFlow()
4342
presentingController?.present(controller, animated: true)
4443
}
4544
}

WooCommerce/Classes/ViewRelated/CardPresentPayments/CardPresentPaymentsModalViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import SafariServices
44

55

66
/// UI containing modals presented in the Card Present Payments flows.
7-
final class CardPresentPaymentsModalViewController: UIViewController {
7+
final class CardPresentPaymentsModalViewController: UIViewController, CardReaderModalFlowViewControllerProtocol {
88
/// The view model providing configuration for this view controller
99
/// and support for user actions
1010
private var viewModel: CardPresentPaymentsModalViewModel
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Foundation
2+
import UIKit
3+
4+
protocol CardReaderModalFlowViewControllerProtocol: UIViewController {
5+
func prepareForCardReaderModalFlow()
6+
}
7+
8+
extension CardReaderModalFlowViewControllerProtocol {
9+
func prepareForCardReaderModalFlow() {
10+
modalPresentationStyle = .overFullScreen
11+
view.backgroundColor = .grayTransparentOverlay
12+
modalTransitionStyle = .coverVertical
13+
}
14+
}
15+
16+
private extension UIColor {
17+
static let grayTransparentOverlay = UIColor.black.withAlphaComponent(0.5)
18+
}

WooCommerce/Classes/ViewRelated/CardPresentPayments/SeveralReadersFoundViewController.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import UIKit
22

3-
final class SeveralReadersFoundViewController: UIViewController, UITableViewDelegate {
3+
final class SeveralReadersFoundViewController: UIViewController, UITableViewDelegate, CardReaderModalFlowViewControllerProtocol {
44

55
@IBOutlet private weak var containerView: UIView!
66

@@ -21,8 +21,6 @@ final class SeveralReadersFoundViewController: UIViewController, UITableViewDele
2121

2222
init() {
2323
super.init(nibName: Self.nibName, bundle: nil)
24-
25-
modalPresentationStyle = .overFullScreen
2624
}
2725

2826
required init?(coder: NSCoder) {
@@ -198,15 +196,11 @@ private extension SeveralReadersFoundViewController {
198196
//
199197
private extension SeveralReadersFoundViewController {
200198
@objc func didTapConnect(readerID: String) {
201-
self.dismiss(animated: true, completion: {
202-
self.onConnect?(readerID)
203-
})
199+
self.onConnect?(readerID)
204200
}
205201

206202
@objc func didTapCancel() {
207-
self.dismiss(animated: true, completion: {
208-
self.onCancel?()
209-
})
203+
self.onCancel?()
210204
}
211205
}
212206

WooCommerce/Classes/ViewRelated/CardPresentPayments/SeveralReadersFoundViewController.xib

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
67
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
78
<capability name="System colors in document resources" minToolsVersion="11.0"/>
89
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -67,7 +68,7 @@
6768
</view>
6869
</subviews>
6970
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
70-
<color key="backgroundColor" white="0.0" alpha="0.31993310629916027" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
71+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
7172
<constraints>
7273
<constraint firstItem="4pu-PC-ZQF" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="125" id="MG9-a3-uaq"/>
7374
<constraint firstItem="4pu-PC-ZQF" firstAttribute="trailing" secondItem="vUN-kp-3ea" secondAttribute="trailing" constant="-48" id="NkI-eF-pdT"/>

WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsAlerts.swift

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,15 @@ final class CardReaderSettingsAlerts: CardReaderSettingsAlertsProvider {
7979
connect: @escaping (String) -> Void,
8080
cancelSearch: @escaping () -> Void) {
8181
severalFoundController = SeveralReadersFoundViewController()
82-
severalFoundController?.configureController(
83-
readerIDs: readerIDs,
84-
connect: connect,
85-
cancelSearch: cancelSearch
86-
)
82+
83+
if let severalFoundController = severalFoundController {
84+
severalFoundController.configureController(
85+
readerIDs: readerIDs,
86+
connect: connect,
87+
cancelSearch: cancelSearch
88+
)
89+
severalFoundController.prepareForCardReaderModalFlow()
90+
}
8791

8892
dismissCommonAndPresent(animated: false, from: from, present: severalFoundController)
8993
}
@@ -121,7 +125,8 @@ private extension CardReaderSettingsAlerts {
121125
/// Dismiss any common modal
122126
///
123127
guard modalController == nil else {
124-
modalController?.dismiss(animated: false, completion: { [weak self] in
128+
let shouldAnimateDismissal = animated && present == nil
129+
modalController?.dismiss(animated: shouldAnimateDismissal, completion: { [weak self] in
125130
self?.modalController = nil
126131
guard let from = from, let present = present else {
127132
return
@@ -144,7 +149,8 @@ private extension CardReaderSettingsAlerts {
144149
///
145150
func dismissSeveralFoundAndPresent(animated: Bool = true, from: UIViewController? = nil, present: CardPresentPaymentsModalViewController? = nil) {
146151
guard severalFoundController == nil else {
147-
severalFoundController?.dismiss(animated: false, completion: { [weak self] in
152+
let shouldAnimateDismissal = animated && present == nil
153+
severalFoundController?.dismiss(animated: shouldAnimateDismissal, completion: { [weak self] in
148154
self?.severalFoundController = nil
149155
guard let from = from, let present = present else {
150156
return
@@ -229,9 +235,8 @@ private extension CardReaderSettingsAlerts {
229235
return
230236
}
231237

232-
modalController.modalPresentationStyle = .custom
233-
modalController.transitioningDelegate = AppDelegate.shared.tabBarController
238+
modalController.prepareForCardReaderModalFlow()
234239

235-
dismissSeveralFoundAndPresent(animated: false, from: from, present: modalController)
240+
dismissSeveralFoundAndPresent(animated: true, from: from, present: modalController)
236241
}
237242
}

WooCommerce/Classes/ViewRelated/MainTabBarController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ extension MainTabBarController: UIViewControllerTransitioningDelegate {
212212
func presentationController(forPresented presented: UIViewController,
213213
presenting: UIViewController?,
214214
source: UIViewController) -> UIPresentationController? {
215-
guard presented is FancyAlertViewController || presented is CardPresentPaymentsModalViewController else {
215+
guard presented is FancyAlertViewController else {
216216
return nil
217217
}
218218

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@
447447
0379C51727BFCE9800A7E284 /* WCPayCardBrand+icons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0379C51627BFCE9800A7E284 /* WCPayCardBrand+icons.swift */; };
448448
0379C51927BFE23400A7E284 /* RefundConfirmationCardDetailsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0379C51827BFE23400A7E284 /* RefundConfirmationCardDetailsCell.xib */; };
449449
0379C51B27BFE23F00A7E284 /* RefundConfirmationCardDetailsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0379C51A27BFE23F00A7E284 /* RefundConfirmationCardDetailsCell.swift */; };
450+
037D270D28CA444F00A3F924 /* CardReaderModalFlowViewControllerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 037D270C28CA444F00A3F924 /* CardReaderModalFlowViewControllerProtocol.swift */; };
450451
0386CFEB2852108B00134466 /* PaymentMethodsHostingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0386CFEA2852108B00134466 /* PaymentMethodsHostingController.swift */; };
451452
039D948D27610C6F0044EF38 /* UIView+SafeAreaConstraints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 039D948C27610C6F0044EF38 /* UIView+SafeAreaConstraints.swift */; };
452453
039D948F276113490044EF38 /* UIView+SuperviewConstraints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 039D948E276113490044EF38 /* UIView+SuperviewConstraints.swift */; };
@@ -2356,6 +2357,7 @@
23562357
0379C51627BFCE9800A7E284 /* WCPayCardBrand+icons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WCPayCardBrand+icons.swift"; sourceTree = "<group>"; };
23572358
0379C51827BFE23400A7E284 /* RefundConfirmationCardDetailsCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = RefundConfirmationCardDetailsCell.xib; sourceTree = "<group>"; };
23582359
0379C51A27BFE23F00A7E284 /* RefundConfirmationCardDetailsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefundConfirmationCardDetailsCell.swift; sourceTree = "<group>"; };
2360+
037D270C28CA444F00A3F924 /* CardReaderModalFlowViewControllerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardReaderModalFlowViewControllerProtocol.swift; sourceTree = "<group>"; };
23592361
0386CFEA2852108B00134466 /* PaymentMethodsHostingController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentMethodsHostingController.swift; sourceTree = "<group>"; };
23602362
039D948C27610C6F0044EF38 /* UIView+SafeAreaConstraints.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+SafeAreaConstraints.swift"; sourceTree = "<group>"; };
23612363
039D948E276113490044EF38 /* UIView+SuperviewConstraints.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+SuperviewConstraints.swift"; sourceTree = "<group>"; };
@@ -8110,6 +8112,7 @@
81108112
isa = PBXGroup;
81118113
children = (
81128114
D8815ADD26383EE600EDAD62 /* CardPresentPaymentsModalViewController.swift */,
8115+
037D270C28CA444F00A3F924 /* CardReaderModalFlowViewControllerProtocol.swift */,
81138116
D8815ADE26383EE700EDAD62 /* CardPresentPaymentsModalViewController.xib */,
81148117
31E6F21E26B3577800227E6F /* CardReaderConnectionController.swift */,
81158118
D8EE9690264D328A0033B2F9 /* ReceiptViewController.swift */,
@@ -10319,6 +10322,7 @@
1031910322
748AD087219F481B00023535 /* UIView+Animation.swift in Sources */,
1032010323
02564A8A246CDF6100D6DB2A /* ProductsTopBannerFactory.swift in Sources */,
1032110324
D89C004725B467C7000E4683 /* ULAccountMismatchViewModel.swift in Sources */,
10325+
037D270D28CA444F00A3F924 /* CardReaderModalFlowViewControllerProtocol.swift in Sources */,
1032210326
AEA3F90D27BE76B300B9F555 /* ShippingLineDetails.swift in Sources */,
1032310327
B509FED321C05121000076A9 /* SupportManagerAdapter.swift in Sources */,
1032410328
B5AA7B3D20ED5D15004DA14F /* SessionManager.swift in Sources */,

0 commit comments

Comments
 (0)