From aeb88195a6a47bb507c8ea10097de8fc53a53e81 Mon Sep 17 00:00:00 2001 From: Charlie Chapman Date: Fri, 8 Sep 2023 09:39:16 -0500 Subject: [PATCH 1/7] gave the footer view buttons a minimum height of 44px to match HIG and updated template layouts to account for the change --- RevenueCatUI/Templates/Template1View.swift | 1 + RevenueCatUI/Templates/Template2View.swift | 3 ++- RevenueCatUI/Templates/Template3View.swift | 1 - RevenueCatUI/Views/FooterView.swift | 5 +++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/RevenueCatUI/Templates/Template1View.swift b/RevenueCatUI/Templates/Template1View.swift index e9002f747c..4b09ab1ceb 100644 --- a/RevenueCatUI/Templates/Template1View.swift +++ b/RevenueCatUI/Templates/Template1View.swift @@ -51,6 +51,7 @@ struct Template1View: TemplateViewType { .font(self.font(for: .callout)) .multilineTextAlignment(.center) .defaultHorizontalPadding() + .padding(.top, self.defaultVerticalPaddingLength) self.button .defaultHorizontalPadding() diff --git a/RevenueCatUI/Templates/Template2View.swift b/RevenueCatUI/Templates/Template2View.swift index 4700c76062..5a903468ae 100644 --- a/RevenueCatUI/Templates/Template2View.swift +++ b/RevenueCatUI/Templates/Template2View.swift @@ -71,6 +71,7 @@ struct Template2View: TemplateViewType { .animation(Constants.fastAnimation, value: self.selectedPackage) .multilineTextAlignment(.center) .frame(maxHeight: .infinity) + .padding(.top, self.defaultVerticalPaddingLength) } private var scrollableContent: some View { @@ -122,7 +123,7 @@ struct Template2View: TemplateViewType { .buttonStyle(PackageButtonStyle(isSelected: isSelected)) } } - .padding([.horizontal, .top], self.defaultHorizontalPaddingLength) + .padding(.horizontal, self.defaultHorizontalPaddingLength) Spacer() } diff --git a/RevenueCatUI/Templates/Template3View.swift b/RevenueCatUI/Templates/Template3View.swift index 7769676cd3..1b49eb8860 100644 --- a/RevenueCatUI/Templates/Template3View.swift +++ b/RevenueCatUI/Templates/Template3View.swift @@ -76,7 +76,6 @@ struct Template3View: TemplateViewType { introEligibility: self.introEligibility, purchaseHandler: self.purchaseHandler ) - .padding(.bottom) FooterView(configuration: self.configuration, purchaseHandler: self.purchaseHandler) diff --git a/RevenueCatUI/Views/FooterView.swift b/RevenueCatUI/Views/FooterView.swift index 443c6c7618..177f04a19d 100644 --- a/RevenueCatUI/Views/FooterView.swift +++ b/RevenueCatUI/Views/FooterView.swift @@ -27,6 +27,8 @@ struct FooterView: View { var boldPreferred: Bool var purchaseHandler: PurchaseHandler var displayingAllPlans: Binding? + + static let buttonMinHeight: CGFloat = 44 init( configuration: TemplateViewConfiguration, @@ -117,6 +119,7 @@ struct FooterView: View { } label: { Text("All subscriptions", bundle: .module) } + .frame(minHeight: FooterView.buttonMinHeight) } private var separator: some View { @@ -179,6 +182,7 @@ private struct RestorePurchasesButton: View { Text("Restore purchases", bundle: .module) } } + .frame(minHeight: FooterView.buttonMinHeight) .buttonStyle(.plain) .alert(isPresented: self.$displayRestoredAlert) { Alert(title: Text("Purchases restored successfully!", bundle: .module)) @@ -224,6 +228,7 @@ private struct LinkButton: View { ), destination: self.url ) + .frame(minHeight: FooterView.buttonMinHeight) } } From 5833f62f81b027caaaf51fe7bdfc69e45e6ace31 Mon Sep 17 00:00:00 2001 From: Charlie Chapman Date: Fri, 8 Sep 2023 10:11:57 -0500 Subject: [PATCH 2/7] making linter happy by removing whitespace --- RevenueCatUI/Views/FooterView.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/RevenueCatUI/Views/FooterView.swift b/RevenueCatUI/Views/FooterView.swift index 177f04a19d..96102fb12b 100644 --- a/RevenueCatUI/Views/FooterView.swift +++ b/RevenueCatUI/Views/FooterView.swift @@ -27,7 +27,6 @@ struct FooterView: View { var boldPreferred: Bool var purchaseHandler: PurchaseHandler var displayingAllPlans: Binding? - static let buttonMinHeight: CGFloat = 44 init( @@ -230,7 +229,6 @@ private struct LinkButton: View { ) .frame(minHeight: FooterView.buttonMinHeight) } - } // MARK: - Previews From dc637d96f28376cbea676668110e0b0edc8174ee Mon Sep 17 00:00:00 2001 From: Charlie Chapman Date: Fri, 8 Sep 2023 13:28:00 -0500 Subject: [PATCH 3/7] Moved minimumButtonHeight to constants --- RevenueCatUI/Data/Constants.swift | 7 +++++++ RevenueCatUI/Views/FooterView.swift | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/RevenueCatUI/Data/Constants.swift b/RevenueCatUI/Data/Constants.swift index 9f6241d901..0a59fbade4 100644 --- a/RevenueCatUI/Data/Constants.swift +++ b/RevenueCatUI/Data/Constants.swift @@ -26,6 +26,13 @@ enum Constants { /// For UI elements that wouldn't make sense to keep scaling up forever static let maximumDynamicTypeSize: DynamicTypeSize = .accessibility3 + + /// See https://developer.apple.com/design/human-interface-guidelines/buttons#Best-practices + #if swift(>=5.9) && os(visionOS) + static let minimumButtonHeight: CGFloat = 60 + #else + static let minimumButtonHeight: CGFloat = 44 + #endif static func defaultHorizontalPaddingLength(_ idiom: UserInterfaceIdiom) -> CGFloat? { if idiom == .pad { diff --git a/RevenueCatUI/Views/FooterView.swift b/RevenueCatUI/Views/FooterView.swift index 96102fb12b..4a17b05271 100644 --- a/RevenueCatUI/Views/FooterView.swift +++ b/RevenueCatUI/Views/FooterView.swift @@ -27,7 +27,6 @@ struct FooterView: View { var boldPreferred: Bool var purchaseHandler: PurchaseHandler var displayingAllPlans: Binding? - static let buttonMinHeight: CGFloat = 44 init( configuration: TemplateViewConfiguration, @@ -118,7 +117,7 @@ struct FooterView: View { } label: { Text("All subscriptions", bundle: .module) } - .frame(minHeight: FooterView.buttonMinHeight) + .frame(minHeight: Constants.minimumButtonHeight) } private var separator: some View { @@ -181,7 +180,7 @@ private struct RestorePurchasesButton: View { Text("Restore purchases", bundle: .module) } } - .frame(minHeight: FooterView.buttonMinHeight) + .frame(minHeight: Constants.minimumButtonHeight) .buttonStyle(.plain) .alert(isPresented: self.$displayRestoredAlert) { Alert(title: Text("Purchases restored successfully!", bundle: .module)) @@ -227,7 +226,7 @@ private struct LinkButton: View { ), destination: self.url ) - .frame(minHeight: FooterView.buttonMinHeight) + .frame(minHeight: Constants.minimumButtonHeight) } } From d2fd257e14c791c1ba0de6457ade16968ac87bce Mon Sep 17 00:00:00 2001 From: Charlie Chapman Date: Fri, 8 Sep 2023 13:30:02 -0500 Subject: [PATCH 4/7] Switched footer view small buttons to not be bold by default --- RevenueCatUI/Views/FooterView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RevenueCatUI/Views/FooterView.swift b/RevenueCatUI/Views/FooterView.swift index 4a17b05271..b946ad7202 100644 --- a/RevenueCatUI/Views/FooterView.swift +++ b/RevenueCatUI/Views/FooterView.swift @@ -30,7 +30,7 @@ struct FooterView: View { init( configuration: TemplateViewConfiguration, - bold: Bool = true, + bold: Bool = false, purchaseHandler: PurchaseHandler, displayingAllPlans: Binding? = nil ) { @@ -49,7 +49,7 @@ struct FooterView: View { mode: PaywallViewMode, fonts: PaywallFontProvider, color: Color, - bold: Bool = true, + bold: Bool = false, purchaseHandler: PurchaseHandler, displayingAllPlans: Binding? ) { From ee371f885d20bea5a61ffff19aa70ff3c240c3e1 Mon Sep 17 00:00:00 2001 From: Charlie Chapman Date: Fri, 8 Sep 2023 13:34:02 -0500 Subject: [PATCH 5/7] Switched footer view small buttons to use footnote size instead of caption when not in the pad medium --- RevenueCatUI/Views/FooterView.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RevenueCatUI/Views/FooterView.swift b/RevenueCatUI/Views/FooterView.swift index b946ad7202..99cf76af33 100644 --- a/RevenueCatUI/Views/FooterView.swift +++ b/RevenueCatUI/Views/FooterView.swift @@ -135,7 +135,7 @@ struct FooterView: View { fileprivate var font: Font.TextStyle { return self.interfaceIdiom == .pad ? .callout - : .caption + : .footnote } } @@ -151,10 +151,10 @@ private struct SeparatorView: View { .accessibilityHidden(true) } - @ScaledMetric(relativeTo: .caption) + @ScaledMetric(relativeTo: .footnote) private var separatorSize: CGFloat = 4 - @ScaledMetric(relativeTo: .caption) + @ScaledMetric(relativeTo: .footnote) private var boldSeparatorSize: CGFloat = 5 } From b40a7b92a1158cf329c481b1b518fa3199433bf7 Mon Sep 17 00:00:00 2001 From: Charlie Chapman Date: Fri, 8 Sep 2023 13:38:10 -0500 Subject: [PATCH 6/7] SwiftLint autocorrect --- RevenueCatUI/Data/Constants.swift | 2 +- RevenueCatUI/Views/FooterView.swift | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/RevenueCatUI/Data/Constants.swift b/RevenueCatUI/Data/Constants.swift index 0a59fbade4..d138e67ba3 100644 --- a/RevenueCatUI/Data/Constants.swift +++ b/RevenueCatUI/Data/Constants.swift @@ -26,7 +26,7 @@ enum Constants { /// For UI elements that wouldn't make sense to keep scaling up forever static let maximumDynamicTypeSize: DynamicTypeSize = .accessibility3 - + /// See https://developer.apple.com/design/human-interface-guidelines/buttons#Best-practices #if swift(>=5.9) && os(visionOS) static let minimumButtonHeight: CGFloat = 60 diff --git a/RevenueCatUI/Views/FooterView.swift b/RevenueCatUI/Views/FooterView.swift index 99cf76af33..c7d1448f19 100644 --- a/RevenueCatUI/Views/FooterView.swift +++ b/RevenueCatUI/Views/FooterView.swift @@ -228,6 +228,7 @@ private struct LinkButton: View { ) .frame(minHeight: Constants.minimumButtonHeight) } + } // MARK: - Previews From 8a7ba1d6223e2d8de20d8a2cac0c5366b3073228 Mon Sep 17 00:00:00 2001 From: NachoSoto Date: Fri, 8 Sep 2023 12:31:57 -0700 Subject: [PATCH 7/7] Updated snapshots --- Tests/purchases-ios-snapshots-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/purchases-ios-snapshots-commit b/Tests/purchases-ios-snapshots-commit index 40d239abd5..0dfdef0836 100644 --- a/Tests/purchases-ios-snapshots-commit +++ b/Tests/purchases-ios-snapshots-commit @@ -1 +1 @@ -82d84e2e241db3853e487cb8718a22d112dfba8f +58e1e2b348e67f180562a49541247d0f0796050e