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] Add Badge Modifier #4596

Merged
merged 6 commits into from
Jan 13, 2025
Merged

[Paywalls] Add Badge Modifier #4596

merged 6 commits into from
Jan 13, 2025

Conversation

MarkVillacampa
Copy link
Member

@MarkVillacampa MarkVillacampa commented Dec 16, 2024

This PR adds a .stackBadge modified to Stacks which is displayed in one of three ways: nested, edge_to_edge, or overlaid.

Check emerge for snapshots for all examples e.g.:

image

Copy link

emerge-tools bot commented Dec 16, 2024

1 build increased size

Name Version Download Change Install Change Approval
Paywalls
com.revenuecat.PaywallsTester
1.0 (1) 11.1 MB ⬆️ 102.8 kB (0.94%) 41.3 MB ⬆️ 369.5 kB (0.91%) N/A

Paywalls 1.0 (1)
com.revenuecat.PaywallsTester

⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 369.5 kB (0.91%)
Total download size change: ⬆️ 102.8 kB (0.94%)

Largest size changes

Item Install Size Change
DYLD.String Table ⬆️ 126.0 kB
Code Signature ⬆️ 9.0 kB
RevenueCat.OfferingsFactory.OfferingsFactory ⬆️ 3.8 kB
DYLD.Exports ⬆️ 3.5 kB
RevenueCatUI.StackComponentViewModel.StackComponentViewModel ⬆️ 3.1 kB
View Treemap

Image of diff


🛸 Powered by Emerge Tools

Comment trigger: Size diff threshold of 100.00kB exceeded

) throws {
self.component = component
self.viewModels = viewModels

if let badge = component.badge {
badgeTextViewModel = try TextComponentViewModel(
Copy link
Member Author

Choose a reason for hiding this comment

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

Initialising the TextComponentViewModel of the badge in the StackComponentViewModel constructor so we can throw if necessary.

self.bottomLeft = bottomLeft.flatMap { CGFloat($0) }
self.bottomRight = bottomRight.flatMap { CGFloat($0) }
}

Copy link
Member Author

@MarkVillacampa MarkVillacampa Dec 16, 2024

Choose a reason for hiding this comment

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

It seems we're not using CGFloats anymore so we can just change the type of the properties.

Base automatically changed from fix-borders to main December 16, 2024 18:49
@@ -128,6 +151,7 @@ struct StackComponentStyle {
self.shape = shape?.shape
self.border = border?.border
self.shadow = shadow?.shadow
self.badge = badge?.badge(stackShape: self.shape)
Copy link
Member Author

Choose a reason for hiding this comment

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

The stack shape is only used to calculate the the corner radius of the edge-to-edge leading/trailing style badge, and make it match the parent stack.

@@ -90,10 +90,22 @@ struct ViewModelFactory {
)
}

let badgeViewModels = try component.badge?.stack.value.components.map { component in
Copy link
Member Author

Choose a reason for hiding this comment

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

Deserialising the badge view models here just like we do with the stack children models right above.

self.overlay(
VStack(alignment: .leading) {
VStack {
ComponentsView(componentViewModels: badge.badgeViewModels, onDismiss: {})
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not entirely sure we need to pass the onDismiss block here? I assume it is only used for the NavigateBack action button and would only make sense if we want to include buttons in the children elements here?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah yeah, this if fine 😅

@MarkVillacampa MarkVillacampa changed the title [Do not merge][Paywalls] Add Badge Modifier [Paywalls] Add Badge Modifier Jan 13, 2025
@joshdholtz joshdholtz requested review from a team January 13, 2025 17:04
Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

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

:shipit: :shipit: :shipit: :shipit: :shipit: :shipit:

self.overlay(
VStack(alignment: .leading) {
VStack {
ComponentsView(componentViewModels: badge.badgeViewModels, onDismiss: {})
Copy link
Member

Choose a reason for hiding this comment

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

Yeah yeah, this if fine 😅

switch badge.stack.value.shape {
case .pill, .none:
// Edge-to-edge badge cannot have pill shape
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this makes sense, we were trying to support these in Android, but probably good to keep it simple for now... cc @JayShortway

@joshdholtz joshdholtz merged commit 3665900 into main Jan 13, 2025
10 checks passed
@joshdholtz joshdholtz deleted the badge-component branch January 13, 2025 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants