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] Adds ImageComponentState and override functionality #2012

Merged
merged 129 commits into from
Jan 2, 2025

Conversation

JayShortway
Copy link
Member

Changes

  • Adds the ImageComponentState and,
  • fully hooks up the ImageComponentStyle to the StyleFactory,
  • including override functionality via the PresentedImagePartial.

# Conflicts:
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/LoadedPaywallComponents.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/LocalizedTextPartial.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/button/ButtonComponentView.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/ktx/Localization.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/stack/StackComponentView.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/style/StyleFactory.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/style/TextComponentStyle.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/text/TextComponentState.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/text/TextComponentView.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/helpers/Result.kt
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/BuildPresentedPartialTests.kt
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/LocalizedTextPartialTests.kt
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/ToPresentedOverridesTests.kt
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/button/ButtonComponentViewTests.kt
#	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/stack/StackComponentViewWindowTests.kt
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/style/StyleFactoryTests.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
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/helpers/FakePaywallState.kt
# Conflicts:
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/LoadedPaywallComponents.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/button/ButtonComponentView.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/stack/StackComponentView.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/text/TextComponentView.kt
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/helpers/NonEmptyMap.kt
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/helpers/ResultTests.kt
Comment on lines -69 to -87
private fun Size.adjustForImage(imageUrls: ImageUrls, density: Density): Size =
Size(
width = imageUrls.width?.let { imageWidthPx ->
when (width) {
is Fit -> Fixed(with(density) { imageWidthPx.toInt().toDp().value.toUInt() })
is Fill,
is Fixed,
-> width
}
} ?: width,
height = imageUrls.height?.let { imageHeightPx ->
when (height) {
is Fit -> Fixed(with(density) { imageHeightPx.toInt().toDp().value.toUInt() })
is Fill,
is Fixed,
-> height
}
} ?: height,
)
Copy link
Member Author

Choose a reason for hiding this comment

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

This was moved to ImageComponentState.

Copy link

codecov bot commented Dec 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.90%. Comparing base (7755855) to head (f8cdcee).

Additional details and impacted files
@@                     Coverage Diff                     @@
##           pw2-validate-loading-phase    #2012   +/-   ##
===========================================================
  Coverage                       81.90%   81.90%           
===========================================================
  Files                             260      260           
  Lines                            8516     8516           
  Branches                         1226     1226           
===========================================================
  Hits                             6975     6975           
  Misses                           1042     1042           
  Partials                          499      499           

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

Base automatically changed from pw2-validate-loading-phase to main December 30, 2024 11:47
Copy link

emerge-tools bot commented Dec 30, 2024

📸 Snapshot Test

125 unchanged

Name Added Removed Modified Unchanged Errored Approval
TestPurchasesUIAndroidCompatibility
com.revenuecat.testpurchasesuiandroidcompatibility
0 0 0 125 5 N/A

🛸 Powered by Emerge Tools

@JayShortway JayShortway merged commit 392ec67 into main Jan 2, 2025
10 checks passed
@JayShortway JayShortway deleted the pw2-image-state branch January 2, 2025 09:54
tonidero pushed a commit that referenced this pull request Jan 9, 2025
**This is an automatic release.**

## RevenueCat SDK
### 📦 Dependency Updates
* Updates the Play Billing Library to 7.1.1. (#2032) via JayShortway
(@JayShortway)

### 🔄 Other Changes
* [Paywalls V2] Fixes click consumption in text buttons (#2033) via
JayShortway (@JayShortway)
* [Paywalls V2] Handles gradient percentages in the 0..100 range (#2030)
via JayShortway (@JayShortway)
* [Paywalls V2] Add `Badge` property to StackComponent (#2003) via Toni
Rico (@tonidero)
* [Paywalls V2] Improves image previews (#2029) via JayShortway
(@JayShortway)
* Make `PurchasesError` `java.io.Serializable` (#2031) via Toni Rico
(@tonidero)
* [Paywalls V2] Fixes `ImageComponentView` size when axes are Fit and
Fixed (#2024) via JayShortway (@JayShortway)
* [Paywalls V2] Image backgrounds support `fit_mode` and `color_overlay`
(#2021) via JayShortway (@JayShortway)
* [Paywalls V2] Fixes various rendering issues (#2020) via JayShortway
(@JayShortway)
* [Paywalls V2] Fixes various deserialization issues (#2018) via
JayShortway (@JayShortway)
* [Paywalls V2] Simplifies validation of `PaywallComponentsData` (#2017)
via JayShortway (@JayShortway)
* [Paywalls V2] Moves click handling from `ButtonComponentStyle` to
`ButtonComponentView` (#2016) via JayShortway (@JayShortway)
* [Paywalls V2] Adds `PackageComponentView` (#2014) via JayShortway
(@JayShortway)
* [Paywalls V2] Adds `ImageComponentState` and override functionality
(#2012) 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