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] Update Stack to handle property overrides #4476

Merged

Conversation

joshdholtz
Copy link
Member

@joshdholtz joshdholtz commented Nov 12, 2024

Motivation

Do what Stack version of #4417

Description

Stacks can now use overrides based on:

  • Intro offers
  • State
    • Selected
  • Conditions(size class)
    • Compact
    • Medium
    • Expanded

Bonus

Implements a new system for handling UI component state overrides based on different
presentation contexts (screen size, selection state, etc).

See #4477 for what this change looks like on when used on a new component (it was super clean when adding it to image)

Key changes:

  • New PresentedPartial protocol for component combining behavior/properties
  • Generic PresentedOverrides<T> struct to handle:
    • Intro offer overrides
    • Selection state overrides (selected/unselected)
    • Screen condition overrides (compact/medium/expanded)
  • Helper methods for building partials based on current state/condition
  • Conversion utilities to map between component types

The system follows a hierarchical override pattern where more specific states (like selection) take precedence over more general ones (like screen size). Screen conditions cascade (expanded includes medium + compact overrides).

@joshdholtz joshdholtz changed the title Paywalls v2/schema rework part 6 stack selection state [Paywalls V2] Update Stack to handle property overrides Nov 12, 2024
@joshdholtz joshdholtz marked this pull request as ready for review November 13, 2024 02:17
@joshdholtz joshdholtz requested review from a team November 13, 2024 02:20
// Without compositingGroup(), the shadow is applied to the stack's children as well.
view.compositingGroup().shadow(shadow: shadow)
}
.padding(viewModel.margin)
.padding(style.margin)
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this interact with line 75? Does it override it?

Copy link
Member Author

Choose a reason for hiding this comment

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

@vegaro This does look very unclear without context 😅 SwiftUI applies things on top of each other so...

  1. Line 75 adds padding to the view to make it bigger
  2. Line 78 adds background color (which is applied to the whole bigger view)
  3. This line (85) adds padding again (but without background color) so it acts as margin

@joshdholtz joshdholtz force-pushed the paywalls-v2/schema-rework-part-5-soft-decoding-error branch from 26cd38e to f16fa6e Compare November 13, 2024 12:23
Base automatically changed from paywalls-v2/schema-rework-part-5-soft-decoding-error to main November 13, 2024 12:52
@joshdholtz joshdholtz force-pushed the paywalls-v2/schema-rework-part-6-stack-selection-state branch from 9fc70a4 to 05ca788 Compare November 13, 2024 12:59
@joshdholtz joshdholtz merged commit 8b77154 into main Nov 13, 2024
7 checks passed
@joshdholtz joshdholtz deleted the paywalls-v2/schema-rework-part-6-stack-selection-state branch November 13, 2024 14:00
This was referenced Nov 13, 2024
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