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 V2] Accept number as font size for text #4654

Merged
merged 3 commits into from
Jan 13, 2025

Conversation

joshdholtz
Copy link
Member

Motivation

More flexability in font size

Description

Use CGFloat as fontSize on TextComponent but also back support FontSize for a while

Copy link
Contributor

@fire-at-will fire-at-will left a 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
Copy link
Contributor

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!

@joshdholtz joshdholtz merged commit 41147c0 into main Jan 13, 2025
10 checks passed
@joshdholtz joshdholtz deleted the paywalls-v2/text-component-font-size-in-numbers branch January 13, 2025 21:51
try container.encodeIfPresent(overrides, forKey: .overrides)

// Encode fontSize as CGFloat
try container.encode(fontSize, forKey: .fontSize)
Copy link
Member

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?

Comment on lines -40 to +39
fontSize: FontSize = .bodyM,
fontSize: CGFloat = 16,
Copy link
Member

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.

Copy link
Member Author

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 🫠

Copy link
Member

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.

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 think the font_size is technically required by the backend schema validation so hopefully you never run into that 😛

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.

4 participants