From 153c753687ce349937e760d9af8fd39a5558b612 Mon Sep 17 00:00:00 2001 From: NachoSoto Date: Mon, 31 Jul 2023 20:56:08 +0200 Subject: [PATCH] `Paywalls`: fixed `LoadingPaywallView` displaying a progress view (#2929) This was broken in #2923. Unfortunately it couldn't be caught by snapshot tests because those don't display progress views. I simplified `PackageButtonStyle` to get the shared `PurchaseHandler.actionInProgress` state instead of relying on whether the button is enabled. --- RevenueCatUI/Views/LoadingPaywallView.swift | 18 ++++++++++++++++++ RevenueCatUI/Views/PackageButtonStyle.swift | 8 ++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/RevenueCatUI/Views/LoadingPaywallView.swift b/RevenueCatUI/Views/LoadingPaywallView.swift index d443f65849..b295144ded 100644 --- a/RevenueCatUI/Views/LoadingPaywallView.swift +++ b/RevenueCatUI/Views/LoadingPaywallView.swift @@ -104,3 +104,21 @@ private extension LoadingPaywallView { subscriptionPeriod: .init(value: 1, unit: .year) ) } + +// MARK: - + +#if DEBUG + +@available(iOS 16.0, macOS 13.0, tvOS 16.0, *) +@available(watchOS, unavailable) +@available(macOS, unavailable) +@available(macCatalyst, unavailable) +struct LoadingPaywallView_Previews: PreviewProvider { + + static var previews: some View { + LoadingPaywallView() + } + +} + +#endif diff --git a/RevenueCatUI/Views/PackageButtonStyle.swift b/RevenueCatUI/Views/PackageButtonStyle.swift index 1c97cc24dc..1c74b0d182 100644 --- a/RevenueCatUI/Views/PackageButtonStyle.swift +++ b/RevenueCatUI/Views/PackageButtonStyle.swift @@ -16,15 +16,15 @@ struct PackageButtonStyle: ButtonStyle { var isSelected: Bool - @Environment(\.isEnabled) - private var isEnabled + @EnvironmentObject + private var purchaseHandler: PurchaseHandler func makeBody(configuration: ButtonStyleConfiguration) -> some View { configuration .label - .hidden(if: !self.isEnabled) + .hidden(if: self.purchaseHandler.actionInProgress) .overlay { - if self.isSelected, !self.isEnabled { + if self.isSelected, self.purchaseHandler.actionInProgress { ProgressView() } }