Skip to content

Commit

Permalink
Paywalls: only dismiss PaywallView when explicitly presenting it …
Browse files Browse the repository at this point in the history
…with `.presentPaywallIfNeeded` (#3075)
  • Loading branch information
NachoSoto committed Sep 14, 2023
1 parent 2dae7fd commit 811c91c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 2 additions & 0 deletions RevenueCatUI/View+PresentPaywall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ private struct PresentingPaywallModifier: ViewModifier {
)
.onPurchaseCompleted {
self.purchaseCompleted?($0)

self.isDisplayed = false
}
.toolbar {
ToolbarItem(placement: .destructiveAction) {
Expand Down
11 changes: 2 additions & 9 deletions RevenueCatUI/Views/PurchaseButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ struct PurchaseButton: View {
self.purchaseHandler = purchaseHandler
}

@Environment(\.dismiss)
private var dismiss

var body: some View {
self.button
}
Expand All @@ -64,12 +61,8 @@ struct PurchaseButton: View {
AsyncButton {
guard !self.purchaseHandler.actionInProgress else { return }

let cancelled = try await self.purchaseHandler.purchase(package: self.package.content,
with: self.mode).userCancelled

if !cancelled, case .fullScreen = self.mode {
self.dismiss()
}
_ = try await self.purchaseHandler.purchase(package: self.package.content,
with: self.mode)
} label: {
IntroEligibilityStateView(
textWithNoIntroOffer: self.package.localization.callToAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ struct SamplePaywallsList: View {
purchaseHandler: .default())
}
}
.onPurchaseCompleted { _ in
self.display = nil
}
.navigationTitle("Paywalls")
}

Expand Down

0 comments on commit 811c91c

Please sign in to comment.