Paywalls: Add PaywallFooterView#1509
Conversation
| import com.revenuecat.purchases.ui.revenuecatui.PaywallListener | ||
|
|
||
| @OptIn(ExperimentalPreviewRevenueCatUIPurchasesAPI::class) | ||
| class PaywallFooterViewActivity : AppCompatActivity() { |
There was a problem hiding this comment.
Note that it's not needed to use an activity, but this was the easier way to get out from the compose world we use in the MainActivity.
| <com.revenuecat.purchases.ui.revenuecatui.fragment.PaywallFooterView | ||
| android:id="@+id/paywall_footer_view" | ||
| android:background="@android:color/holo_blue_light" | ||
| android:fontFamily="@font/lobster_two" |
There was a problem hiding this comment.
Right now I'm hardcoding the font, so we can test it
| options: PaywallOptions, | ||
| condensed: Boolean = false, | ||
| mainContent: @Composable (PaddingValues) -> Unit, | ||
| mainContent: @Composable ((PaddingValues) -> Unit)? = null, |
There was a problem hiding this comment.
This shouldn't be a breaking change, since we're only relaxing the restriction here. I do wonder if this will be confusing and some users will not pass this parameter and try to organize the screen themselves in compose... It should still be fine, but it's probably easier for them to pass us the content there so we can organize it.
There was a problem hiding this comment.
I am a bit confused about this change. When would someone not want to set something? This is a footer anywyas
There was a problem hiding this comment.
Right... The main reason for this change was that the Column composable inside has a fillMaxSize modifier, which we don't want when we want to render only the footer view. In native android, we probably want people to pass us a composable, but when using the PaywallFooterView, we can't easily pass composables as a parameter to the view (most people using the view are probably not using compose).
An alternative to this would be to add a parameter, useMaxSize or something like that that tells us whether this composable should use all available space. I kinda didn't want to add another parameter if possible, but it might be less error prone than making the content nullable... wdyt?
There was a problem hiding this comment.
Hmm, I see... I am seeing now that mainContent is a confusing parameter. It makes it feel as if it's the content of the Footer, and not whatever is behind the Footer
I am honestly leaning towards creating two views, the current PaywallFooter should be something like PaywallFooterWithScreenContent and a new PaywallFooter shouldn't paint anything else and not accept a mainContent
We can discuss this in our weekly sync I think
| ), | ||
| ) | ||
| } | ||
| if (mainContent == null) { |
There was a problem hiding this comment.
So if we get some composables as a parameter, we will actually take the whole space. If not, we will just use the space needed for the footer.
| <resources> | ||
| <declare-styleable name="PaywallFooterView"> | ||
| <attr name="android:fontFamily" /> | ||
| <attr name="offeringIdentifier" format="string" /> |
There was a problem hiding this comment.
These are the parameters that can be passed from the xml. This is limited, some of them can only be passed accessing the view programmatically, like the listener.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1509 +/- ##
=======================================
Coverage 84.50% 84.50%
=======================================
Files 218 218
Lines 7211 7211
Branches 1004 1004
=======================================
Hits 6094 6094
Misses 729 729
Partials 388 388 ☔ View full report in Codecov by Sentry. |
…ter view and main content using negative margins
| * Sets a dismiss handler which will be called when the user successfully purchases or if there is an error | ||
| * loading the offerings and the user clicks through the error dialog. | ||
| */ | ||
| fun setDismissHandler(dismissHandler: (() -> Unit)?) { |
There was a problem hiding this comment.
I wondered whether to remove this for the footer view, since there is already a purchase completed listener in the PaywallListener. But there can still be an error loading the offerings and we show an error dialog in that case, In that case, we want to dismiss it, and this would be the only way to do it.
…venuecatui/views/PaywallFooterView.kt Co-authored-by: Cesar de la Vega <cesarvegaro@gmail.com>
| android:background="@android:color/holo_blue_light" | ||
| android:layout_weight="1" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="0dp" |
There was a problem hiding this comment.
If you set the layout_weight parameter, you usually need to set one of the dimensions with 0dp so it can grow from that dimension. This is basically telling it to use all the available space after removing the size of other sibling views that don't use layout_weight.
| options: PaywallOptions, | ||
| condensed: Boolean = false, | ||
| mainContent: @Composable (PaddingValues) -> Unit, | ||
| mainContent: @Composable ((PaddingValues) -> Unit)? = null, |
There was a problem hiding this comment.
I am a bit confused about this change. When would someone not want to set something? This is a footer anywyas
### Description Followup to #1509 This adds a `condensed` parameter to the `PaywallFooterView`. This can be set either through the constructor or as an XML parameter.
### Description Full screen counterpart to #1509. This adds a new view `PaywallView` which wraps the `Paywall` composable so it's usable in the view system. The view will be used in the hybrids. --------- Co-authored-by: Cesar de la Vega <cesarvegaro@gmail.com>
**This is an automatic release.** ### RevenueCatUI * Paywalls: Add `PaywallFooterView` (#1509) via Toni Rico (@tonidero) * Paywalls: Remove `PaywallActivity` theme to pickup application's theme by default (#1511) via Toni Rico (@tonidero) * Paywalls: Auto-close paywall activity if restore grants required entitlement identifier (#1507) via Toni Rico (@tonidero) ### Bugfixes * Improve pricePerYear price calculation precision (#1515) via Toni Rico (@tonidero) * Improve price per month accuracy for weekly subscriptions (#1504) via Andy Boedo (@aboedo) ### Dependency Updates * Bump danger from 9.4.0 to 9.4.1 (#1512) via dependabot[bot] (@dependabot[bot]) ### Other Changes * Remove unnecessary appInBackground parameters (#1508) via Cesar de la Vega (@vegaro) * Create `PurchasesStateProvider` (#1502) via Cesar de la Vega (@vegaro) Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Description
This adds a new view
PaywallFooterViewwhich acts as a wrapper for thePaywallFootercomposable. It has some limitations:This view will be used in the hybrids in order to support footer view.
