diff --git a/RevenueCatUI/Templates/V2/Components/Text/TextComponentView.swift b/RevenueCatUI/Templates/V2/Components/Text/TextComponentView.swift index f2153c7ec6..99df41d8a3 100644 --- a/RevenueCatUI/Templates/V2/Components/Text/TextComponentView.swift +++ b/RevenueCatUI/Templates/V2/Components/Text/TextComponentView.swift @@ -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( @@ -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 diff --git a/Sources/Networking/Responses/RevenueCatUI/PaywallComponentsData.swift b/Sources/Networking/Responses/RevenueCatUI/PaywallComponentsData.swift index 68fafdf357..40ecb791de 100644 --- a/Sources/Networking/Responses/RevenueCatUI/PaywallComponentsData.swift +++ b/Sources/Networking/Responses/RevenueCatUI/PaywallComponentsData.swift @@ -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"