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

Fixes for paywalls v2 renderer after testing some real life paywalls #4436

Merged
merged 5 commits into from
Nov 7, 2024

Conversation

joshdholtz
Copy link
Member

@joshdholtz joshdholtz commented Nov 1, 2024

Motivation

Fixes for paywall tester for Paywalls V2

Description

  • Added @frozen to all the enums to get rid of Swift 6 warnings
  • New FlexHStack to support horizontal distribution
  • Fixed a width bug with LazyVStack
    • LazyVStack is used to make rendering a bit snappier feeling but it has issues with width sometimes
    • It was behaving as maxWidth: .infinity so added some naive logic to only use LazyVStack if more than 3 children. Ideally this should look recursively down
  • Temporarily removed the error in the paywall if there are no packages (because it makes initial testing of paywall designs hard)
    • Could maybe only show a warning when in debug
  • Fixed a bunch of Codable things that were failing when testing real life paywalls

Demo

Blinkist HabitKit
Simulator Screenshot - iPhone 16 Pro - 2024-11-01 at 15 56 46 Simulator Screenshot - iPhone 16 Pro - 2024-11-01 at 17 46 22

@joshdholtz joshdholtz changed the title Fixes for paywall tester Fixes for paywalls v2 renderer after testing some real life paywalls Nov 1, 2024
@joshdholtz joshdholtz requested review from a team November 1, 2024 23:39
@joshdholtz joshdholtz marked this pull request as ready for review November 1, 2024 23:46
Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

Some questions but nothing blocking. Looking good!

@@ -18,10 +18,10 @@ import Foundation

public extension PaywallComponent {

enum Dimension: Codable, Sendable, Hashable {
@frozen enum Dimension: Codable, Sendable, Hashable {
Copy link
Contributor

Choose a reason for hiding this comment

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

I must say I'm not a big fan of this @frozen annotation... While it does make sense, it seems it might cause us some issues down the line. For this enum I don't foresee new values coming anytime soon but well... In any case, if this is the recommended approach, seems we just will need to be thinking forward a lot for these APIs.

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 will just remove them for now 😇

@@ -109,7 +109,7 @@ public extension PaywallComponent {

}

enum WidthSizeType: String, Codable, Sendable, Hashable, Equatable {
@frozen enum WidthSizeType: String, Codable, Sendable, Hashable, Equatable {
case fit, fill, fixed
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we allow something like fixedPercentage?

Copy link
Member Author

Choose a reason for hiding this comment

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

There has been A LOT of discussion about this 😅 We decided to leave this out (for now) but will probably introduce some type of "grid" component that has percentage like this in a more structured way

enum CodingKeys: String, CodingKey {
case type
case packageID = "packageId"
case isSelectedByDefault = "isDefaultSelected"
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm strange these are using camelCase instead of snake_case? Same below

Copy link
Member Author

@joshdholtz joshdholtz Nov 5, 2024

Choose a reason for hiding this comment

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

Codables are a bit weird here 😅

Keys will get deserialized from snake to camel automatically... however, packageID would get deserialized as package_i_d because of the ID both being capitals 🫠

Some of the other codables are values that we actually are expecting to be snake case as well but Codable only auto converts for keys (not values)

Copy link
Contributor

Choose a reason for hiding this comment

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

That's.... confusing 🥴. But yeah makes sense. Thanks for explaining!

Copy link
Member Author

Choose a reason for hiding this comment

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

It honestly is 😬 Maybe I should document this is all the place? Because it will be more than just me supporting this and I don't want to make anybody else think about Swift quirks 😛

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a quick comment could help yeah. Having said that, I think as long as the decoding behavior is well tested, this should be caught with tests

@joshdholtz joshdholtz merged commit 319fde3 into main Nov 7, 2024
7 checks passed
@joshdholtz joshdholtz deleted the fixes-for-paywall-tester branch November 7, 2024 15:07
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.

2 participants