Skip to content

Commit

Permalink
Snapshot for this should be good
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdholtz committed Jan 12, 2025
1 parent abe467a commit 0254a82
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
54 changes: 54 additions & 0 deletions RevenueCatUI/Templates/V2/Components/Text/TextComponentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ struct TextComponentView: View {
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct TextComponentView_Previews: PreviewProvider {

static let fontSizeOverridesUIConfigProvider = UIConfigProvider(
uiConfig: PreviewUIConfig.make(),
fontSizeOverride: .init(
headingXXL: 10,
headingXL: 12,
headingL: 14,
headingM: 16,
headingS: 18,
headingXS: 20,
bodyXL: 22,
bodyL: 24,
bodyM: 26,
bodyS: 28
)
)

static var previews: some View {
// Default
TextComponentView(
Expand Down Expand Up @@ -265,6 +281,44 @@ struct TextComponentView_Previews: PreviewProvider {
.previewLayout(.sizeThatFits)
.previewDisplayName("Custom Color")

// Font Size Override
VStack {
let data: [(String, PaywallComponent.FontSize)] = [
("Heading XXL - Size 10", .headingXXL),
("Heading XL - Size 12", .headingXL),
("Heading L - Size 14", .headingL),
("Heading M - Size 16", .headingM),
("Heading S - Size 18", .headingS),
("Heading XS - Size 20", .headingXS),
("Body XL - Size 22", .bodyXL),
("Body L - Size 24", .bodyL),
("Body M - Size 26", .bodyM),
("Body S - Size 28", .bodyS)
]
ForEach(data, id: \.self.0) { (string, size) in
TextComponentView(
// swiftlint:disable:next force_try
viewModel: try! .init(
localizationProvider: .init(
locale: Locale.current,
localizedStrings: [
"id_1": .string(string)
]
),
uiConfigProvider: self.fontSizeOverridesUIConfigProvider,
component: .init(
text: "id_1",
color: .init(light: .hex("#000000")),
fontSize: size
)
)
)
}
}
.previewRequiredEnvironmentProperties()
.previewLayout(.sizeThatFits)
.previewDisplayName("Font Size Overrides")

// Gradient
TextComponentView(
// swiftlint:disable:next force_try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ public struct PaywallComponentsData: Codable, Equatable, Sendable {
public let bodyM: Int
public let bodyS: Int

public init(headingXXL: Int,
headingXL: Int,
headingL: Int,
headingM: Int,
headingS: Int,
headingXS: Int,
bodyXL: Int,
bodyL: Int,
bodyM: Int,
bodyS: Int) {
self.headingXXL = headingXXL
self.headingXL = headingXL
self.headingL = headingL
self.headingM = headingM
self.headingS = headingS
self.headingXS = headingXS
self.bodyXL = bodyXL
self.bodyL = bodyL
self.bodyM = bodyM
self.bodyS = bodyS
}

// swiftlint:disable:next nesting
private enum CodingKeys: String, CodingKey {
case headingXXL = "heading_xxl"
Expand Down

0 comments on commit 0254a82

Please sign in to comment.