Skip to content

Commit

Permalink
Paywalls: markdown support (#2961)
Browse files Browse the repository at this point in the history
This relies on `SwiftUI`'s automatic rendering of markdown when using
`Text(LocalizedStringKey)`

![Screenshot 2023-08-03 at 11 52
55](https://github.com/RevenueCat/purchases-ios/assets/685609/0f19be26-aaa1-4bb2-ab0f-e0b3b1396f0b)
  • Loading branch information
NachoSoto committed Sep 7, 2023
1 parent 3e5e1e8 commit 13f3ec8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions RevenueCatUI/Data/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ internal enum TestData {
termsOfServiceURL: URL(string: "https://revenuecat.com/tos")!
),
localization: .init(
title: "How your free trial works",
title: "How your **free** trial works",
callToAction: "Start",
callToActionWithIntroOffer: "Start your {{ intro_duration }} free",
offerDetails: "Only {{ price }} per {{ period }}",
offerDetailsWithIntroOffer: "First {{ intro_duration }} free,\nthen {{ total_price_and_per_month }}",
features: [
.init(title: "Today",
content: "Full access to 1000+ workouts plus free meal plan worth {{ price }}.",
content: "Full access to 1000+ workouts plus _free_ meal plan worth {{ price }}.",
iconID: "tick"),
.init(title: "Day 7",
content: "Get a reminder about when your trial is about to end.",
Expand Down Expand Up @@ -313,17 +313,17 @@ internal enum TestData {
}()

static let localization1: PaywallData.LocalizedConfiguration = .init(
title: "Ignite your child's curiosity",
subtitle: "Get access to all our educational content trusted by thousands of parents.",
title: "Ignite your child's *curiosity*",
subtitle: "Get access to all our educational content trusted by **thousands** of parents.",
callToAction: "Purchase for {{ price }}",
callToActionWithIntroOffer: "Purchase for {{ price_per_month }} per month",
offerDetails: "{{ price_per_month }} per month",
offerDetailsWithIntroOffer: "Start your {{ intro_duration }} trial, then {{ price_per_month }} per month",
features: []
)
static let localization2: PaywallData.LocalizedConfiguration = .init(
title: "Call to action for better conversion.",
subtitle: "Lorem ipsum is simply dummy text of the printing and typesetting industry.",
title: "Call to action for _better_ conversion.",
subtitle: "Lorem ipsum is simply dummy text of the ~printing and~ typesetting industry.",
callToAction: "Subscribe for {{ price_per_month }}/mo",
offerDetails: "{{ total_price_and_per_month }}",
offerDetailsWithIntroOffer: "{{ total_price_and_per_month }} after {{ intro_duration }} trial",
Expand Down
4 changes: 2 additions & 2 deletions RevenueCatUI/Templates/MultiPackageBoldTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ struct MultiPackageBoldTemplate: TemplateViewType {

Spacer()

Text(self.selectedLocalization.title)
Text(.init(self.selectedLocalization.title))
.foregroundColor(self.configuration.colors.text1Color)
.font(.largeTitle.bold())

Spacer()

Text(self.selectedLocalization.subtitle ?? "")
Text(.init(self.selectedLocalization.subtitle ?? ""))
.foregroundColor(self.configuration.colors.text1Color)
.font(.title3)

Expand Down
4 changes: 2 additions & 2 deletions RevenueCatUI/Templates/OnePackageStandardTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct OnePackageStandardTemplate: TemplateViewType {
self.headerImage

Group {
Text(verbatim: self.localization.title)
Text(.init(self.localization.title))
.font(self.configuration.mode.titleFont)
.fontWeight(.heavy)
.padding(
Expand All @@ -66,7 +66,7 @@ struct OnePackageStandardTemplate: TemplateViewType {
)

if self.configuration.mode.displaySubtitle, let subtitle = self.localization.subtitle {
Text(verbatim: subtitle)
Text(.init(subtitle))
.font(self.configuration.mode.subtitleFont)
}
}
Expand Down
6 changes: 3 additions & 3 deletions RevenueCatUI/Templates/OnePackageWithFeaturesTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct OnePackageWithFeaturesTemplate: TemplateViewType {
.cornerRadius(8)
}

Text(self.localization.title)
Text(.init(self.localization.title))
.font(.title)
.foregroundStyle(self.configuration.colors.text1Color)
.multilineTextAlignment(.center)
Expand Down Expand Up @@ -146,14 +146,14 @@ private struct FeatureView: View {
self.icon
}

Text(self.feature.title)
Text(.init(self.feature.title))
.foregroundStyle(self.colors.text1Color)
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
}

if let content = self.feature.content {
Text(content)
Text(.init(content))
.foregroundStyle(self.colors.accent2Color)
.font(.body)
}
Expand Down
2 changes: 1 addition & 1 deletion RevenueCatUI/Views/IntroEligibilityStateView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct IntroEligibilityStateView: View {
}

var body: some View {
Text(self.text)
Text(.init(self.text))
// Hide until we've determined intro eligibility
// only if there is a custom intro text.
.withPendingData(self.needsToWaitForIntroEligibility, alignment: self.alignment)
Expand Down

0 comments on commit 13f3ec8

Please sign in to comment.