Skip to content

Commit

Permalink
Adds long sample paywall with sticky footer to PaywallsTester (#4412)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayShortway authored Oct 30, 2024
1 parent c7aadbc commit 2ad11a5
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -643,13 +643,17 @@ private extension SamplePaywallLoader {
typealias LocaleID = PaywallComponent.LocaleID
typealias LocalizationDictionary = PaywallComponent.LocalizationDictionary

static func createFakePaywallComponentsData(components: [PaywallComponent], localization: [LocaleID: LocalizationDictionary]) -> PaywallComponentsData {
static func createFakePaywallComponentsData(
components: [PaywallComponent],
stickyFooter: PaywallComponent.StickyFooterComponent?,
localization: [LocaleID: LocalizationDictionary]
) -> PaywallComponentsData {
PaywallComponentsData(templateName: "Component Sample",
assetBaseURL: URL(string:"https://assets.pawwalls.com/")!,
componentsConfigs: .init(
base: .init(
stack: .init(components: components),
stickyFooter: nil
stickyFooter: stickyFooter
)
),
componentsLocalizations: localization,
Expand All @@ -658,15 +662,35 @@ private extension SamplePaywallLoader {
}

internal static var fitnessComponents: PaywallComponentsData {
return createFakePaywallComponentsData(components: fitnessSample, localization: fitnessPaywallStrings())
return createFakePaywallComponentsData(
components: fitnessSample,
stickyFooter: nil,
localization: fitnessPaywallStrings()
)
}

internal static var template1Components: PaywallComponentsData {
return createFakePaywallComponentsData(components: curiosity, localization: curiosityPaywallStrings())
return createFakePaywallComponentsData(
components: curiosity,
stickyFooter: nil,
localization: curiosityPaywallStrings()
)
}

internal static var simpleSampleComponents: PaywallComponentsData {
return createFakePaywallComponentsData(components: simpleSix, localization: simplePaywallStrings())
return createFakePaywallComponentsData(
components: simpleSix,
stickyFooter: nil,
localization: simplePaywallStrings()
)
}

internal static var longWithStickyFooter: PaywallComponentsData {
return createFakePaywallComponentsData(
components: longWithStickyFooterComponents,
stickyFooter: stickyPurchaseButtonFooter,
localization: curiosityPaywallStrings()
)
}

static var simpleOne: [PaywallComponent] = {
Expand Down Expand Up @@ -1379,6 +1403,55 @@ private extension SamplePaywallLoader {
padding: .zero))]

}()

// Long with sticky footer

static var longWithStickyFooterComponents: [PaywallComponent] = {
[
.stack(
.init(
components: [
headerZStack,
spacer,
headingText,
subHeadingText,
spacer,
featureVStack,
spacer,
featureVStack,
spacer,
featureVStack,
spacer,
featureVStack,
spacer,
featureVStack,
spacer,
],
dimension: .vertical(),
spacing: nil,
backgroundColor: nil,
padding: .zero
)
)
]
}()

static var stickyPurchaseButtonFooter: PaywallComponent.StickyFooterComponent = {
PaywallComponent.StickyFooterComponent(
stack: .init(
components: [
costText,
purchaseButton,
footerStack
],
dimension: .vertical(),
spacing: 10,
backgroundColor: .init(light: "#F2545B"),
padding: .zero,
cornerRadiuses: .init(topLeading: 16.0, topTrailing: 16.0, bottomLeading: 0.0, bottomTrailing: 0.0)
)
)
}()

static func fitnessPaywallStrings() -> [LocaleID: LocalizationDictionary] {
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ struct SamplePaywallsList: View {
} label: {
TemplateLabel(name: "Simple Sample Components", icon: "iphone")
}
Button {
let data = SamplePaywallLoader.longWithStickyFooter
data.componentsConfigs.base.stack.components.printAsJSON()
data.componentsLocalizations.printAsJSON()
self.display = .componentPaywall(data)
} label: {
TemplateLabel(name: "Long, with sticky footer", icon: "iphone")
}
}
#endif

Expand Down

0 comments on commit 2ad11a5

Please sign in to comment.