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 V2] Rename paywallFooter to originalTemplatePaywallFooter #4721

Merged
merged 4 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
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
114 changes: 105 additions & 9 deletions RevenueCatUI/View+PresentPaywallFooter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// View+PresentPaywallFooter.swift
//
// Created by Josh Holtz on 8/18/23.
//
// swiftlint:disable file_length

import RevenueCat
import SwiftUI
Expand Down Expand Up @@ -68,6 +70,7 @@ extension View {
)
}

// swiftlint:disable line_length
/// Presents a ``PaywallFooterView`` at the bottom of a view that loads the `Offerings.current`.
/// ```swift
/// var body: some View {
Expand All @@ -78,6 +81,12 @@ extension View {
///
/// ### Related Articles
/// [Documentation](https://rev.cat/paywalls)
@available(iOS, deprecated: 1, renamed: "originalTemplatePaywallFooter(condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(tvOS, deprecated: 1, renamed: "originalTemplatePaywallFooter(condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(watchOS, deprecated: 1, renamed: "originalTemplatePaywallFooter(condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(macOS, deprecated: 1, renamed: "originalTemplatePaywallFooter(condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(macCatalyst, deprecated: 1, renamed: "originalTemplatePaywallFooter(condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
// swiftlint:enable line_length
public func paywallFooter(
condensed: Bool = false,
fonts: PaywallFontProvider = DefaultPaywallFontProvider(),
Expand All @@ -89,10 +98,49 @@ extension View {
restoreCompleted: PurchaseOrRestoreCompletedHandler? = nil,
purchaseFailure: PurchaseFailureHandler? = nil,
restoreFailure: PurchaseFailureHandler? = nil
) -> some View {
return self.originalTemplatePaywallFooter(
condensed: condensed,
fonts: fonts,
myAppPurchaseLogic: myAppPurchaseLogic,
purchaseStarted: purchaseStarted,
purchaseCompleted: purchaseCompleted,
purchaseCancelled: purchaseCancelled,
restoreStarted: restoreStarted,
restoreCompleted: restoreCompleted,
purchaseFailure: purchaseFailure,
restoreFailure: restoreFailure
)
}

/// Presents a ``PaywallFooterView`` at the bottom of a view that loads the `Offerings.current`.
/// If you are presenting a V1 paywall, this will show the footer of the template you selected.
/// If you are presenting a V2 paywall, this will show a default footer since V2 paywalls
Comment on lines +117 to +118
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can keep the V1/V2 stuff here for now imo, but we should be mindful to update this when V2 becomes the default / gets to GA.

/// don't have a footer representation.
/// ```swift
/// var body: some View {
/// YourPaywall()
/// .originalTemplatePaywallFooter()
/// }
/// ```
///
/// ### Related Articles
/// [Documentation](https://rev.cat/paywalls)
public func originalTemplatePaywallFooter(
condensed: Bool = false,
fonts: PaywallFontProvider = DefaultPaywallFontProvider(),
myAppPurchaseLogic: MyAppPurchaseLogic? = nil,
purchaseStarted: PurchaseOfPackageStartedHandler? = nil,
purchaseCompleted: PurchaseOrRestoreCompletedHandler? = nil,
purchaseCancelled: PurchaseCancelledHandler? = nil,
restoreStarted: RestoreStartedHandler? = nil,
restoreCompleted: PurchaseOrRestoreCompletedHandler? = nil,
purchaseFailure: PurchaseFailureHandler? = nil,
restoreFailure: PurchaseFailureHandler? = nil
) -> some View {
let purchaseHandler = PurchaseHandler.default(performPurchase: myAppPurchaseLogic?.performPurchase,
performRestore: myAppPurchaseLogic?.performRestore)
return self.paywallFooter(
return self.originalTemplatePaywallFooter(
offering: nil,
customerInfo: nil,
condensed: condensed,
Expand Down Expand Up @@ -120,11 +168,11 @@ extension View {
///
/// ### Related Articles
/// [Documentation](https://rev.cat/paywalls)
@available(iOS, deprecated: 1, renamed: "paywallFooter(offering:condensed:fonts:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(tvOS, deprecated: 1, renamed: "paywallFooter(offering:condensed:fonts:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(watchOS, deprecated: 1, renamed: "paywallFooter(offering:condensed:fonts:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(macOS, deprecated: 1, renamed: "paywallFooter(offering:condensed:fonts:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(macCatalyst, deprecated: 1, renamed: "paywallFooter(offering:condensed:fonts:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(iOS, deprecated: 1, renamed: "paywallFooter(offering:condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(tvOS, deprecated: 1, renamed: "paywallFooter(offering:condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(watchOS, deprecated: 1, renamed: "paywallFooter(offering:condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(macOS, deprecated: 1, renamed: "paywallFooter(offering:condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(macCatalyst, deprecated: 1, renamed: "paywallFooter(offering:condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
// swiftlint:enable line_length
@_disfavoredOverload
public func paywallFooter(
Expand All @@ -139,7 +187,7 @@ extension View {
restoreFailure: PurchaseFailureHandler? = nil
) -> some View {
let purchaseHandler = PurchaseHandler.default()
return self.paywallFooter(
return self.originalTemplatePaywallFooter(
offering: offering,
customerInfo: nil,
condensed: condensed,
Expand All @@ -158,6 +206,7 @@ extension View {
)
}

// swiftlint:disable line_length
/// Presents a ``PaywallFooterView`` at the bottom of a view with the given offering.
/// ```swift
/// var body: some View {
Expand All @@ -168,6 +217,12 @@ extension View {
///
/// ### Related Articles
/// [Documentation](https://rev.cat/paywalls)
@available(iOS, deprecated: 1, renamed: "originalTemplatePaywallFooter(offering:condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(tvOS, deprecated: 1, renamed: "originalTemplatePaywallFooter(offering:condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(watchOS, deprecated: 1, renamed: "originalTemplatePaywallFooter(offering:condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(macOS, deprecated: 1, renamed: "originalTemplatePaywallFooter(offering:condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
@available(macCatalyst, deprecated: 1, renamed: "originalTemplatePaywallFooter(offering:condensed:fonts:myAppPurchaseLogic:purchaseStarted:purchaseCompleted:purchaseCancelled:restoreStarted:restoreCompleted:purchaseFailure:restoreFailure:)")
// swiftlint:enable line_length
public func paywallFooter(
offering: Offering,
condensed: Bool = false,
Expand All @@ -180,10 +235,51 @@ extension View {
restoreCompleted: PurchaseOrRestoreCompletedHandler? = nil,
purchaseFailure: PurchaseFailureHandler? = nil,
restoreFailure: PurchaseFailureHandler? = nil
) -> some View {
return self.originalTemplatePaywallFooter(
offering: offering,
condensed: condensed,
fonts: fonts,
myAppPurchaseLogic: myAppPurchaseLogic,
purchaseStarted: purchaseStarted,
purchaseCompleted: purchaseCompleted,
purchaseCancelled: purchaseCancelled,
restoreStarted: restoreStarted,
restoreCompleted: restoreCompleted,
purchaseFailure: purchaseFailure,
restoreFailure: restoreFailure
)
}

/// Presents a ``PaywallFooterView`` at the bottom of a view with the given offering.
/// If you are presenting a V1 paywall, this will show the footer of the template you selected.
/// If you are presenting a V2 paywall, this will show a default footer since V2 paywalls
/// don't have a footer representation.
/// ```swift
/// var body: some View {
/// YourPaywall()
/// .originalTemplatePaywallFooter(offering: offering)
/// }
/// ```
///
/// ### Related Articles
/// [Documentation](https://rev.cat/paywalls)
public func originalTemplatePaywallFooter(
offering: Offering,
condensed: Bool = false,
fonts: PaywallFontProvider = DefaultPaywallFontProvider(),
myAppPurchaseLogic: MyAppPurchaseLogic? = nil,
purchaseStarted: PurchaseOfPackageStartedHandler? = nil,
purchaseCompleted: PurchaseOrRestoreCompletedHandler? = nil,
purchaseCancelled: PurchaseCancelledHandler? = nil,
restoreStarted: RestoreStartedHandler? = nil,
restoreCompleted: PurchaseOrRestoreCompletedHandler? = nil,
purchaseFailure: PurchaseFailureHandler? = nil,
restoreFailure: PurchaseFailureHandler? = nil
) -> some View {
let purchaseHandler = PurchaseHandler.default(performPurchase: myAppPurchaseLogic?.performPurchase,
performRestore: myAppPurchaseLogic?.performRestore)
return self.paywallFooter(
return self.originalTemplatePaywallFooter(
offering: offering,
customerInfo: nil,
condensed: condensed,
Expand All @@ -201,7 +297,7 @@ extension View {
}

// @PublicForExternalTesting
func paywallFooter(
func originalTemplatePaywallFooter(
offering: Offering?,
customerInfo: CustomerInfo?,
condensed: Bool = false,
Expand Down
Loading