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: improve PreviewableTemplate's display name #3682

Merged
merged 1 commit into from
Feb 13, 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
12 changes: 7 additions & 5 deletions RevenueCatUI/Helpers/PreviewHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct PreviewableTemplate<T: TemplateViewType>: View {
@Environment(\.userInterfaceIdiom)
private var interfaceIdiom

private let configuration: Result<TemplateViewConfiguration, Error>
private let configuration: Result<(PaywallTemplate, TemplateViewConfiguration), Error>
private let presentInSheet: Bool
private let creator: Creator

Expand All @@ -66,15 +66,17 @@ struct PreviewableTemplate<T: TemplateViewType>: View {
creator: @escaping Creator
) {
let paywall = offering.paywall!
let template = PaywallTemplate(rawValue: paywall.templateName)!

self.configuration = paywall.configuration(
for: offering,
activelySubscribedProductIdentifiers: activelySubscribedProductIdentifiers,
template: PaywallTemplate(rawValue: paywall.templateName)!,
template: template,
mode: mode,
fonts: DefaultPaywallFontProvider(),
locale: .current
)
).map { (template, $0) }

self.presentInSheet = presentInSheet
self.creator = creator
}
Expand All @@ -94,7 +96,7 @@ struct PreviewableTemplate<T: TemplateViewType>: View {
@ViewBuilder
private var content: some View {
switch self.configuration {
case let .success(configuration):
case let .success((template, configuration)):
self.creator(configuration)
.environmentObject(self.introEligibilityViewModel)
.environmentObject(PreviewHelpers.purchaseHandler)
Expand All @@ -105,7 +107,7 @@ struct PreviewableTemplate<T: TemplateViewType>: View {
for: configuration.packages
)
}
.previewDisplayName("\(configuration.mode)")
.previewDisplayName("Template \(template.rawValue)-\(configuration.mode)")
.previewLayout(configuration.mode.layout)

case let .failure(error):
Expand Down