Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paywalls: disable interactive sheet dismissal during purchases #3613

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion RevenueCatUI/View+PresentPaywall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,33 @@ private struct PresentingPaywallModifier: ViewModifier {

var customerInfoFetcher: View.CustomerInfoFetcher
var introEligibility: TrialOrIntroEligibilityChecker?
var purchaseHandler: PurchaseHandler?

init(
shouldDisplay: @escaping @Sendable (CustomerInfo) -> Bool,
purchaseCompleted: PurchaseOrRestoreCompletedHandler?,
purchaseCancelled: PurchaseCancelledHandler?,
restoreCompleted: PurchaseOrRestoreCompletedHandler?,
onDismiss: (() -> Void)?,
content: PaywallViewConfiguration.Content,
fontProvider: PaywallFontProvider,
customerInfoFetcher: @escaping View.CustomerInfoFetcher,
introEligibility: TrialOrIntroEligibilityChecker?,
purchaseHandler: PurchaseHandler?
) {
self.shouldDisplay = shouldDisplay
self.purchaseCompleted = purchaseCompleted
self.purchaseCancelled = purchaseCancelled
self.restoreCompleted = restoreCompleted
self.onDismiss = onDismiss
self.content = content
self.fontProvider = fontProvider
self.customerInfoFetcher = customerInfoFetcher
self.introEligibility = introEligibility
self._purchaseHandler = .init(wrappedValue: purchaseHandler ?? .default())
}

@StateObject
private var purchaseHandler: PurchaseHandler

@State
private var data: Data?
Expand Down Expand Up @@ -201,6 +227,7 @@ private struct PresentingPaywallModifier: ViewModifier {
self.close()
}
}
.interactiveDismissDisabled(self.purchaseHandler.actionInProgress)
}
.task {
guard let info = try? await self.customerInfoFetcher() else { return }
Expand Down