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] StackComponentView handles overrides with StackComponentState #1993

Merged
merged 83 commits into from
Dec 23, 2024

Conversation

JayShortway
Copy link
Member

Description

This PR is analogous to #1989, and the motivation behind it is the same.

  • Introduces StackComponentState.
  • StackComponentView uses StackComponentState.
  • StyleFactory is simplified further.
  • Adds StackComponentViewWindowTests.
  • Adds 2 tests to StackComponentViewTests.

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.95%. Comparing base (1221849) to head (bf27e45).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1993   +/-   ##
=======================================
  Coverage   81.95%   81.95%           
=======================================
  Files         260      260           
  Lines        8507     8507           
  Branches     1226     1226           
=======================================
  Hits         6972     6972           
  Misses       1036     1036           
  Partials      499      499           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}

@get:JvmSynthetic
val visible by derivedStateOf { presentedPartial?.partial?.visible ?: true }
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this default to the style visibility? I don't know if this is something controllable from the dashboard but seems like a better default IMO?

Suggested change
val visible by derivedStateOf { presentedPartial?.partial?.visible ?: true }
val visible by derivedStateOf { presentedPartial?.partial?.visible ?: style.visible }

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 good that you mention it! This made me realize that *ComponentStyles don't need a visible property anymore. I removed them from StackComponentStyle and TextComponentStyle here: bf27e45. Will need to do the same once ImageComponentStyle gets an accompanying ImageComponentState.

The reason for this is that a component is always visible, except when a PresentedPartial override tells it it's not. This is to support scenarios where a developer wants to hide a component for a certain window size, for instance. That's why only the PresentedPartial overrides have a visible property, and when that's not set the component is visible.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 makes sense! Yeah I didn't think it made much sense to control the visibility from the dashboard like that. This makes more sense!

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.

LGTM!

Base automatically changed from pw2-component-state to main December 19, 2024 11:46
# Conflicts:
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/text/TextComponentViewWindowTests.kt
# Conflicts:
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/stack/StackComponentViewTests.kt
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/text/TextComponentViewTests.kt
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/text/TextComponentViewWindowTests.kt
@JayShortway JayShortway enabled auto-merge (squash) December 23, 2024 14:13
@JayShortway JayShortway merged commit 29e69a8 into main Dec 23, 2024
10 checks passed
@JayShortway JayShortway deleted the pw2-stack-component-state branch December 23, 2024 14:35
tonidero pushed a commit that referenced this pull request Jan 2, 2025
**This is an automatic release.**

## RevenueCat SDK
### 🐞 Bugfixes
* improvements for fr translations (#2019) via Andy Boedo (@aboedo)

### 🔄 Other Changes
* Feedback Surveys (#2010) via Cesar de la Vega (@vegaro)
* [Paywalls V2] Fixes previews (#2015) via JayShortway (@JayShortway)
* [Paywalls V2] Moves validation logic to the Loading phase (#2007) via
JayShortway (@JayShortway)
* Add Cancel subscriptions support (#2008) via Cesar de la Vega
(@vegaro)
* [Paywalls V2] Localizations are kept in a NonEmptyMap (#2001) via
JayShortway (@JayShortway)
* [Paywalls V2] `TextComponentState` handles locale changes (#2000) via
JayShortway (@JayShortway)
* [Paywalls V2] Some minor cleanup (#1994) via JayShortway
(@JayShortway)
* [Paywalls V2] `StackComponentView` handles overrides with
`StackComponentState` (#1993) via JayShortway (@JayShortway)
* Customer Center restores [CC-2] (#1999) via Cesar de la Vega (@vegaro)
* [Paywalls V2] Add more image component previews to test parent being
smaller than image size (#2004) via Toni Rico (@tonidero)
* [Paywalls V2] Add `PurchaseButtonComponent` support (#2002) via Toni
Rico (@tonidero)
* Build Customer Center from JSON (#1998) via Cesar de la Vega (@vegaro)
* Fix missing import after PR merge conflict (#1997) via Toni Rico
(@tonidero)
* [Paywalls V2] Add `StickyFooterComponentView` (#1991) via Toni Rico
(@tonidero)
* [Paywalls V2] `TextComponentView` handles overrides with
`TextComponentState` (#1989) via JayShortway (@JayShortway)

Co-authored-by: revenuecat-ops <[email protected]>
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