Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paywalls: improved FooterView #3171

Merged
merged 7 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions RevenueCatUI/Data/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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 {
return 24
Expand Down
1 change: 1 addition & 0 deletions RevenueCatUI/Templates/Template1View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct Template1View: TemplateViewType {
.font(self.font(for: .callout))
.multilineTextAlignment(.center)
.defaultHorizontalPadding()
.padding(.top, self.defaultVerticalPaddingLength)

self.button
.defaultHorizontalPadding()
Expand Down
3 changes: 2 additions & 1 deletion RevenueCatUI/Templates/Template2View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -122,7 +123,7 @@ struct Template2View: TemplateViewType {
.buttonStyle(PackageButtonStyle(isSelected: isSelected))
}
}
.padding([.horizontal, .top], self.defaultHorizontalPaddingLength)
.padding(.horizontal, self.defaultHorizontalPaddingLength)

Spacer()
}
Expand Down
1 change: 0 additions & 1 deletion RevenueCatUI/Templates/Template3View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ struct Template3View: TemplateViewType {
introEligibility: self.introEligibility,
purchaseHandler: self.purchaseHandler
)
.padding(.bottom)
charliemchapman marked this conversation as resolved.
Show resolved Hide resolved

FooterView(configuration: self.configuration,
purchaseHandler: self.purchaseHandler)
Expand Down
13 changes: 8 additions & 5 deletions RevenueCatUI/Views/FooterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct FooterView: View {

init(
configuration: TemplateViewConfiguration,
bold: Bool = true,
bold: Bool = false,
purchaseHandler: PurchaseHandler,
displayingAllPlans: Binding<Bool>? = nil
) {
Expand All @@ -49,7 +49,7 @@ struct FooterView: View {
mode: PaywallViewMode,
fonts: PaywallFontProvider,
color: Color,
bold: Bool = true,
bold: Bool = false,
purchaseHandler: PurchaseHandler,
displayingAllPlans: Binding<Bool>?
) {
Expand Down Expand Up @@ -117,6 +117,7 @@ struct FooterView: View {
} label: {
Text("All subscriptions", bundle: .module)
}
.frame(minHeight: Constants.minimumButtonHeight)
}

private var separator: some View {
Expand All @@ -134,7 +135,7 @@ struct FooterView: View {
fileprivate var font: Font.TextStyle {
return self.interfaceIdiom == .pad
? .callout
: .caption
: .footnote
}

}
Expand All @@ -150,10 +151,10 @@ private struct SeparatorView: View {
.accessibilityHidden(true)
}

@ScaledMetric(relativeTo: .caption)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh thanks 👏🏻
Unfortunately this can't use a common constant so it has to be hardcoded again.

@ScaledMetric(relativeTo: .footnote)
private var separatorSize: CGFloat = 4

@ScaledMetric(relativeTo: .caption)
@ScaledMetric(relativeTo: .footnote)
private var boldSeparatorSize: CGFloat = 5
}

Expand All @@ -179,6 +180,7 @@ private struct RestorePurchasesButton: View {
Text("Restore purchases", bundle: .module)
}
}
.frame(minHeight: Constants.minimumButtonHeight)
.buttonStyle(.plain)
.alert(isPresented: self.$displayRestoredAlert) {
Alert(title: Text("Purchases restored successfully!", bundle: .module))
Expand Down Expand Up @@ -224,6 +226,7 @@ private struct LinkButton: View {
),
destination: self.url
)
.frame(minHeight: Constants.minimumButtonHeight)
}

}
Expand Down
2 changes: 1 addition & 1 deletion Tests/purchases-ios-snapshots-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
82d84e2e241db3853e487cb8718a22d112dfba8f
58e1e2b348e67f180562a49541247d0f0796050e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charliemchapman updated :)