diff --git a/RevenueCatUI/Templates/MultiPackageBoldTemplate.swift b/RevenueCatUI/Templates/MultiPackageBoldTemplate.swift index e473544095..c9f7636d2e 100644 --- a/RevenueCatUI/Templates/MultiPackageBoldTemplate.swift +++ b/RevenueCatUI/Templates/MultiPackageBoldTemplate.swift @@ -40,8 +40,6 @@ struct MultiPackageBoldTemplate: TemplateViewType { @ViewBuilder var content: some View { VStack(spacing: 10) { - self.iconImage - self.scrollableContent .scrollableIfNecessary() @@ -64,6 +62,10 @@ struct MultiPackageBoldTemplate: TemplateViewType { VStack { Spacer() + self.iconImage + + Spacer() + Text(self.selectedLocalization.title) .foregroundColor(self.configuration.colors.text1Color) .font(.largeTitle.bold()) @@ -98,29 +100,12 @@ struct MultiPackageBoldTemplate: TemplateViewType { .buttonStyle(PackageButtonStyle(isSelected: isSelected)) } } - .padding(.bottom) } @ViewBuilder private func packageButton(_ package: TemplateViewConfiguration.Package, selected: Bool) -> some View { - let alignment: Alignment = .leading - - VStack(alignment: alignment.horizontal, spacing: 5) { - HStack { - Image(systemName: "checkmark.circle.fill") - .hidden(if: !selected) - .overlay { - if selected { - EmptyView() - } else { - Circle() - .foregroundColor(self.selectedBackgroundColor.opacity(0.5)) - } - } - - Text(self.localization(for: package.content).offerName ?? package.content.productName) - } - .foregroundColor(self.configuration.colors.accent1Color) + VStack(alignment: Self.packageButtonAlignment.horizontal, spacing: 5) { + self.packageButtonTitle(package, selected: selected) IntroEligibilityStateView( textWithNoIntroOffer: package.localization.offerDetails, @@ -129,7 +114,7 @@ struct MultiPackageBoldTemplate: TemplateViewType { foregroundColor: selected ? self.configuration.colors.backgroundColor : self.configuration.colors.text1Color, - alignment: alignment + alignment: Self.packageButtonAlignment ) .fixedSize(horizontal: false, vertical: true) .font(.body) @@ -137,7 +122,7 @@ struct MultiPackageBoldTemplate: TemplateViewType { .font(.body.weight(.medium)) .padding() .multilineTextAlignment(.leading) - .frame(maxWidth: .infinity, alignment: alignment) + .frame(maxWidth: .infinity, alignment: Self.packageButtonAlignment) .overlay { if selected { EmptyView() @@ -156,6 +141,31 @@ struct MultiPackageBoldTemplate: TemplateViewType { } } + private func packageButtonTitle( + _ package: TemplateViewConfiguration.Package, + selected: Bool + ) -> some View { + HStack { + Image(systemName: "checkmark.circle.fill") + .hidden(if: !selected) + .overlay { + if selected { + EmptyView() + } else { + Circle() + .foregroundColor(self.selectedBackgroundColor.opacity(0.5)) + } + } + + Text(self.localization(for: package.content).offerName ?? package.content.productName) + } + .foregroundColor( + selected + ? self.configuration.colors.accent1Color + : self.configuration.colors.text1Color + ) + } + private var subscribeButton: some View { PurchaseButton( package: self.selectedPackage, @@ -177,9 +187,6 @@ struct MultiPackageBoldTemplate: TemplateViewType { } else { RemoteImage(url: url) } - } else { - DebugErrorView("Template configuration is missing background URL", - releaseBehavior: .emptyView) } } @@ -187,7 +194,7 @@ struct MultiPackageBoldTemplate: TemplateViewType { private var iconImage: some View { Group { if let url = self.configuration.iconImageURL { - RemoteImage(url: url, aspectRatio: 1, maxWidth: Self.iconSize) + RemoteImage(url: url, aspectRatio: 1, maxWidth: self.iconSize) .clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous)) } else { // Placeholder to be able to add a consistent padding @@ -206,8 +213,10 @@ struct MultiPackageBoldTemplate: TemplateViewType { private var selectedBackgroundColor: Color { self.configuration.colors.accent2Color } - private static let iconSize: CGFloat = 100 + @ScaledMetric(relativeTo: .largeTitle) + private var iconSize: CGFloat = 140 private static let cornerRadius: CGFloat = 15 + private static let packageButtonAlignment: Alignment = .leading } diff --git a/RevenueCatUI/Templates/OnePackageStandardTemplate.swift b/RevenueCatUI/Templates/OnePackageStandardTemplate.swift index 41a98b6913..eb74ee8a59 100644 --- a/RevenueCatUI/Templates/OnePackageStandardTemplate.swift +++ b/RevenueCatUI/Templates/OnePackageStandardTemplate.swift @@ -19,33 +19,11 @@ struct OnePackageStandardTemplate: TemplateViewType { var body: some View { VStack(spacing: self.configuration.mode.verticalSpacing) { - VStack(spacing: self.configuration.mode.verticalSpacing) { - self.headerImage - - Group { - Text(verbatim: self.localization.title) - .font(self.configuration.mode.titleFont) - .fontWeight(.heavy) - .padding( - self.configuration.mode.displaySubtitle - ? .bottom - : [] - ) - - if self.configuration.mode.displaySubtitle, let subtitle = self.localization.subtitle { - Text(verbatim: subtitle) - .font(self.configuration.mode.subtitleFont) - } - } - .padding(.horizontal) - } - .foregroundColor(self.configuration.colors.text1Color) - .multilineTextAlignment(.center) - .scrollable(if: self.configuration.mode.isFullScreen) - .scrollContentBackground(.hidden) - .scrollBounceBehaviorBasedOnSize() - .scrollIndicators(.automatic) - .edgesIgnoringSafeArea(self.configuration.mode.isFullScreen ? .top : []) + self.scrollableContent + .scrollableIfNecessary() + .scrollContentBackground(.hidden) + .scrollBounceBehaviorBasedOnSize() + .scrollIndicators(.automatic) if case .fullScreen = self.configuration.mode { Spacer() @@ -58,6 +36,7 @@ struct OnePackageStandardTemplate: TemplateViewType { foregroundColor: self.configuration.colors.text1Color ) .font(self.configuration.mode.offerDetailsFont) + .multilineTextAlignment(.center) self.button .padding(.horizontal) @@ -70,6 +49,37 @@ struct OnePackageStandardTemplate: TemplateViewType { } } + @ViewBuilder + private var scrollableContent: some View { + VStack(spacing: self.configuration.mode.verticalSpacing) { + self.headerImage + + Spacer() + + Group { + Text(verbatim: self.localization.title) + .font(self.configuration.mode.titleFont) + .fontWeight(.heavy) + .padding( + self.configuration.mode.displaySubtitle + ? .bottom + : [] + ) + + if self.configuration.mode.displaySubtitle, let subtitle = self.localization.subtitle { + Text(verbatim: subtitle) + .font(self.configuration.mode.subtitleFont) + } + } + .padding(.horizontal, 20) + + Spacer() + } + .foregroundColor(self.configuration.colors.text1Color) + .multilineTextAlignment(.center) + .edgesIgnoringSafeArea(self.configuration.mode.isFullScreen ? .top : []) + } + @ViewBuilder private var asyncImage: some View { if let headerImage = self.configuration.headerImageURL { @@ -86,7 +96,7 @@ struct OnePackageStandardTemplate: TemplateViewType { self.asyncImage .clipShape( Circle() - .offset(y: -140) + .offset(y: -120) .scale(3.0) ) .padding(.bottom) diff --git a/RevenueCatUI/Views/PurchaseButton.swift b/RevenueCatUI/Views/PurchaseButton.swift index 32b91bfe97..97d156d03c 100644 --- a/RevenueCatUI/Views/PurchaseButton.swift +++ b/RevenueCatUI/Views/PurchaseButton.swift @@ -53,8 +53,11 @@ struct PurchaseButton: View { .controlSize(self.mode.buttonSize) .buttonStyle(.borderedProminent) .frame(maxWidth: .infinity) + .dynamicTypeSize(...Self.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 ea3970ee88..b24ead26ff 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 db5844fe9d..c05d8f0d95 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 4759e65ec7..8096f78e9a 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 6c9710f5f3..edff0e186d 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 62c1e46f8f..cdff6e2fe1 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 e63424e087..bfd884548a 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 a4e7b27f54..1bf01bee0e 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 ee4c27f20e..9c01d5d2f6 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__/OtherPaywallViewTests/iOS16-testDefaultDarkModePaywall.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testDefaultDarkModePaywall.1.png index b4460cf682..0647a899ce 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 f29beedfa0..05d274e483 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__/OtherPaywallViewTests/iOS16-testLoadingPaywallView.1.png b/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testLoadingPaywallView.1.png index 433c615d7f..c5faf66b1d 100644 Binary files a/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testLoadingPaywallView.1.png and b/Tests/RevenueCatUITests/Templates/__Snapshots__/OtherPaywallViewTests/iOS16-testLoadingPaywallView.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 57e7c73275..bccfb0707a 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 29213c5718..45f8e76c2d 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 1317a8ab44..1f14b15a4f 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 ffb0a882a6..51842ff091 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 db323229a3..9e69c7465c 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 9bcf125daf..73e4ed4dc4 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 ffb0a882a6..51842ff091 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 0d68ce4a2d..6d57eec544 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 e313fc1d36..0aae79d949 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 862c5c3213..80c34345b1 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 a16f8a753d..43e5d9e1e0 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