-
Notifications
You must be signed in to change notification settings - Fork 54
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 V2] Adds progress indicator to buttons #2198
Conversation
📸 Snapshot Test4 modified, 2 added, 256 unchanged
🛸 Powered by Emerge Tools |
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
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.
Nice work on this! left some comments but I think it's looking good!
...ain/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/button/ButtonComponentView.kt
Show resolved
Hide resolved
} | ||
} | ||
|
||
Layout( |
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.
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?
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.
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.
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.
Ahhh right... yeah I think that makes sense. Thanks for explaining! Might be worth leaving a comment just in case.
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.
Good point! Added: 4b8391d.
val progressIndicator: (@Composable () -> Unit)? by remember { | ||
derivedStateOf { | ||
if (isClickable) { | ||
null |
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.
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?
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.
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.
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 job! 💪
} | ||
} | ||
|
||
Layout( |
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.
Ahhh right... yeah I think that makes sense. Thanks for explaining! Might be worth leaving a comment just in case.
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 newGradientBrush
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 theStackComponentView
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 toStackComponentView
, but we're not there yet.