Skip to content

[Paywalls V2] Adds progress indicator to buttons#2198

Merged
JayShortway merged 9 commits into
mainfrom
pw2-button-progress
Feb 27, 2025
Merged

[Paywalls V2] Adds progress indicator to buttons#2198
JayShortway merged 9 commits into
mainfrom
pw2-button-progress

Conversation

@JayShortway

@JayShortway JayShortway commented Feb 26, 2025

Copy link
Copy Markdown
Member

This is the Android equivalent of RevenueCat/purchases-ios#4787.

Description

This adds a progress indicator to the ButtonComponentView. It calculates the indicator color in the same way as we do on iOS. I created a new GradientBrush intermediate type that allows for reading the gradient colors after the brush has been constructed. This is used to determine the progress indicator color when the StackComponentView has a gradient background.

I didn't want to add the logic to StackComponentView, as that one is big enough already, and my first attempt at doing so resulted in multiple layout issues. Also, ideally it is unaware of the progress indicator. Perhaps in the future, we can add a slot API to StackComponentView, but we're not there yet.

@emerge-tools

emerge-tools Bot commented Feb 26, 2025

Copy link
Copy Markdown

📸 Snapshot Test

4 modified, 2 added, 256 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
TestPurchasesUIAndroidCompatibility
com.revenuecat.testpurchasesuiandroidcompatibility
2 0 4 0 256 0 ✅ Approved

🛸 Powered by Emerge Tools

@codecov

codecov Bot commented Feb 26, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.54%. Comparing base (e5a416c) to head (4b8391d).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2198   +/-   ##
=======================================
  Coverage   80.54%   80.54%           
=======================================
  Files         277      277           
  Lines        9456     9456           
  Branches     1334     1334           
=======================================
  Hits         7616     7616           
  Misses       1280     1280           
  Partials      560      560           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JayShortway JayShortway requested review from a team February 26, 2025 14:04
@JayShortway JayShortway marked this pull request as ready for review February 26, 2025 14:04

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work on this! left some comments but I think it's looking good!

}
}

Layout(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm TBH, I do wonder if it makes more sense to just wrap the StackComponentView inside a Box and put the indicator on top and centered within the parent. I think that would be much simpler, even if it adds another composable, wdyt?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yea I tried that first, but I couldn't force the progress indicator to not be larger than the StackComponentView. That's why I added the narrow preview.

If the StackComponentView is less tall than the CircularProgressIndicator, the CircularProgressIndicator should shrink. I tried various combinations of IntrinsicSize and matchParentSize(), but none of that worked. The Box would always allow the CircularProgressIndicator to be as big as it wants. So that's why I resorted to a Layout, to have more control.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ahhh right... yeah I think that makes sense. Thanks for explaining! Might be worth leaving a comment just in case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point! Added: 4b8391d.

val progressIndicator: (@Composable () -> Unit)? by remember {
derivedStateOf {
if (isClickable) {
null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Haven't tested this but I'm wondering, if the button changes TO being clickable, this would change to not draw the indicator directly right? Does the animation look ok when the button stops loading?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yea you're right, and we don't even need to set it to null since it will be invisible anyways. Much cleaner as well: e61fa93.

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great job! 💪

}
}

Layout(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ahhh right... yeah I think that makes sense. Thanks for explaining! Might be worth leaving a comment just in case.

@JayShortway JayShortway merged commit a31c2a2 into main Feb 27, 2025
@JayShortway JayShortway deleted the pw2-button-progress branch February 27, 2025 12:50
tonidero added a commit that referenced this pull request Mar 6, 2025
**This is an automatic release.**

## RevenueCat SDK
### ✨ New Features
* Add `hasPaywall` property to `Offering` (#2212) via Antonio Pallares
(@ajpallares)
### 🐞 Bugfixes
* Fix empty options in NoActive subscriptions screen (#2168) via Cesar
de la Vega (@vegaro)

## RevenueCatUI SDK
### Customer Center
#### ✨ New Features
* Create `CustomerCenterListener` (#2199) via Cesar de la Vega (@vegaro)
#### 🐞 Bugfixes
* Reload Customer Center after a successful restore (#2203) via Cesar de
la Vega (@vegaro)
* Fixes CustomerCenter state not refreshing when reopening (#2202) via
Cesar de la Vega (@vegaro)

### 🔄 Other Changes
* Improves PaywallsTester multi-API-key support (#2218) via JayShortway
(@JayShortway)
* [EXTERNAL] Bump Emerge Gradle Plugin and Snaphsots version (#2211) via
@runningcode (#2217) via JayShortway (@JayShortway)
* [AUTOMATIC][Paywalls V2] Updates Compose previews of all templates
(#2207) via RevenueCat Git Bot (@RCGitBot)
* [Paywalls V2] Enables template previews again (#2215) via JayShortway
(@JayShortway)
* Adds support for switching between 2 API keys to PaywallsTester
(#2213) via JayShortway (@JayShortway)
* Adds a `LocalPreviewImageLoader` `CompositionLocal`. (#2201) via
JayShortway (@JayShortway)
* Logs from RevenueCatUI are now tagged with `[Purchases]` too. (#2206)
via JayShortway (@JayShortway)
* [Paywalls V2] Ignores template previews for now. (#2209) via
JayShortway (@JayShortway)
* [Paywalls V2] Some more template previews optimizations (#2208) via
JayShortway (@JayShortway)
* chore: Delete key from customer center survey event (#2204) via
Facundo Menzella (@facumenzella)
* [Paywalls V2] Extract ImageLoader to use a single one (#2146) via Toni
Rico (@tonidero)
* [Paywalls V2] Adds progress indicator to buttons (#2198) via
JayShortway (@JayShortway)
* Avoids triggering "unscheduled" workflows when triggering workflows
via the CircleCI API (#2200) via JayShortway (@JayShortway)
* [Paywalls V2] Adds a note on publishing to the missing paywall error.
(#2193) via JayShortway (@JayShortway)
* Adds X-Kotlin-Version header. (#2197) via JayShortway (@JayShortway)
* [Paywalls V2] Adds docs on ignored arguments for Paywalls V2 in more
places. (#2195) via JayShortway (@JayShortway)
* chore: Add backend integration test for events (#2189) via Facundo
Menzella (@facumenzella)
* [Paywalls V2] Adds CI job to update template previews (#2192) via
JayShortway (@JayShortway)

---------

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Co-authored-by: Cesar de la Vega <cesarvegaro@gmail.com>
Co-authored-by: Toni Rico <antonio.rico.diez@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.

3 participants