From 4536ebc5ba67e6c76eded9c34acb90cd104349e6 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Wed, 15 Jan 2025 16:52:45 -0600 Subject: [PATCH] Move masking after view sizing (#4675) --- .../V2/Components/Image/ImageComponentView.swift | 10 +++++----- .../Template1Preview.swift | 3 ++- RevenueCatUI/Templates/V2/ViewHelpers/Shape.swift | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/RevenueCatUI/Templates/V2/Components/Image/ImageComponentView.swift b/RevenueCatUI/Templates/V2/Components/Image/ImageComponentView.swift index 6c2ea7dfe7..244907335a 100644 --- a/RevenueCatUI/Templates/V2/Components/Image/ImageComponentView.swift +++ b/RevenueCatUI/Templates/V2/Components/Image/ImageComponentView.swift @@ -55,6 +55,11 @@ struct ImageComponentView: View { } .size(style.size) .clipped() + .shape(border: nil, + shape: style.shape) + .padding(style.padding) + // WIP: Add border still + .padding(style.margin) } } @@ -89,11 +94,6 @@ struct ImageComponentView: View { Color.clear.backgroundStyle(.color(colorOverlay)) ) }) - .shape(border: nil, - shape: style.shape) - .padding(style.padding) - // WIP: Add border still - .padding(style.margin) } } diff --git a/RevenueCatUI/Templates/V2/Previews/TemplateComponentsViewPreviews/Template1Preview.swift b/RevenueCatUI/Templates/V2/Previews/TemplateComponentsViewPreviews/Template1Preview.swift index 4f1950e338..be720b9b66 100644 --- a/RevenueCatUI/Templates/V2/Previews/TemplateComponentsViewPreviews/Template1Preview.swift +++ b/RevenueCatUI/Templates/V2/Previews/TemplateComponentsViewPreviews/Template1Preview.swift @@ -33,7 +33,8 @@ private enum Template1Preview { heicLowRes: catUrl ) ), - fitMode: .fit, + size: .init(width: .fill, height: .fixed(270)), + fitMode: .fill, maskShape: .convex ) diff --git a/RevenueCatUI/Templates/V2/ViewHelpers/Shape.swift b/RevenueCatUI/Templates/V2/ViewHelpers/Shape.swift index bc2337b300..c50fd923a9 100644 --- a/RevenueCatUI/Templates/V2/ViewHelpers/Shape.swift +++ b/RevenueCatUI/Templates/V2/ViewHelpers/Shape.swift @@ -263,7 +263,7 @@ private struct ConvexShape: Shape { private var curveHeight: CGFloat { // Calculate the curve height as a percentage of the view's height - max(0, size.height * curveHeightPercentage) + max(0, size.height * curveHeightPercentage) / 2 } }