Skip to content

Commit

Permalink
Paywalls: changed subtitle to be optional (#2900)
Browse files Browse the repository at this point in the history
Not all templates require it, so it's optional from here on.
  • Loading branch information
NachoSoto committed Aug 3, 2023
1 parent 1442761 commit de90b84
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 14 deletions.
6 changes: 3 additions & 3 deletions RevenueCatUI/Data/ProcessedLocalizedConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct ProcessedLocalizedConfiguration: PaywallLocalizedConfiguration {
typealias Feature = PaywallData.LocalizedConfiguration.Feature

var title: String
var subtitle: String
var subtitle: String?
var callToAction: String
var callToActionWithIntroOffer: String?
var offerDetails: String
Expand All @@ -23,7 +23,7 @@ struct ProcessedLocalizedConfiguration: PaywallLocalizedConfiguration {
) {
self.init(
title: configuration.title.processed(with: dataProvider, locale: locale),
subtitle: configuration.subtitle.processed(with: dataProvider, locale: locale),
subtitle: configuration.subtitle?.processed(with: dataProvider, locale: locale),
callToAction: configuration.callToAction.processed(with: dataProvider, locale: locale),
callToActionWithIntroOffer: configuration.callToActionWithIntroOffer?.processed(with: dataProvider,
locale: locale),
Expand All @@ -41,7 +41,7 @@ struct ProcessedLocalizedConfiguration: PaywallLocalizedConfiguration {

private init(
title: String,
subtitle: String,
subtitle: String?,
callToAction: String,
callToActionWithIntroOffer: String?,
offerDetails: String,
Expand Down
2 changes: 1 addition & 1 deletion RevenueCatUI/Templates/MultiPackageBoldTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private struct MultiPackageTemplateContent: View {

Spacer()

Text(self.selectedLocalization.subtitle)
Text(self.selectedLocalization.subtitle ?? "")
.font(.title2)

Spacer()
Expand Down
4 changes: 2 additions & 2 deletions RevenueCatUI/Templates/SinglePackageStandardTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ private struct SinglePackageTemplateContent: View {
: []
)

if self.configuration.mode.displaySubtitle {
Text(verbatim: self.localization.subtitle)
if self.configuration.mode.displaySubtitle, let subtitle = self.localization.subtitle {
Text(verbatim: subtitle)
.font(self.configuration.mode.subtitleFont)
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Paywalls/PaywallData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public protocol PaywallLocalizedConfiguration {
/// The title of the paywall screen.
var title: String { get }
/// The subtitle of the paywall screen.
var subtitle: String { get }
var subtitle: String? { get }
/// The content of the main action button for purchasing a subscription.
var callToAction: String { get }
/// The content of the main action button for purchasing a subscription when an intro offer is available.
Expand All @@ -66,7 +66,7 @@ extension PaywallData {
// swiftlint:disable missing_docs

public var title: String
public var subtitle: String
public var subtitle: String?
public var callToAction: String
public var offerDetails: String
public var offerName: String?
Expand All @@ -92,7 +92,7 @@ extension PaywallData {

public init(
title: String,
subtitle: String,
subtitle: String? = nil,
callToAction: String,
callToActionWithIntroOffer: String? = nil,
offerDetails: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func checkPaywallConfiguration(_ config: PaywallData.Configuration,

func checkPaywallLocalizedConfig(_ config: PaywallData.LocalizedConfiguration) {
let title: String = config.title
let subtitle: String = config.subtitle
let subtitle: String? = config.subtitle
let callToAction: String = config.callToAction
let callToActionWithIntroOffer: String? = config.callToActionWithIntroOffer
let offerDetails: String = config.offerDetails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
},
"es_ES": {
"title": "Tienda",
"subtitle": "Descripción",
"call_to_action": "Comprar",
"call_to_action_with_intro_offer": "Comprar",
"offer_details": "{{ price_per_month }} cada mes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
},
"es_ES": {
"title": "Tienda",
"subtitle": "Descripción",
"call_to_action": "Comprar",
"offer_details": "{{ price_per_month }} cada mes",
"offer_details_with_intro_offer": " ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class OfferingsDecodingTests: BaseHTTPResponseTest {

let esConfig = try XCTUnwrap(paywall.config(for: Locale(identifier: "es_ES")))
expect(esConfig.title) == "Tienda"
expect(esConfig.subtitle) == "Descripción"
expect(esConfig.subtitle).to(beNil())
expect(esConfig.callToAction) == "Comprar"
expect(esConfig.callToActionWithIntroOffer) == "Comprar"
expect(esConfig.offerDetails) == "{{ price_per_month }} cada mes"
Expand Down
2 changes: 1 addition & 1 deletion Tests/UnitTests/Paywalls/PaywallDataTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class PaywallDataTests: BaseHTTPResponseTest {

let esConfig = try XCTUnwrap(paywall.config(for: Locale(identifier: "es_ES")))
expect(esConfig.title) == "Tienda"
expect(esConfig.subtitle) == "Descripción"
expect(esConfig.subtitle).to(beNil())
expect(esConfig.callToAction) == "Comprar"
expect(esConfig.callToActionWithIntroOffer).to(beNil())
expect(esConfig.offerDetails) == "{{ price_per_month }} cada mes"
Expand Down

0 comments on commit de90b84

Please sign in to comment.