From cd0157d039f9bb98af17bb38aad9f63b739c32cb Mon Sep 17 00:00:00 2001 From: Virginia Cook Date: Tue, 12 Dec 2023 16:51:45 -0500 Subject: [PATCH] small updates --- .../WalletHeaderView.swift | 6 -- .../Source/PaymentSheet/PaymentSheet.swift | 93 +++++++++---------- .../PaymentSheetViewController.swift | 3 +- 3 files changed, 47 insertions(+), 55 deletions(-) diff --git a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/New Payment Method Screen/WalletHeaderView.swift b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/New Payment Method Screen/WalletHeaderView.swift index d14e4dfaa0d..f44f595fab5 100644 --- a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/New Payment Method Screen/WalletHeaderView.swift +++ b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/New Payment Method Screen/WalletHeaderView.swift @@ -126,12 +126,6 @@ extension PaymentSheetViewController { stackView.axis = .vertical stackView.spacing = Constants.buttonSpacing - if let walletSubview = walletSubview { - stackView.setCustomSpacing(Constants.labelSpacing, after: walletSubview) - } else if let lastButton = buttons.last { - stackView.setCustomSpacing(Constants.labelSpacing, after: lastButton) - } - addAndPinSubview(stackView) } diff --git a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentSheet.swift b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentSheet.swift index 0a1315026d8..0d740594c81 100644 --- a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentSheet.swift +++ b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentSheet.swift @@ -136,58 +136,55 @@ public class PaymentSheet { completion(.failed(error: error)) return } - let seconds = 1.0 - DispatchQueue.main.asyncAfter(deadline: .now() + seconds) { - // Configure the Payment Sheet VC after loading the PI/SI, Customer, etc. - PaymentSheetLoader.load( - mode: self.mode, - configuration: self.configuration - ) { result in - switch result { - case .success(let intent, let savedPaymentMethods, let isLinkEnabled): - // Set the PaymentSheetViewController as the content of our bottom sheet - let isApplePayEnabled = StripeAPI.deviceSupportsApplePay() - && self.configuration.applePay != nil - && intent.isApplePayEnabled - - let presentPaymentSheetVC = { (justVerifiedLinkOTP: Bool) in - let paymentSheetVC = PaymentSheetViewController( + // Configure the Payment Sheet VC after loading the PI/SI, Customer, etc. + PaymentSheetLoader.load( + mode: self.mode, + configuration: self.configuration + ) { result in + switch result { + case .success(let intent, let savedPaymentMethods, let isLinkEnabled): + // Set the PaymentSheetViewController as the content of our bottom sheet + let isApplePayEnabled = StripeAPI.deviceSupportsApplePay() + && self.configuration.applePay != nil + && intent.isApplePayEnabled + + let presentPaymentSheetVC = { (justVerifiedLinkOTP: Bool) in + let paymentSheetVC = PaymentSheetViewController( + intent: intent, + savedPaymentMethods: savedPaymentMethods, + configuration: self.configuration, + isApplePayEnabled: isApplePayEnabled, + isLinkEnabled: isLinkEnabled, + isConfirmed: self.configuration.delegate == nil, + delegate: self + ) + + self.configuration.style.configure(paymentSheetVC) + + let updateBottomSheet: () -> Void = { + self.bottomSheetViewController.contentStack = [paymentSheetVC] + } + + if LinkAccountContext.shared.account?.sessionState == .verified { + self.presentPayWithLinkController( + from: self.bottomSheetViewController, intent: intent, - savedPaymentMethods: savedPaymentMethods, - configuration: self.configuration, - isApplePayEnabled: isApplePayEnabled, - isLinkEnabled: isLinkEnabled, - isConfirmed: self.configuration.delegate == nil, - delegate: self + shouldOfferApplePay: justVerifiedLinkOTP, + shouldFinishOnClose: true, + completion: { + // Update the bottom sheet after presenting the Link controller + // to avoid briefly flashing the PaymentSheet in the middle of + // the View Controller transition. + updateBottomSheet() + } ) - - self.configuration.style.configure(paymentSheetVC) - - let updateBottomSheet: () -> Void = { - self.bottomSheetViewController.contentStack = [paymentSheetVC] - } - - if LinkAccountContext.shared.account?.sessionState == .verified { - self.presentPayWithLinkController( - from: self.bottomSheetViewController, - intent: intent, - shouldOfferApplePay: justVerifiedLinkOTP, - shouldFinishOnClose: true, - completion: { - // Update the bottom sheet after presenting the Link controller - // to avoid briefly flashing the PaymentSheet in the middle of - // the View Controller transition. - updateBottomSheet() - } - ) - } else { - updateBottomSheet() - } + } else { + updateBottomSheet() } - presentPaymentSheetVC(false) - case .failure(let error): - completion(.failed(error: error)) } + presentPaymentSheetVC(false) + case .failure(let error): + completion(.failed(error: error)) } } diff --git a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentSheetViewController.swift b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentSheetViewController.swift index 00bfa3409ad..6d61ac03f87 100644 --- a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentSheetViewController.swift +++ b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentSheetViewController.swift @@ -77,7 +77,6 @@ class PaymentSheetViewController: UIViewController { private lazy var savedPaymentOptionsViewController: SavedPaymentOptionsViewController = { let showApplePay = !shouldShowWalletHeader && isApplePayEnabled let showLink = !shouldShowWalletHeader && isLinkEnabled - return SavedPaymentOptionsViewController( savedPaymentMethods: savedPaymentMethods, configuration: .init( @@ -214,9 +213,11 @@ class PaymentSheetViewController: UIViewController { let stackView = UIStackView(arrangedSubviews: [ headerLabel, walletHeader, paymentContainerView, errorLabel, bottomNoticeTextField, ]) + stackView.directionalLayoutMargins = PaymentSheetUI.defaultMargins stackView.isLayoutMarginsRelativeArrangement = true stackView.spacing = PaymentSheetUI.defaultPadding + stackView.setCustomSpacing(8.0, after: walletHeader) stackView.axis = .vertical stackView.bringSubviewToFront(headerLabel)