Add conditional visibility to ButtonComponent#6821
Conversation
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
left a comment
There was a problem hiding this comment.
little nits. Good to go after testing it
…ody, add conditional-visibility previews Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📸 Snapshot Test1 modified, 2 added, 266 unchanged
🛸 Powered by Emerge Tools |
…e and hidden states Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4 builds increased size
RevenueCat 1.0 (1)
|
| 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 |
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 |
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 |
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 |
🛸 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>
|
Added some previews @vegaro ! |




Summary
Ports the
button-conditional-visibilityfeature from Android to iOS. Buttons can now declare avisiblefield and anoverridesarray, allowing visibility to be toggled conditionally (e.g., hide a back button when a package is selected).visible: Bool?andoverrides: ComponentOverrides<PartialButtonComponent>?toButtonComponentPartialButtonComponent(mirrors Android'sPresentedButtonPartial)PresentedPartialconformance and avisible(state:condition:...)method onButtonComponentViewModel, resolving button-level overrides independently of the stackButtonComponentView.isVisibleto use button-level override resolutioncontainsUnsupportedConditions()inPresentedPartials.swiftto recurse into a button's own overridesdiscardRulesanduiConfigProviderthroughViewModelFactoryintoButtonComponentViewModelTest plan
ButtonComponentViewModelMappingTests— unit tests forvisible(...)covering default visibility,visible: false, selected override hiding, and selected override not hiding when not selectedToPresentedOverridesTests— two new cases: button with unsupported condition in its own overrides returnstrue; button with supported condition returnsfalseButtonComponentViewTests— view-level rendering tests usingUIHostingControllerconfirmingvisible: falsehides the button,visible: trueshows it, and a.selectedoverride withvisible: falsehides whencomponentViewState = .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.ButtonComponentwithvisibleplusoverrides(via newPartialButtonComponent) and including these fields in coding/hash/equality.Updates
ButtonComponentViewModel/ButtonComponentViewto evaluate button-level overrides (usingUIConfigProvider+ selection/eligibility/custom-variable context) and skip rendering when the resolved visibility is false;ViewModelFactorynow threadsuiConfigProviderand the globaldiscardRulesflag 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.