Skip to content

Commit

Permalink
Paywalls: tweaking colors on template 2&3 (#3011)
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoSoto committed Aug 31, 2023
1 parent d5b7bad commit 87fc166
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
12 changes: 11 additions & 1 deletion RevenueCatUI/Data/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,22 @@ internal enum TestData {
images: Self.images,
colors: .init(
light: .init(
background: "#FAFAFA",
text1: "#000000",
text2: "#2A2A2A",
callToActionBackground: "#222222",
callToActionForeground: "#FFFFFF",
accent1: "#F4E971",
accent2: "#121212"
),
dark: .init(
background: "#272727",
text1: "#FFFFFF",
text2: "#B7B7B7",
callToActionBackground: "#FFFFFF",
callToActionForeground: "#000000",
accent1: "#F4E971"
accent1: "#F4E971",
accent2: "#4A4A4A"
)
),
termsOfServiceURL: URL(string: "https://revenuecat.com/tos")!
Expand Down
1 change: 1 addition & 0 deletions RevenueCatUI/Helpers/PreviewHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct PreviewableTemplate<T: TemplateViewType>: View {
self.creator(configuration)
.environmentObject(self.introEligibilityViewModel)
.environmentObject(PreviewHelpers.purchaseHandler)
.background(configuration.backgroundView)
.task {
await self.introEligibilityViewModel.computeEligibility(
for: configuration.packages
Expand Down
6 changes: 4 additions & 2 deletions RevenueCatUI/Templates/Template2View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct Template2View: TemplateViewType {
EmptyView()
} else {
RoundedRectangle(cornerRadius: Self.cornerRadius)
.stroke(self.configuration.colors.text1Color, lineWidth: 2)
.stroke(self.configuration.colors.text1Color.opacity(Self.fadedColorOpacity), lineWidth: 2)
}
}
.background {
Expand Down Expand Up @@ -156,7 +156,7 @@ struct Template2View: TemplateViewType {
EmptyView()
} else {
Circle()
.foregroundColor(self.selectedBackgroundColor.opacity(0.5))
.foregroundColor(self.selectedBackgroundColor.opacity(Self.fadedColorOpacity))
}
}

Expand Down Expand Up @@ -239,6 +239,8 @@ struct Template2View: TemplateViewType {
private var appIconSize: CGFloat = 100
@ScaledMetric(relativeTo: .largeTitle)
private var iconSize: CGFloat = 140

private static let fadedColorOpacity: CGFloat = 0.3
private static let cornerRadius: CGFloat = 15
private static let packageButtonAlignment: Alignment = .leading

Expand Down
2 changes: 1 addition & 1 deletion RevenueCatUI/Templates/Template3View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private struct FeatureView: View {
.padding(self.iconPadding)
}
}
.foregroundColor(.black)
.foregroundColor(self.colors.accent2Color)
.frame(width: self.iconSize, height: self.iconSize)
}

Expand Down
8 changes: 8 additions & 0 deletions Tests/RevenueCatUITests/Templates/Template3ViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ class Template3ViewTests: BaseSnapshotTest {
.snapshot(size: Self.fullScreenSize)
}

func testDarkMode() {
PaywallView(offering: Self.offering.withLocalImages,
introEligibility: Self.eligibleChecker,
purchaseHandler: Self.purchaseHandler)
.environment(\.colorScheme, .dark)
.snapshot(size: Self.fullScreenSize)
}

func testCustomFont() {
PaywallView(offering: Self.offering.withLocalImages,
fonts: Self.fonts,
Expand Down
12 changes: 11 additions & 1 deletion Tests/TestingApps/SimpleApp/SimpleApp/SamplePaywalls.swift
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,22 @@ private extension SamplePaywallLoader {
images: Self.images,
colors: .init(
light: .init(
background: "#FAFAFA",
text1: "#000000",
text2: "#2A2A2A",
callToActionBackground: "#222222",
callToActionForeground: "#FFFFFF",
accent1: "#F4E971",
accent2: "#121212"
),
dark: .init(
background: "#272727",
text1: "#FFFFFF",
text2: "#B7B7B7",
callToActionBackground: "#FFFFFF",
callToActionForeground: "#000000",
accent1: "#F4E971"
accent1: "#F4E971",
accent2: "#4A4A4A"
)
),
termsOfServiceURL: Self.tosURL
Expand Down

0 comments on commit 87fc166

Please sign in to comment.