[Paywalls] Tabs (multi-tier / toggle) component#4648
Conversation
1 build increased size
Paywalls 1.0 (1)
|
| Item | Install Size Change |
|---|---|
| DYLD.String Table | ⬆️ 176.1 kB |
| 📝 RevenueCatUI.TabsComponentViewModel.TabsComponentViewModel | ⬆️ 33.8 kB |
| Code Signature | ⬆️ 29.3 kB |
| 📝 RevenueCatUI.TabViewModel.TabViewModel | ⬆️ 25.7 kB |
| RevenueCatUI.StickyFooterComponentViewModel.StickyFooterComponent... | ⬇️ -15.9 kB |
🛸 Powered by Emerge Tools
Comment trigger: Size diff threshold of 100.00kB exceeded
| LoadedTabsComponentView( | ||
| viewModel: self.viewModel, | ||
| parentPackageContext: self.packageContext, | ||
| onDismiss: self.onDismiss | ||
| ) |
There was a problem hiding this comment.
Environment variables cannot be referenced in initializers so... I created LoadedTabsComponentView so that it would be passed self.packageContext since we need a the list of packages for creating a context for each tab/tier
| onChange: { context in | ||
| self.packageContext.update( | ||
| package: context.package, | ||
| variableContext: context.variableContext | ||
| ) | ||
| }, |
There was a problem hiding this comment.
Each tab will call back to the entire tabs when one of its package contexts is updated (so that the whole paywall knows which new package was selected)
| @State | ||
| private var tierPackageContexts: [PackageContext] |
There was a problem hiding this comment.
Keeps a separate PackageContext stored for each tab
| @StateObject | ||
| private var tabControlContext: TabControlContext |
There was a problem hiding this comment.
This stores the shared state of the tab control (buttons of toggle)
Each tab will use this when it comes across the TabControlComponent in its stack so it knows what to render and what the active tab state is
There was a problem hiding this comment.
Does this happen recursively? What if the TabControlComponent is not a direct child of TabComponent?
There was a problem hiding this comment.
Great question! The TabControlComponent could be in stack of stack of stack of stack and it will still find it since .environmentObjects get passed to the whole stack. So it it just needs to be within the tab somewhere
But the other way around... we will need to validate (on the backend) that TabControlComponent is always within a TabComponent somewhere (can't be outside) 😅
There was a problem hiding this comment.
Thanks! Happy that that's supported! 😄
ec9c328 to
d5bb741
Compare
JayShortway
left a comment
There was a problem hiding this comment.
Very awesome! Just some questions basically.
| @StateObject | ||
| private var tabControlContext: TabControlContext |
There was a problem hiding this comment.
Does this happen recursively? What if the TabControlComponent is not a direct child of TabComponent?
9dd6452 to
f889fc8
Compare
38b2d1e to
000e34d
Compare

Motivation
Allow a multi-tier paywall with tabs and toggle
Description
tabstabs_controltabs_control_buttontabs_control_toggleViewModelFactoryPackageCollectorwhen digging thetabsstackTabViewModelTabsComponentTabControlComponentTabControlButtonComponentTabControlToggleComponent