-
Notifications
You must be signed in to change notification settings - Fork 105
PW-1178 | Support package-level visibility via visible property and overrides #3279
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
Merged
facumenzella
merged 13 commits into
main
from
facundo/pw-1178-package-visibility-android
Apr 9, 2026
+455
−8
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bff8935
feat: support package-level visibility via visible property and overr…
facumenzella 405a23f
fix: reconcile hidden package selection
facumenzella 5e06e96
Merge branch 'main' into facundo/pw-1178-package-visibility-android
facumenzella 5cba746
fix: use ComponentOverride import instead of inline FQN in PackageCom…
facumenzella 8c03721
Merge branch 'main' into facundo/pw-1178-package-visibility-android
facumenzella 427f96b
Merge branch 'main' into facundo/pw-1178-package-visibility-android
facumenzella a94791f
Merge branch 'main' into facundo/pw-1178-package-visibility-android
facumenzella f7289e2
refactor: rely on dashboard to prevent hidden default packages instea…
facumenzella a149e05
fix: revert accidental local dev changes from paywall-tester
facumenzella c99a314
refactor: remove visibility reconciliation — assume default package i…
facumenzella 7244363
chore: remove stale comment from StyleFactory per review
facumenzella 14736c6
Merge branch 'main' into facundo/pw-1178-package-visibility-android
facumenzella 0abf6ab
fix: PartialPackageComponent.visible defaults to null; remove self-hi…
facumenzella File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ain/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/PresentedPackagePartial.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.revenuecat.purchases.ui.revenuecatui.components | ||
|
|
||
| import com.revenuecat.purchases.paywalls.components.PartialPackageComponent | ||
| import com.revenuecat.purchases.ui.revenuecatui.errors.PaywallValidationError | ||
| import com.revenuecat.purchases.ui.revenuecatui.helpers.NonEmptyList | ||
| import com.revenuecat.purchases.ui.revenuecatui.helpers.Result | ||
| import dev.drewhamilton.poko.Poko | ||
|
|
||
| @Poko | ||
| internal class PresentedPackagePartial( | ||
| @get:JvmSynthetic val partial: PartialPackageComponent, | ||
| ) : PresentedPartial<PresentedPackagePartial> { | ||
|
|
||
| companion object { | ||
| @JvmSynthetic | ||
| operator fun invoke( | ||
| from: PartialPackageComponent, | ||
| ): Result<PresentedPackagePartial, NonEmptyList<PaywallValidationError>> = | ||
| Result.Success(PresentedPackagePartial(partial = from)) | ||
| } | ||
|
|
||
| override fun combine(with: PresentedPackagePartial?): PresentedPackagePartial { | ||
| val otherPartial = with?.partial | ||
| return PresentedPackagePartial( | ||
| partial = PartialPackageComponent( | ||
| visible = otherPartial?.visible ?: partial.visible, | ||
| ), | ||
| ) | ||
| } | ||
| } |
107 changes: 107 additions & 0 deletions
107
...n/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/pkg/PackageComponentState.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| @file:JvmSynthetic | ||
|
|
||
| package com.revenuecat.purchases.ui.revenuecatui.components.pkg | ||
|
|
||
| import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.Stable | ||
| import androidx.compose.runtime.derivedStateOf | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.window.core.layout.WindowWidthSizeClass | ||
| import com.revenuecat.purchases.ui.revenuecatui.CustomVariableValue | ||
| import com.revenuecat.purchases.ui.revenuecatui.components.ComponentViewState | ||
| import com.revenuecat.purchases.ui.revenuecatui.components.ConditionContext | ||
| import com.revenuecat.purchases.ui.revenuecatui.components.ScreenCondition | ||
| import com.revenuecat.purchases.ui.revenuecatui.components.buildPresentedPartial | ||
| import com.revenuecat.purchases.ui.revenuecatui.components.state.PackageAwareDelegate | ||
| import com.revenuecat.purchases.ui.revenuecatui.components.style.PackageComponentStyle | ||
| import com.revenuecat.purchases.ui.revenuecatui.composables.OfferEligibility | ||
| import com.revenuecat.purchases.ui.revenuecatui.data.PaywallState | ||
|
|
||
| @Stable | ||
| @JvmSynthetic | ||
| @Composable | ||
| internal fun rememberUpdatedPackageComponentState( | ||
| style: PackageComponentStyle, | ||
| paywallState: PaywallState.Loaded.Components, | ||
| ): PackageComponentState = rememberUpdatedPackageComponentState( | ||
| style = style, | ||
| selectedPackageInfoProvider = { paywallState.selectedPackageInfo }, | ||
| selectedTabIndexProvider = { paywallState.selectedTabIndex }, | ||
| selectedOfferEligibilityProvider = { paywallState.selectedOfferEligibility }, | ||
| customVariablesProvider = { paywallState.mergedCustomVariables }, | ||
| ) | ||
|
|
||
| @Suppress("LongParameterList") | ||
| @Stable | ||
| @JvmSynthetic | ||
| @Composable | ||
| private fun rememberUpdatedPackageComponentState( | ||
| style: PackageComponentStyle, | ||
| selectedPackageInfoProvider: () -> PaywallState.Loaded.Components.SelectedPackageInfo?, | ||
| selectedTabIndexProvider: () -> Int, | ||
| selectedOfferEligibilityProvider: () -> OfferEligibility, | ||
| customVariablesProvider: () -> Map<String, CustomVariableValue>, | ||
| ): PackageComponentState { | ||
| val windowSize = currentWindowAdaptiveInfo().windowSizeClass.windowWidthSizeClass | ||
|
|
||
| return remember(style) { | ||
| PackageComponentState( | ||
| initialWindowSize = windowSize, | ||
| style = style, | ||
| selectedPackageInfoProvider = selectedPackageInfoProvider, | ||
| selectedTabIndexProvider = selectedTabIndexProvider, | ||
| selectedOfferEligibilityProvider = selectedOfferEligibilityProvider, | ||
| customVariablesProvider = customVariablesProvider, | ||
| ) | ||
| }.apply { | ||
| update(windowSize = windowSize) | ||
| } | ||
| } | ||
|
|
||
| @Suppress("LongParameterList") | ||
| @Stable | ||
| internal class PackageComponentState( | ||
| initialWindowSize: WindowWidthSizeClass, | ||
| private val style: PackageComponentStyle, | ||
| private val selectedPackageInfoProvider: () -> PaywallState.Loaded.Components.SelectedPackageInfo?, | ||
| private val selectedTabIndexProvider: () -> Int, | ||
| private val selectedOfferEligibilityProvider: () -> OfferEligibility, | ||
| private val customVariablesProvider: () -> Map<String, CustomVariableValue> = { emptyMap() }, | ||
| ) { | ||
| private var windowSize by mutableStateOf(initialWindowSize) | ||
|
|
||
| private val packageAwareDelegate = PackageAwareDelegate( | ||
| style = style, | ||
| selectedPackageInfoProvider = selectedPackageInfoProvider, | ||
| selectedTabIndexProvider = selectedTabIndexProvider, | ||
| selectedOfferEligibilityProvider = selectedOfferEligibilityProvider, | ||
| ) | ||
|
|
||
| private val presentedPartial by derivedStateOf { | ||
| val windowCondition = ScreenCondition.from(windowSize) | ||
| val componentState = | ||
| if (packageAwareDelegate.isSelected) ComponentViewState.SELECTED else ComponentViewState.DEFAULT | ||
|
|
||
| style.overrides.buildPresentedPartial( | ||
| windowCondition, | ||
| packageAwareDelegate.offerEligibility, | ||
| componentState, | ||
| conditionContext = ConditionContext( | ||
| selectedPackageId = selectedPackageInfoProvider()?.rcPackage?.identifier, | ||
| customVariables = customVariablesProvider(), | ||
| ), | ||
| ) | ||
| } | ||
|
|
||
| @get:JvmSynthetic | ||
| val visible by derivedStateOf { presentedPartial?.partial?.visible ?: style.visible } | ||
|
|
||
| @JvmSynthetic | ||
| fun update(windowSize: WindowWidthSizeClass) { | ||
| this.windowSize = windowSize | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.