Skip to content

Commit

Permalink
Paywalls: updated template names (#2878)
Browse files Browse the repository at this point in the history
These now match our initial 2 templates.

I've updated everything for consistency:
- `PaywallTemplate`
- `View`s
- Snapshot tests
- Test fixtures
  • Loading branch information
NachoSoto committed Aug 17, 2023
1 parent a5c3bcc commit 2596938
Show file tree
Hide file tree
Showing 20 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ let package = Package(
"Nimble",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
],
exclude: ["__Snapshots__"],
exclude: ["Templates/__Snapshots__"],
resources: [.copy("Resources/header.jpg"), .copy("Resources/background.jpg")])
]
)
6 changes: 3 additions & 3 deletions RevenueCatUI/Data/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ internal enum TestData {
]

static let paywallWithIntroOffer = PaywallData(
template: .singlePackage,
template: .onePackageStandard,
config: .init(
packages: [.monthly],
images: Self.images,
Expand All @@ -129,7 +129,7 @@ internal enum TestData {
assetBaseURL: Self.paywallAssetBaseURL
)
static let paywallWithNoIntroOffer = PaywallData(
template: .singlePackage,
template: .onePackageStandard,
config: .init(
packages: [.annual],
images: Self.images,
Expand Down Expand Up @@ -160,7 +160,7 @@ internal enum TestData {
serverDescription: "Offering",
metadata: [:],
paywall: .init(
template: .multiPackage,
template: .multiPackageBold,
config: .init(
packages: [.annual, .monthly],
images: Self.images,
Expand Down
2 changes: 1 addition & 1 deletion RevenueCatUI/Helpers/PaywallData+Default.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension PaywallData {
/// Default `PaywallData` to display when attempting to present a ``PaywallView`` with an offering
/// that has no paywall configuration, or when that configuration is invalid.
public static let `default`: Self = .init(
template: .multiPackage,
template: .multiPackageBold,
config: .init(
packages: [.weekly, .monthly, .annual],
images: .init(background: Self.backgroundImage),
Expand Down
4 changes: 2 additions & 2 deletions RevenueCatUI/PaywallView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ private extension PaywallTemplate {

var name: String {
switch self {
case .singlePackage: return "single"
case .multiPackage: return "multi"
case .onePackageStandard: return "single"
case .multiPackageBold: return "multi"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import RevenueCat
import SwiftUI

@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
struct MultiPackageTemplate: TemplateViewType {
struct MultiPackageBoldTemplate: TemplateViewType {

private let configuration: TemplateViewConfiguration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import RevenueCat
import SwiftUI

@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
struct SinglePackageTemplate: TemplateViewType {
struct SinglePackageStandardTemplate: TemplateViewType {

private let configuration: TemplateViewConfiguration

Expand Down
12 changes: 6 additions & 6 deletions RevenueCatUI/Templates/TemplateViewType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ private extension PaywallTemplate {

var packageSetting: TemplateViewConfiguration.PackageSetting {
switch self {
case .singlePackage: return .single
case .multiPackage: return .multiple
case .onePackageStandard: return .single
case .multiPackageBold: return .multiple
}
}

Expand Down Expand Up @@ -69,10 +69,10 @@ extension PaywallData {
private static func createView(template: PaywallTemplate,
configuration: TemplateViewConfiguration) -> some View {
switch template {
case .singlePackage:
SinglePackageTemplate(configuration)
case .multiPackage:
MultiPackageTemplate(configuration)
case .onePackageStandard:
SinglePackageStandardTemplate(configuration)
case .multiPackageBold:
MultiPackageBoldTemplate(configuration)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Paywalls/PaywallTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import Foundation
public enum PaywallTemplate: String {

// swiftlint:disable missing_docs
case singlePackage = "sample_1"
case multiPackage = "sample_2"
case onePackageStandard = "one_package_standard"
case multiPackageBold = "multi_package_bold"

// swiftlint:enable missing_docs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ func checkPaywallColor(_ color: PaywallColor) throws {

func checkPaywallTemplate(_ template: PaywallTemplate) {
switch template {
case .singlePackage:
case .onePackageStandard:
break
case .multiPackage:
case .multiPackageBold:
break
@unknown default:
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SnapshotTesting
#if !os(macOS)

@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
class MultiPackagePaywallViewTests: BaseSnapshotTest {
class MultiPackageBoldPaywallViewTests: BaseSnapshotTest {

func testSamplePaywall() {
let view = PaywallView(offering: Self.offering.withLocalImages,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SwiftUI
#if !os(macOS)

@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
class SinglePackagePaywallViewTests: BaseSnapshotTest {
class OnePackageStandardPaywallViewTests: BaseSnapshotTest {

func testSamplePaywall() {
let view = PaywallView(offering: Self.offeringWithNoIntroOffer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import SwiftUI
serverDescription: "Offering",
metadata: [:],
paywall: .init(
template: .multiPackage,
template: .multiPackageBold,
config: .init(
packages: [.weekly, .annual, .monthly],
images: TestData.images,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
],
"paywall": {
"template_name": "sample_1",
"template_name": "one_package_standard",
"localized_strings": {
"en_US": {
"title": "Paywall",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"template_name": "sample_1",
"template_name": "one_package_standard",
"localized_strings": {
"en_US": {
"title": "Paywall",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"template_name": "sample_1",
"template_name": "one_package_standard",
"localized_strings": {
"it_IT": {
"title": "Paywall",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"template_name": "sample_1",
"template_name": "one_package_standard",
"localized_strings": {
"es_ES": {
"title": "Tienda",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class OfferingsDecodingTests: BaseHTTPResponseTest {
expect(offering.packages).to(haveCount(2))

let paywall = try XCTUnwrap(offering.paywall)
expect(paywall.template) == .singlePackage
expect(paywall.template) == .onePackageStandard
expect(paywall.defaultLocale) == Locale(identifier: "en_US")
try expect(paywall.assetBaseURL) == XCTUnwrap(URL(string: "https://rc-paywalls.s3.amazonaws.com"))

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 @@ -29,7 +29,7 @@ class PaywallDataTests: BaseHTTPResponseTest {
func testSample1() throws {
let paywall: PaywallData = try self.decodeFixture("PaywallData-Sample1")

expect(paywall.template) == .singlePackage
expect(paywall.template) == .onePackageStandard
expect(paywall.defaultLocale) == Locale(identifier: Self.defaultLocale)
expect(paywall.assetBaseURL) == URL(string: "https://rc-paywalls.s3.amazonaws.com")!
expect(paywall.config.packages) == [.monthly, .annual]
Expand Down

0 comments on commit 2596938

Please sign in to comment.