-
Notifications
You must be signed in to change notification settings - Fork 329
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
Conversation
1 build increased size
Paywalls 1.0 (1)
|
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 |
🛸 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( |
There was a problem hiding this comment.
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) } | ||
} | ||
|
There was a problem hiding this comment.
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 CGFloat
s anymore so we can just change the type of the properties.
e9c2afb
to
39bfe4e
Compare
@@ -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) |
There was a problem hiding this comment.
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.
0ae8ff7
to
6c7f787
Compare
6c7f787
to
1ee7c4c
Compare
@@ -90,10 +90,22 @@ struct ViewModelFactory { | |||
) | |||
} | |||
|
|||
let badgeViewModels = try component.badge?.stack.value.components.map { component in |
There was a problem hiding this comment.
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: {}) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.overlay( | ||
VStack(alignment: .leading) { | ||
VStack { | ||
ComponentsView(componentViewModels: badge.badgeViewModels, onDismiss: {}) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
This PR adds a
.stackBadge
modified toStacks
which is displayed in one of three ways: nested, edge_to_edge, or overlaid.Check emerge for snapshots for all examples e.g.: