From d99fd9e81668fb8258df6f72d0830d66c4d2499c Mon Sep 17 00:00:00 2001 From: Andy Boedo Date: Wed, 6 Dec 2023 17:37:13 -0300 Subject: [PATCH] Paywalls: disable the close button when an action is in progress (#3474) Disabled and lowered the opacity of the close button while an action is in progress, to prevent a potentially bad UX state when you exit the paywall. --- RevenueCatUI/PaywallView.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/RevenueCatUI/PaywallView.swift b/RevenueCatUI/PaywallView.swift index 21b396e286..a3c2ec2b5c 100644 --- a/RevenueCatUI/PaywallView.swift +++ b/RevenueCatUI/PaywallView.swift @@ -309,7 +309,7 @@ struct LoadedOfferingPaywallView: View { if let dismiss = self.dismiss { NavigationView { view - .toolbar { Self.toolbar(dismiss) } + .toolbar { self.toolbar(dismiss) } } .navigationViewStyle(.stack) @@ -329,13 +329,18 @@ struct LoadedOfferingPaywallView: View { ) } - private static func toolbar(_ dismiss: @escaping () -> Void) -> some ToolbarContent { + private func toolbar(_ dismiss: @escaping () -> Void) -> some ToolbarContent { ToolbarItem(placement: .destructiveAction) { Button { dismiss() } label: { Image(systemName: "xmark") } + .disabled(self.purchaseHandler.actionInProgress) + .opacity( + self.purchaseHandler.actionInProgress + ? Constants.purchaseInProgressButtonOpacity + : 1) } }