-
Notifications
You must be signed in to change notification settings - Fork 338
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 V2] Accept number as font size for text #4654
[Paywalls V2] Accept number as font size for text #4654
Conversation
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.
Looks good! 🚀
@@ -114,7 +114,7 @@ struct TextComponentView_Previews: PreviewProvider { | |||
component: .init( | |||
text: "id_1", | |||
color: .init(light: .hex("#000000")), | |||
fontSize: .headingXXL | |||
fontSize: 40 |
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.
Nit: It'd be nice if all of these could be hardcoded somewhere, like using the PaywallComponent.FontSize.size
property defined further down in the PR, but since these are just previews, it's probably okay!
try container.encodeIfPresent(overrides, forKey: .overrides) | ||
|
||
// Encode fontSize as CGFloat | ||
try container.encode(fontSize, forKey: .fontSize) |
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 know I'm late but (perhaps for a future PR), since this implementation of encode(to:)
is the same the default implementation of Encondable
, I think we can remove it. Or am I missing something?
fontSize: FontSize = .bodyM, | ||
fontSize: CGFloat = 16, |
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.
@joshdholtz I noticed .bodyM
is 15
, but you're setting the default value to 16
here. Why? Just checking as I'm doing this for Android now.
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.
Oh, this default in the constructor is really just used for the SwiftUI preview so it doesn't super matter 🤷♂️ I wasn't sure what it mapped to so I just picked something 🫠
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.
Ah okay, thanks for explaining! In Android's case the default would be used when the JSON doesn't contain a font_size
, so I'll keep it at 15
then.
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 think the font_size
is technically required by the backend schema validation so hopefully you never run into that 😛
Motivation
More flexability in font size
Description
Use
CGFloat
asfontSize
onTextComponent
but also back supportFontSize
for a while