-
Notifications
You must be signed in to change notification settings - Fork 329
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] Tabs (multi-tier / toggle) component #4648
base: main
Are you sure you want to change the base?
Conversation
1 build increased size
Paywalls 1.0 (1)
|
Item | Install Size Change |
---|---|
DYLD.String Table | ⬆️ 146.1 kB |
📝 RevenueCatUI.TabsComponentViewModel.TabsComponentViewModel | ⬆️ 33.5 kB |
Code Signature | ⬆️ 28.1 kB |
📝 RevenueCatUI.TabViewModel.TabViewModel | ⬆️ 24.8 kB |
RevenueCatUI.StickyFooterComponentViewModel.StickyFooterComponent... | ⬇️ -15.4 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeps a separate PackageContext
stored for each tab
@StateObject | ||
private var tabControlContext: TabControlContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this happen recursively? What if the TabControlComponent
is not a direct child of TabComponent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) 😅
ec9c328
to
d5bb741
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very awesome! Just some questions basically.
RevenueCatUI/Templates/V2/Components/Tabs/TabControlToggleComponentView.swift
Show resolved
Hide resolved
@StateObject | ||
private var tabControlContext: TabControlContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this happen recursively? What if the TabControlComponent
is not a direct child of TabComponent
?
RevenueCatUI/Templates/V2/Previews/TemplateComponentsViewPreviews/Template5Preview.swift
Show resolved
Hide resolved
c0225db
to
2a109b7
Compare
Motivation
Allow a multi-tier paywall with tabs and toggle
Description
tabs
tabs_control
tabs_control_button
tabs_control_toggle
ViewModelFactory
PackageCollector
when digging thetabs
stackTabViewModel
TabsComponent
TabControlComponent
TabControlButtonComponent
TabControlToggleComponent