Skip to content

Paywalls: Add PaywallFooterView#1509

Merged
vegaro merged 12 commits into
mainfrom
add-paywall-footer-view
Dec 5, 2023
Merged

Paywalls: Add PaywallFooterView#1509
vegaro merged 12 commits into
mainfrom
add-paywall-footer-view

Conversation

@tonidero

@tonidero tonidero commented Nov 30, 2023

Copy link
Copy Markdown
Contributor

Description

This adds a new view PaywallFooterView which acts as a wrapper for the PaywallFooter composable. It has some limitations:

  • Condensed form not supported
  • Need to set most of the attributes on the construction of the view.

This view will be used in the hybrids in order to support footer view.
image

import com.revenuecat.purchases.ui.revenuecatui.PaywallListener

@OptIn(ExperimentalPreviewRevenueCatUIPurchasesAPI::class)
class PaywallFooterViewActivity : AppCompatActivity() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right now I'm hardcoding the font, so we can test it

Comment thread examples/paywall-tester/src/main/res/layout/activity_paywall_footer_view.xml Outdated
options: PaywallOptions,
condensed: Boolean = false,
mainContent: @Composable (PaddingValues) -> Unit,
mainContent: @Composable ((PaddingValues) -> Unit)? = null,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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.

I am a bit confused about this change. When would someone not want to set something? This is a footer anywyas

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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?

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.

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) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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" />

@tonidero tonidero Nov 30, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@tonidero tonidero requested a review from a team November 30, 2023 19:05
@codecov

codecov Bot commented Nov 30, 2023

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3848f20) 84.50% compared to head (9fab167) 84.50%.
Report is 5 commits behind head on main.

❗ Current head 9fab167 differs from pull request most recent head 07cfe84. Consider uploading reports for the commit 07cfe84 to get more accurate results

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.
📢 Have feedback on the report? Share it here.

* 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)?) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@tonidero tonidero marked this pull request as ready for review December 1, 2023 09:56
…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"

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.

Why is this 0dp?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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,

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.

I am a bit confused about this change. When would someone not want to set something? This is a footer anywyas

tonidero and others added 2 commits December 5, 2023 17:51
### 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>
@vegaro vegaro enabled auto-merge (squash) December 5, 2023 17:42
@vegaro vegaro merged commit a6ee1c6 into main Dec 5, 2023
@vegaro vegaro deleted the add-paywall-footer-view branch December 5, 2023 17:47
vegaro pushed a commit that referenced this pull request Dec 5, 2023
**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>
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