diff --git a/RevenueCatUI/Data/Constants.swift b/RevenueCatUI/Data/Constants.swift index 4c21bc5b62..a1031a0536 100644 --- a/RevenueCatUI/Data/Constants.swift +++ b/RevenueCatUI/Data/Constants.swift @@ -13,4 +13,7 @@ enum Constants { static let defaultAnimation: Animation = .easeIn(duration: 0.2) static let fastAnimation: Animation = .easeIn(duration: 0.1) + /// For UI elements that wouldn't make sense to keep scaling up forever + static let maximumDynamicTypeSize: DynamicTypeSize = .accessibility3 + } diff --git a/RevenueCatUI/Views/FooterView.swift b/RevenueCatUI/Views/FooterView.swift index bd3e6d23b3..6540955007 100644 --- a/RevenueCatUI/Views/FooterView.swift +++ b/RevenueCatUI/Views/FooterView.swift @@ -13,8 +13,16 @@ struct FooterView: View { var configuration: PaywallData.Configuration var color: Color + var bold: Bool var purchaseHandler: PurchaseHandler + init(configuration: PaywallData.Configuration, color: Color, bold: Bool = true, purchaseHandler: PurchaseHandler) { + self.configuration = configuration + self.color = color + self.bold = bold + self.purchaseHandler = purchaseHandler + } + var body: some View { HStack { if self.configuration.displayRestorePurchases { @@ -42,22 +50,42 @@ struct FooterView: View { } } .foregroundColor(self.color) - .font(.caption.bold()) + .font(Self.font.weight(self.fontWeight)) .padding(.horizontal) .padding(.bottom, 5) + .dynamicTypeSize(...Constants.maximumDynamicTypeSize) } private var separator: some View { - Image(systemName: "circle.fill") - .font(.system(size: 5)) - .accessibilityHidden(true) + SeparatorView(bold: self.bold) } private var hasTOS: Bool { self.configuration.termsOfServiceURL != nil } private var hasPrivacy: Bool { self.configuration.privacyURL != nil } + private var fontWeight: Font.Weight { self.bold ? .bold : .regular } + + private static let font: Font = .caption } +@available(iOS 16.0, macOS 13.0, tvOS 16.0, *) +private struct SeparatorView: View { + + var bold: Bool + + var body: some View { + Image(systemName: "circle.fill") + .font(.system(size: self.bold ? self.boldSeparatorSize : self.separatorSize)) + .accessibilityHidden(true) + } + + @ScaledMetric(relativeTo: .caption) + private var separatorSize: CGFloat = 4 + + @ScaledMetric(relativeTo: .caption) + private var boldSeparatorSize: CGFloat = 5 +} + @available(iOS 16.0, macOS 13.0, tvOS 16.0, *) private struct RestorePurchasesButton: View { @@ -154,12 +182,21 @@ struct Footer_Previews: PreviewProvider { privacyURL: URL(string: "https://revenuecat.com/tos")! ) .previewDisplayName("All") + + Self.create( + displayRestorePurchases: true, + termsOfServiceURL: URL(string: "https://revenuecat.com/tos")!, + privacyURL: URL(string: "https://revenuecat.com/tos")!, + bold: false + ) + .previewDisplayName("Not bold") } private static func create( displayRestorePurchases: Bool = true, termsOfServiceURL: URL? = nil, - privacyURL: URL? = nil + privacyURL: URL? = nil, + bold: Bool = true ) -> some View { FooterView( configuration: .init( @@ -171,6 +208,7 @@ struct Footer_Previews: PreviewProvider { privacyURL: privacyURL ), color: TestData.colors.text1Color, + bold: bold, purchaseHandler: PreviewHelpers.purchaseHandler ) } diff --git a/RevenueCatUI/Views/PurchaseButton.swift b/RevenueCatUI/Views/PurchaseButton.swift index 97d156d03c..a9e9569f7a 100644 --- a/RevenueCatUI/Views/PurchaseButton.swift +++ b/RevenueCatUI/Views/PurchaseButton.swift @@ -53,11 +53,9 @@ struct PurchaseButton: View { .controlSize(self.mode.buttonSize) .buttonStyle(.borderedProminent) .frame(maxWidth: .infinity) - .dynamicTypeSize(...Self.maximumDynamicTypeSize) + .dynamicTypeSize(...Constants.maximumDynamicTypeSize) } - private static let maximumDynamicTypeSize: DynamicTypeSize = .accessibility3 - } @available(iOS 16.0, macOS 13.0, tvOS 16.0, *) diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testDarkMode.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testDarkMode.1.png index b24ead26ff..8259b94836 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testDarkMode.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testDarkMode.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testPurchasingState.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testPurchasingState.1.png index c05d8f0d95..a872087ca9 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testPurchasingState.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testPurchasingState.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testSamplePaywall.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testSamplePaywall.1.png index 8096f78e9a..6adf4186fe 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testSamplePaywall.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/MultiPackageBoldPaywallViewTests/iOS16-testSamplePaywall.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testDarkMode.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testDarkMode.1.png index abd8466bca..27746649d5 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testDarkMode.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testDarkMode.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywall.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywall.1.png index 0d4b31f7c3..55f9bc8c81 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywall.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywall.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithIneligibleIntroOffer.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithIneligibleIntroOffer.1.png index 170bf63565..cb318dec96 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithIneligibleIntroOffer.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithIneligibleIntroOffer.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithIntroOffer.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithIntroOffer.1.png index 6acff796a4..e3a67b0bee 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithIntroOffer.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithIntroOffer.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithLoadingEligibility.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithLoadingEligibility.1.png index 53adf866cd..068c47f533 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithLoadingEligibility.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageStandardPaywallViewTests/iOS16-testSamplePaywallWithLoadingEligibility.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageWithFeaturesPaywallViewTests/iOS16-testSamplePaywall.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageWithFeaturesPaywallViewTests/iOS16-testSamplePaywall.1.png index 0a30e2564d..7680bc20e4 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageWithFeaturesPaywallViewTests/iOS16-testSamplePaywall.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/OnePackageWithFeaturesPaywallViewTests/iOS16-testSamplePaywall.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultDarkModePaywall.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultDarkModePaywall.1.png index 0647a899ce..a3b4d3a3ed 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultDarkModePaywall.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultDarkModePaywall.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultPaywall.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultPaywall.1.png index 05d274e483..2de25cfeb1 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultPaywall.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultPaywall.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility1.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility1.1.png index 4e16912f7d..7cc0a5dfff 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility1.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility1.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility3.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility3.1.png index 391c211a4b..08ea1fca46 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility3.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility3.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility5.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility5.1.png index c178716524..948eaa5ae6 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility5.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testAccessibility5.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testLarge.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testLarge.1.png index d2bbdd4da2..85bfa6d824 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testLarge.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testLarge.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testMedium.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testMedium.1.png index 1ca792e84b..2b3bfe8c73 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testMedium.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testMedium.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testSmall.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testSmall.1.png index fa09ae4386..92350df89e 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testSmall.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testSmall.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXLarge.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXLarge.1.png index d2bbdd4da2..85bfa6d824 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXLarge.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXLarge.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXSmall.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXSmall.1.png index 7b3651ddab..357941b054 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXSmall.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXSmall.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXXLarge.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXXLarge.1.png index 90a72a44cd..5e739560a8 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXXLarge.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXXLarge.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXXXLarge.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXXXLarge.1.png index da54e2e4f0..4e4e2fb17e 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXXXLarge.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewDynamicTypeTests/iOS16-testXXXLarge.1.png differ diff --git a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewLocalizationTests/iOS16-testSpanish.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewLocalizationTests/iOS16-testSpanish.1.png index 43e5d9e1e0..dd93a0a178 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewLocalizationTests/iOS16-testSpanish.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/PaywallViewLocalizationTests/iOS16-testSpanish.1.png differ