Skip to content

Add conditional visibility to ButtonComponent#6821

Merged
facumenzella merged 6 commits into
mainfrom
worktree-partitioned-moseying-cloud
May 20, 2026
Merged

Add conditional visibility to ButtonComponent#6821
facumenzella merged 6 commits into
mainfrom
worktree-partitioned-moseying-cloud

Conversation

@facumenzella

@facumenzella facumenzella commented May 19, 2026

Copy link
Copy Markdown
Member

Summary

Ports the button-conditional-visibility feature from Android to iOS. Buttons can now declare a visible field and an overrides array, allowing visibility to be toggled conditionally (e.g., hide a back button when a package is selected).

  • Adds visible: Bool? and overrides: ComponentOverrides<PartialButtonComponent>? to ButtonComponent
  • Adds PartialButtonComponent (mirrors Android's PresentedButtonPartial)
  • Adds PresentedPartial conformance and a visible(state:condition:...) method on ButtonComponentViewModel, resolving button-level overrides independently of the stack
  • Updates ButtonComponentView.isVisible to use button-level override resolution
  • Updates containsUnsupportedConditions() in PresentedPartials.swift to recurse into a button's own overrides
  • Threads discardRules and uiConfigProvider through ViewModelFactory into ButtonComponentViewModel

Test plan

  • ButtonComponentViewModelMappingTests — unit tests for visible(...) covering default visibility, visible: false, selected override hiding, and selected override not hiding when not selected
  • ToPresentedOverridesTests — two new cases: button with unsupported condition in its own overrides returns true; button with supported condition returns false
  • ButtonComponentViewTests — view-level rendering tests using UIHostingController confirming visible: false hides the button, visible: true shows it, and a .selected override with visible: false hides when componentViewState = .selected

🤖 Generated with Claude Code


Note

Medium Risk
Adds new serialized fields and override evaluation that can hide/show paywall buttons at runtime, which could unintentionally suppress navigation/restore actions if misconfigured. Changes are localized to Paywalls V2 button rendering/mapping and are covered by new unit and view tests.

Overview
Adds conditional visibility to Paywalls V2 buttons by extending PaywallComponent.ButtonComponent with visible plus overrides (via new PartialButtonComponent) and including these fields in coding/hash/equality.

Updates ButtonComponentViewModel/ButtonComponentView to evaluate button-level overrides (using UIConfigProvider + selection/eligibility/custom-variable context) and skip rendering when the resolved visibility is false; ViewModelFactory now threads uiConfigProvider and the global discardRules flag into the button view model, and unsupported-condition detection now also checks a button’s own overrides.

Adds coverage with new/expanded tests for visibility resolution and actual SwiftUI rendering (ButtonComponentViewTests), and registers the new test file in the Xcode project.

Reviewed by Cursor Bugbot for commit dfc94a7. Bugbot is set up for automated code reviews on this repo. Configure here.

Port Android's button-conditional-visibility feature: adds visible and
overrides fields to ButtonComponent and PartialButtonComponent, resolves
button-level overrides in ButtonComponentViewModel, and gates rendering
in ButtonComponentView on the result.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@vegaro vegaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

little nits. Good to go after testing it

Comment thread RevenueCatUI/Templates/V2/Components/Button/ButtonComponentView.swift Outdated
Comment thread RevenueCatUI/Templates/V2/Components/Button/ButtonComponentView.swift Outdated
…ody, add conditional-visibility previews

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@emerge-tools

emerge-tools Bot commented May 20, 2026

Copy link
Copy Markdown

📸 Snapshot Test

1 modified, 2 added, 266 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
RevenueCat
com.revenuecat.PaywallsTester
2 0 1 0 266 0 ✅ Approved

🛸 Powered by Emerge Tools

…e and hidden states

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@emerge-tools

emerge-tools Bot commented May 20, 2026

Copy link
Copy Markdown

4 builds increased size

Name Version Download Change Install Change Approval
RevenueCat
com.revenuecat.PaywallsTester
1.0 (1) 18.1 MB ⬆️ 34.1 kB (0.19%) 65.1 MB ⬆️ 175.6 kB (0.27%) N/A
BinarySizeTest
com.revenuecat.binary-size-test.local-source
1.0 (1) 4.1 MB ⬆️ 3.9 kB (0.1%) 12.4 MB ⬆️ 19.1 kB (0.16%) N/A
BinarySizeTest
com.revenuecat.binary-size-test.cocoapods
1.0 (1) 6.2 MB ⬆️ 7.9 kB (0.13%) 27.3 MB ⬆️ 35.8 kB (0.13%) ⏳ Needs approval
BinarySizeTest
com.revenuecat.binary-size-test.spm
1.0 (1) 4.2 MB ⬆️ 5.2 kB (0.12%) 10.8 MB ⬆️ 10.9 kB (0.1%) N/A

RevenueCat 1.0 (1)
com.revenuecat.PaywallsTester

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 175.6 kB (0.27%)
Total download size change: ⬆️ 34.1 kB (0.19%)

Largest size changes

Item Install Size Change
DYLD.String Table ⬆️ 73.9 kB
Code Signature ⬆️ 4.2 kB
DYLD.Exports ⬆️ 2.0 kB
📝 RevenueCat.PaywallComponent.PartialButtonComponent.PartialButtonC... ⬆️ 1.4 kB
RevenueCatUI.ButtonComponentViewModel.ButtonComponentViewModel ⬆️ 1.2 kB
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.local-source

⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 19.1 kB (0.16%)
Total download size change: ⬆️ 3.9 kB (0.1%)

Largest size changes

Item Install Size Change
RevenueCat.PaywallComponent.ButtonComponent.ButtonComponent ⬆️ 3.5 kB
RevenueCat.PaywallComponent.PackageComponent.PackageComponent ⬇️ -3.4 kB
📝 RevenueCatUI.ButtonComponentViewModel.init(component,localization... ⬆️ 3.1 kB
🗑 RevenueCatUI.ButtonComponentViewModel.init(component,localization... ⬇️ -2.4 kB
RevenueCatUI.ButtonComponentView.body ⬆️ 2.0 kB
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.cocoapods

⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 35.8 kB (0.13%)
Total download size change: ⬆️ 7.9 kB (0.13%)

Largest size changes

Item Install Size Change
DYLD.String Table ⬆️ 12.4 kB
RevenueCat.PaywallComponent.ButtonComponent.ButtonComponent ⬆️ 3.5 kB
RevenueCat.PaywallComponent.PackageComponent.PackageComponent ⬇️ -3.4 kB
DYLD.String Table ⬆️ 3.2 kB
📝 RevenueCatUI.ButtonComponentViewModel.init(component,localization... ⬆️ 3.1 kB
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.spm

⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 10.9 kB (0.1%)
Total download size change: ⬆️ 5.2 kB (0.12%)

Largest size changes

Item Install Size Change
RevenueCat.PaywallComponent.ButtonComponent.ButtonComponent ⬆️ 3.5 kB
RevenueCat.PaywallComponent.PackageComponent.PackageComponent ⬇️ -3.4 kB
📝 RevenueCatUI.ButtonComponentViewModel.init(component,localization... ⬆️ 3.1 kB
🗑 RevenueCatUI.ButtonComponentViewModel.init(component,localization... ⬇️ -2.4 kB
RevenueCatUI.ButtonComponentView.body ⬆️ 2.0 kB
View Treemap

Image of diff


🛸 Powered by Emerge Tools

Comment trigger: Size diff threshold of 100.00kB exceeded

…behavior adds no value

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@facumenzella facumenzella marked this pull request as ready for review May 20, 2026 17:01
@facumenzella facumenzella requested review from a team as code owners May 20, 2026 17:01
@facumenzella

Copy link
Copy Markdown
Member Author

Added some previews @vegaro !

@facumenzella facumenzella enabled auto-merge (squash) May 20, 2026 17:01
@facumenzella facumenzella merged commit ef1bf10 into main May 20, 2026
16 of 19 checks passed
@facumenzella facumenzella deleted the worktree-partitioned-moseying-cloud branch May 20, 2026 17:12
@facumenzella facumenzella added pr:fix A bug fix and removed pr:feat A new feature labels May 22, 2026
This was referenced May 22, 2026
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