Skip to content

Commit

Permalink
Paywalls: fixed LoadingPaywallView displaying a progress view (#2929
Browse files Browse the repository at this point in the history
)

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.
  • Loading branch information
NachoSoto committed Sep 15, 2023
1 parent 4b13430 commit 955d493
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions RevenueCatUI/Views/LoadingPaywallView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions RevenueCatUI/Views/PackageButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down

0 comments on commit 955d493

Please sign in to comment.