From 90977a873044d5a26ded3ba78e97593601b58f87 Mon Sep 17 00:00:00 2001 From: Yuki Date: Thu, 25 Aug 2022 10:39:06 -0700 Subject: [PATCH] Bandaid fix for missing PaymentSheet loading -> loaded animation. (#1390) Long-term fix is to revert this commit, add `animated: Bool` params to SectionContainerView, AddressSection, etc., and make the `updateBillingSameAsShippingDefaultAddress` call in `AddPaymentMethodViewController.willAppear` pass `animated: false`. If it animates during viewWillAppear, the view controller presentation animation becomes glitchy. --- Stripe/BottomSheetViewController.swift | 2 +- .../Source/Categories/UIViewController+StripeUICore.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Stripe/BottomSheetViewController.swift b/Stripe/BottomSheetViewController.swift index 0510ab11de9..00259c9924d 100644 --- a/Stripe/BottomSheetViewController.swift +++ b/Stripe/BottomSheetViewController.swift @@ -84,7 +84,7 @@ class BottomSheetViewController: UIViewController, BottomSheetPresentable { } self.contentContainerView.layoutIfNeeded() - animateHeightChange() + animateHeightChange(forceAnimation: true) // Add its navigation bar if necessary oldContentViewController.navigationBar.removeFromSuperview() navigationBarContainerView.addArrangedSubview(contentViewController.navigationBar) diff --git a/StripeUICore/StripeUICore/Source/Categories/UIViewController+StripeUICore.swift b/StripeUICore/StripeUICore/Source/Categories/UIViewController+StripeUICore.swift index 9714a0ee596..561640f468e 100644 --- a/StripeUICore/StripeUICore/Source/Categories/UIViewController+StripeUICore.swift +++ b/StripeUICore/StripeUICore/Source/Categories/UIViewController+StripeUICore.swift @@ -9,9 +9,9 @@ import UIKit @_spi(STP) public extension UIViewController { /// Use this to animate changes that affect the height of the sheet - func animateHeightChange(duration: CGFloat = 0.5, _ animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) + func animateHeightChange(forceAnimation: Bool = false, duration: CGFloat = 0.5, _ animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) { - guard !isBeingPresented else { + guard forceAnimation || !isBeingPresented else { animations?() return }