Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paywalls: template 5 #3095

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions RevenueCatUI/Data/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ enum Constants {
static let toggleAllPlansAnimation: Animation = .spring(response: 0.35, dampingFraction: 0.7)

static let defaultCornerRadius: CGFloat = 20
static let defaultPackageCornerRadius: CGFloat = 16
static let defaultPackageBorderWidth: CGFloat = 2

/// For UI elements that wouldn't make sense to keep scaling up forever
static let maximumDynamicTypeSize: DynamicTypeSize = .accessibility3
Expand All @@ -43,6 +45,15 @@ enum Constants {

}

@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
extension Constants {

static var checkmarkImage: some View {
Image(systemName: "checkmark.circle.fill")
}

}

@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
extension TemplateViewType {

Expand Down
1 change: 1 addition & 0 deletions RevenueCatUI/Data/PaywallTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal enum PaywallTemplate: String {

// Temporarily disabled until it's supported in the dashboard
case template4 = "4_disabled"
case template5 = "5_disabled"

}

Expand Down
54 changes: 54 additions & 0 deletions RevenueCatUI/Data/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,60 @@ internal enum TestData {
TestData.annualPackage]
)

static let offeringWithTemplate5Paywall = Offering(
identifier: Self.offeringIdentifier,
serverDescription: "Offering",
metadata: [:],
paywall: .init(
templateName: PaywallTemplate.template5.rawValue,
config: .init(
packages: [PackageType.annual.identifier,
PackageType.monthly.identifier],
defaultPackage: PackageType.annual.identifier,
images: .init(
header: "954459_1692992845.png"
),
colors: .init(
light: .init(
background: "#FFFFFF",
text1: "#000000",
callToActionBackground: "#008575",
callToActionForeground: "#FFFFFF",
accent1: "#008575",
accent2: "#DFDFDF"
),
dark: .init(
background: "#000000",
text1: "#FFFFFF",
callToActionBackground: "#41E194",
callToActionForeground: "#000000",
accent1: "#41E194",
accent2: "#DFDFDF"
)
),
termsOfServiceURL: URL(string: "https://revenuecat.com/tos")!
),
localization: .init(
title: "Spice Up Your Kitchen - Go Pro for Exclusive Benefits!",
callToAction: "Continue",
callToActionWithIntroOffer: "Start your Free Trial",
offerDetails: "{{ total_price_and_per_month }}",
offerDetailsWithIntroOffer: "Free for {{ sub_offer_duration }}, then {{ total_price_and_per_month }}",
offerName: "{{ sub_period }}",
features: [
.init(title: "Unique gourmet recipes", iconID: "tick"),
.init(title: "Advanced nutritional recipes", iconID: "tick"),
.init(title: "Personalized support from our Chef", iconID: "tick"),
.init(title: "Unlimited receipt collections", iconID: "tick")
]
),
assetBaseURL: Self.paywallAssetBaseURL
),
availablePackages: [TestData.monthlyPackage,
TestData.sixMonthPackage,
TestData.annualPackage]
)

static let offeringWithNoPaywall = Offering(
identifier: Self.offeringIdentifier,
serverDescription: "Offering",
Expand Down
1 change: 1 addition & 0 deletions RevenueCatUI/PaywallView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ private extension PaywallTemplate {
case .template2: return "Bold Packages"
case .template3: return "Feature List"
case .template4: return "Horizontal"
case .template5: return "Small Banner"
}
}

Expand Down
8 changes: 4 additions & 4 deletions RevenueCatUI/Templates/Template2View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ struct Template2View: TemplateViewType {
self.selectedPackage = package
} label: {
self.packageButton(package, selected: isSelected)
.contentShape(Rectangle())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted to PackageButtonStyle.

}
.buttonStyle(PackageButtonStyle(isSelected: isSelected))
}
Expand All @@ -144,7 +143,8 @@ struct Template2View: TemplateViewType {
EmptyView()
} else {
self.roundedRectangle
.stroke(self.configuration.colors.text1Color.opacity(Self.fadedColorOpacity), lineWidth: 2)
.stroke(self.configuration.colors.text1Color.opacity(Self.fadedColorOpacity),
lineWidth: Constants.defaultPackageBorderWidth)
}
}
.background {
Expand Down Expand Up @@ -173,7 +173,7 @@ struct Template2View: TemplateViewType {
selected: Bool
) -> some View {
HStack {
Image(systemName: "checkmark.circle.fill")
Constants.checkmarkImage
.hidden(if: !selected)
.overlay {
if selected {
Expand Down Expand Up @@ -265,7 +265,7 @@ struct Template2View: TemplateViewType {
private var iconSize: CGFloat = 140

private static let fadedColorOpacity: CGFloat = 0.3
private static let cornerRadius: CGFloat = 15
private static let cornerRadius: CGFloat = Constants.defaultPackageCornerRadius
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted to have common values.

private static let packageButtonAlignment: Alignment = .leading

}
Expand Down
3 changes: 1 addition & 2 deletions RevenueCatUI/Templates/Template3View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ private struct FeatureView: View {
private var icon: some View {
Circle()
.overlay {
if let iconName = self.feature.iconID,
let icon = PaywallIcon(rawValue: iconName) {
if let icon = self.feature.icon {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted this into an extension to reuse it.

IconView(icon: icon, tint: self.colors.accent1Color)
.padding(self.iconPadding)
}
Expand Down
1 change: 0 additions & 1 deletion RevenueCatUI/Templates/Template4View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ struct Template4View: TemplateViewType {
selected: isSelected,
packageWidth: self.packageWidth,
desiredHeight: self.packageContentHeight)
.contentShape(Rectangle())
}
.buttonStyle(PackageButtonStyle(isSelected: isSelected))
}
Expand Down
Loading