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 paywall tester #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

lizard-boy
Copy link

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-android and hybrids

Motivation

Description

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR makes several key changes to the paywall components system, focusing on layout improvements and naming consistency:

  • Added new FlexHStack component with 6 distribution modes (start, center, end, spaceBetween, spaceAround, spaceEvenly) for flexible horizontal layouts
  • Introduced conditional VStack/LazyVStack usage based on child count (<3) to improve performance with many components
  • Fixed incorrect cornerRadius mapping where bottomRight incorrectly used bottomLeading value in StackComponentViewModel
  • Renamed font weights for consistency (ultraLight→extraLight, heavy→extraBold) and standardized snake_case raw values
  • Renamed property from componentsConfigs to componentsConfig throughout codebase for API consistency

The changes improve layout control and naming consistency while fixing some bugs, though performance concerns with VStack/LazyVStack are noted as not final.

17 file(s) reviewed, 13 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +49 to +51
ForEach(0..<componentViewModels.count, id: \.self) { index in
ComponentsView(componentViewModels: [self.componentViewModels[index]], onDismiss: self.onDismiss)
}
Copy link

Choose a reason for hiding this comment

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

logic: Using array index directly as id could cause issues if items change. Consider using a more stable identifier from PaywallComponentViewModel

Comment on lines +86 to +90
ForEach(0..<componentViewModels.count, id: \.self) { index in
Spacer()
ComponentsView(componentViewModels: [self.componentViewModels[index]], onDismiss: self.onDismiss)
}
Spacer()
Copy link

Choose a reason for hiding this comment

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

logic: spaceEvenly implementation places Spacer before first item, which differs from CSS flex justify-content: space-evenly. Should have equal space between all items

Comment on lines +40 to +41
// There are some horizontal sizing issues with using LazyVStack
// There are so performance issues with VStack with lots of children
Copy link

Choose a reason for hiding this comment

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

syntax: typo in comment: 'There are so performance issues' should be 'There are some performance issues'

// This is NOT a final implementation of this
// There are some horizontal sizing issues with using LazyVStack
// There are so performance issues with VStack with lots of children
if viewModel.shouldUseVStack {
Copy link

Choose a reason for hiding this comment

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

logic: using a hardcoded threshold of 3 items (from ViewModel) to switch between VStack and LazyVStack could cause performance issues with complex child views even with few items

Comment on lines +53 to +57
if viewModels.count < 3 {
return true
}
return false
case .horizontal, .zlayer:
Copy link

Choose a reason for hiding this comment

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

style: Simplify to return viewModels.count < 3 since both paths return a boolean

Comment on lines 53 to +55
let alignment = try container.decode(VerticalAlignment.self, forKey: .alignment)
self = .horizontal(alignment)
let distribution = try container.decode(FlexDistribution.self, forKey: .distribution)
self = .horizontal(alignment, distribution)
Copy link

Choose a reason for hiding this comment

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

logic: decoding will fail for existing horizontal dimensions that don't have distribution field - need migration strategy

Comment on lines 169 to 181
enum FontWeight: String, Codable, Sendable, Hashable, Equatable {

case ultraLight
case extraLight = "extra_light"
case thin
case light
case regular
case medium
case semibold
case bold
case heavy
case extraBold = "extra_bold"
case black

}
Copy link

Choose a reason for hiding this comment

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

logic: FontWeight case changes from ultraLight to extraLight and heavy to extraBold will break existing paywall configurations that use the old values

Comment on lines 99 to 101
case type
case text = "text_lid"
case text = "textLid"
case fontFamily
Copy link

Choose a reason for hiding this comment

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

logic: this change from text_lid to textLid will break deserialization of existing paywall data that uses the old key format. Need to either maintain backward compatibility or document migration steps

Comment on lines 142 to 147
.sheet(item: self.$presentedPaywall) { paywall in
#if PAYWALL_COMPONENTS
if let componentData = paywall.offering.paywallComponentsData {
// TODO: Get locale
TemplateComponentsView(
paywallComponentsData: componentData,
offering: paywall.offering,
onDismiss: { self.presentedPaywall = nil }
)
} else {
PaywallPresenter(offering: paywall.offering, mode: paywall.mode, introEligility: .eligible)
.onRestoreCompleted { _ in
self.presentedPaywall = nil
}
}
#else
PaywallPresenter(offering: paywall.offering, mode: paywall.mode, introEligility: .eligible)
.onRestoreCompleted { _ in
self.presentedPaywall = nil
}
#endif
}
Copy link

Choose a reason for hiding this comment

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

logic: Removing PAYWALL_COMPONENTS conditional breaks component-based paywall presentation. Should keep the conditional to support both standard and component-based paywalls.

Comment on lines +195 to +197
if name == "components" {
return "V2"
} else if let template = PaywallTemplate(rawValue: name) {
Copy link

Choose a reason for hiding this comment

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

style: Hardcoding 'V2' for components template name reduces clarity. Consider using a more descriptive constant or enum value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants