Skip to content

Commit

Permalink
PaywallData: ignore empty strings in LocalizedConfiguration (#2818)
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoSoto committed Jul 18, 2023
1 parent c68764f commit a6c0331
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
29 changes: 20 additions & 9 deletions Sources/Paywalls/PaywallData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public protocol PaywallLocalizedConfiguration {

}

// swiftlint:disable identifier_name

extension PaywallData {

/// Defines the necessary localized information for a paywall.
Expand All @@ -62,13 +64,21 @@ extension PaywallData {
public var title: String
public var subtitle: String
public var callToAction: String
public var callToActionWithIntroOffer: String?
public var offerDetails: String
public var offerDetailsWithIntroOffer: String?

// swiftlint:enable missing_docs
@NonEmptyStringDecodable
var _callToActionWithIntroOffer: String?
@NonEmptyStringDecodable
var _offerDetailsWithIntroOffer: String?

public var callToActionWithIntroOffer: String? {
get { return self._callToActionWithIntroOffer }
set { self._callToActionWithIntroOffer = newValue }
}
public var offerDetailsWithIntroOffer: String? {
get { return self._offerDetailsWithIntroOffer }
set { self._offerDetailsWithIntroOffer = newValue }
}

/// swiftlint:disable:next missing_docs
public init(
title: String,
subtitle: String,
Expand All @@ -80,11 +90,12 @@ extension PaywallData {
self.title = title
self.subtitle = subtitle
self.callToAction = callToAction
self.callToActionWithIntroOffer = callToActionWithIntroOffer
self._callToActionWithIntroOffer = callToActionWithIntroOffer
self.offerDetails = offerDetails
self.offerDetailsWithIntroOffer = offerDetailsWithIntroOffer
self._offerDetailsWithIntroOffer = offerDetailsWithIntroOffer
}

// swiftlint:enable missing_docs
}

/// - Returns: ``PaywallData/LocalizedConfiguration-swift.struct`` for the given `Locale`, if found.
Expand Down Expand Up @@ -196,9 +207,9 @@ extension PaywallData.LocalizedConfiguration: Codable {
case title
case subtitle
case callToAction
case callToActionWithIntroOffer
case _callToActionWithIntroOffer = "callToActionWithIntroOffer"
case offerDetails
case offerDetailsWithIntroOffer
case _offerDetailsWithIntroOffer = "offerDetailsWithIntroOffer"
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"title": "Tienda",
"subtitle": "Descripción",
"call_to_action": "Comprar",
"offer_details": "{{ price_per_month }} cada mes"
"offer_details": "{{ price_per_month }} cada mes",
"offer_details_with_intro_offer": " "
}
},
"default_locale": "en_US",
Expand Down

0 comments on commit a6c0331

Please sign in to comment.