Skip to content
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: new PaywallIcon #1274

Merged
merged 3 commits into from
Sep 21, 2023

Conversation

NachoSoto
Copy link
Contributor

Screenshot 2023-09-20 at 13 53 59

@NachoSoto NachoSoto requested a review from a team September 20, 2023 20:54
@NachoSoto NachoSoto changed the title Paywalls : new PaywallIcon Paywalls: new PaywallIcon Sep 20, 2023
@NachoSoto NachoSoto force-pushed the nacho/pwl-266-ability-to-render-svg-icons branch from 6b521bd to fbd5ad0 Compare September 20, 2023 21:47
Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

Left some comments but nothing blocking. I would suggest removing the strings for the enum if it's possible though, to avoid repetition there.

/**
* An icon that can be displayed inside a RevenueCat paywall.
*/
enum class PaywallIconName(val value: String) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be internal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to expose this for https://linear.app/revenuecat/issue/PWL-194/icons /cc @vegaro
So we can iterate through the icons inside of features and verify that they're all valid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm still not clear to me... Are we performing the validation in the purchases module? If so, should we move this to the purchases module as well and make it public there? If we make it internal here, we can still perform the validation in this module I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I read your first comment as "private", I keep forgetting that Kotlin's default is public and not internal like in Swift.

TRANSFER("transfer"),
TWO_WAY_ARROWS("two_way_arrows"),
KEY("key"),
WARNING("warning"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the strings always match the enum but uppercased right? If so, we could just remove the string value and in the fromValue, we can do PaywallIconName.valueOf(value.uppercased()) I think. Or create a map from the lowercased strings to the enums as well, to avoid linear lookup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me check 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


@Preview(showBackground = true, widthDp = 300)
@Composable
internal fun PaywallIconPreview() {
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

modifier = Modifier
.aspectRatio(1.0f)
.fillMaxSize()
.then(modifier),
Copy link
Contributor

Choose a reason for hiding this comment

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

So this would apply the modifiers in the modifier parameter AFTER the aspectRation/fillMaxSize modifiers. That might be ok depending on the usage. Most times, when there is a modifier parameter, I've seen it used instead of the Modifier name, so this would look like:

        modifier = modifier
            .aspectRatio(1.0f)
            .fillMaxSize(),

But again, this might be correct if we need to apply the modifiers in the parameters last.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I don't think there's a right answer, but I was thinking that this way you can override the aspect ratio, etc. if needed.

LazyVerticalGrid(columns = GridCells.Adaptive(40.dp)) {
items(icons.size) {
Box(modifier = Modifier.background(randomColor())) {
PaywallIcon(icon = icons[it], tintColor = Color.Black)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess there is a chance the background color is also black? I guess it's probably not a big deal though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure 😅 it's just a way to make them easier to see in a grid.

@NachoSoto NachoSoto force-pushed the nacho/pwl-266-ability-to-render-svg-icons branch from fbd5ad0 to 7b3cbb2 Compare September 21, 2023 15:02
@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (a794347) 85.46% compared to head (f84c3bc) 85.46%.
Report is 6 commits behind head on paywalls.

Additional details and impacted files
@@            Coverage Diff            @@
##           paywalls    #1274   +/-   ##
=========================================
  Coverage     85.46%   85.46%           
=========================================
  Files           189      189           
  Lines          6376     6376           
  Branches        929      929           
=========================================
  Hits           5449     5449           
  Misses          568      568           
  Partials        359      359           

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

@NachoSoto NachoSoto merged commit 00f8ca1 into paywalls Sep 21, 2023
@NachoSoto NachoSoto deleted the nacho/pwl-266-ability-to-render-svg-icons branch September 21, 2023 15:37
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