Skip to content

Commit

Permalink
PaywallData: added @NonEmptyString to subtitle and offerName (#…
Browse files Browse the repository at this point in the history
…3150)

Thanks to @vegaro for pointing this out. It's not required, but it helps
to ensure that these properties don't end up with empty strings.
  • Loading branch information
NachoSoto committed Sep 14, 2023
1 parent 377dc9a commit 3600211
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion RevenueCatUI/Data/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation
import RevenueCat

// swiftlint:disable variable_name
// swiftlint:disable identifier_name

enum Strings {

Expand Down
23 changes: 17 additions & 6 deletions Sources/Paywalls/PaywallData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,25 @@ extension PaywallData {
// swiftlint:disable missing_docs

public var title: String
public var subtitle: String?
public var callToAction: String
public var offerName: String?

@NonEmptyStringDecodable
var _subtitle: String?
@NonEmptyStringDecodable
var _callToActionWithIntroOffer: String?
@NonEmptyStringDecodable
var _offerDetails: String?
@NonEmptyStringDecodable
var _offerDetailsWithIntroOffer: String?
@NonEmptyStringDecodable
var _offerName: String?
@DefaultDecodable.EmptyArray
var _features: [Feature]

public var subtitle: String? {
get { return self._subtitle }
set { self._subtitle = newValue }
}
public var callToActionWithIntroOffer: String? {
get { return self._callToActionWithIntroOffer }
set { self._callToActionWithIntroOffer = newValue }
Expand All @@ -95,6 +102,10 @@ extension PaywallData {
get { return self._offerDetailsWithIntroOffer }
set { self._offerDetailsWithIntroOffer = newValue }
}
public var offerName: String? {
get { return self._offerName }
set { self._offerName = newValue }
}
public var features: [Feature] {
get { return self._features }
set { self._features = newValue }
Expand All @@ -111,12 +122,12 @@ extension PaywallData {
features: [Feature] = []
) {
self.title = title
self.subtitle = subtitle
self._subtitle = subtitle
self.callToAction = callToAction
self._callToActionWithIntroOffer = callToActionWithIntroOffer
self._offerDetails = offerDetails
self._offerDetailsWithIntroOffer = offerDetailsWithIntroOffer
self.offerName = offerName
self._offerName = offerName
self.features = features
}

Expand Down Expand Up @@ -379,12 +390,12 @@ extension PaywallData.LocalizedConfiguration: Codable {

private enum CodingKeys: String, CodingKey {
case title
case subtitle
case _subtitle = "subtitle"
case callToAction
case _callToActionWithIntroOffer = "callToActionWithIntroOffer"
case _offerDetails = "offerDetails"
case _offerDetailsWithIntroOffer = "offerDetailsWithIntroOffer"
case offerName
case _offerName = "offerName"
case _features = "features"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
],
"offer_details" : "{{ total_price_and_per_month }}",
"offer_details_with_intro_offer" : "Try {{ sub_offer_duration }} for free, then {{ total_price_and_per_month }}",
"offer_name" : null,
"subtitle" : "Get access to all content",
"title" : "Ignite your child's curiosity"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
],
"offer_details" : "{{ total_price_and_per_month }}",
"offer_details_with_intro_offer" : "Start your {{ sub_offer_duration }} trial, then {{ total_price_and_per_month }}.",
"offer_name" : null,
"subtitle" : null,
"title" : "{{ app_name }}"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
],
"offer_details" : "{{ total_price_and_per_month }}",
"offer_details_with_intro_offer" : "Start your {{ sub_offer_duration }} trial, then {{ total_price_and_per_month }}.",
"offer_name" : null,
"subtitle" : null,
"title" : "{{ app_name }}"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
],
"offer_details" : "{{ total_price_and_per_month }}",
"offer_details_with_intro_offer" : "Start your {{ sub_offer_duration }} trial, then {{ total_price_and_per_month }}.",
"offer_name" : null,
"subtitle" : null,
"title" : "{{ app_name }}"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
],
"offer_details" : "{{ total_price_and_per_month }}",
"offer_details_with_intro_offer" : "Start your {{ sub_offer_duration }} trial, then {{ total_price_and_per_month }}.",
"offer_name" : null,
"subtitle" : null,
"title" : "{{ app_name }}"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
],
"offer_details" : "{{ total_price_and_per_month }}",
"offer_details_with_intro_offer" : "Start your {{ sub_offer_duration }} trial, then {{ total_price_and_per_month }}.",
"offer_name" : null,
"subtitle" : null,
"title" : "{{ app_name }}"
}
},
Expand Down

0 comments on commit 3600211

Please sign in to comment.