-
Notifications
You must be signed in to change notification settings - Fork 53
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: backwards compatible blurring #1327
Changes from 1 commit
4b22c1f
de56b10
cb65f39
1d51f1f
f28fce4
ed4e957
19ef51e
ef31b22
119c260
d5f4c95
1ef2a52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.revenuecat.purchases.ui.revenuecatui.composables | ||
|
||
import BlurTransformation | ||
import android.content.Context | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ReadOnlyComposable | ||
|
@@ -11,6 +12,7 @@ import coil.compose.AsyncImage | |
import coil.compose.AsyncImagePainter | ||
import coil.disk.DiskCache | ||
import coil.request.ImageRequest | ||
import coil.transform.Transformation | ||
import com.revenuecat.purchases.ui.revenuecatui.UIConstant | ||
import com.revenuecat.purchases.ui.revenuecatui.helpers.Logger | ||
|
||
|
@@ -20,16 +22,25 @@ internal fun RemoteImage( | |
modifier: Modifier = Modifier, | ||
contentScale: ContentScale = ContentScale.Fit, | ||
contentDescription: String? = null, | ||
transformation: Transformation? = null, | ||
alpha: Float = 1f | ||
) { | ||
AsyncImage( | ||
model = ImageRequest.Builder(LocalContext.current) | ||
.data(urlString) | ||
.crossfade(durationMillis = UIConstant.defaultAnimationDurationMillis) | ||
.build(), | ||
|
||
val requestBuilder = ImageRequest.Builder(LocalContext.current) | ||
.data(urlString) | ||
.crossfade(durationMillis = UIConstant.defaultAnimationDurationMillis) | ||
|
||
transformation?.let { | ||
requestBuilder.transformations(listOf(it)) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out this can be simplified: .transformations(listOfNotNull(transformation)) |
||
|
||
return AsyncImage( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I don't think we need the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, fixed |
||
model = requestBuilder.build(), | ||
contentDescription = contentDescription, | ||
imageLoader = LocalContext.current.getRevenueCatUIImageLoader(), | ||
modifier = modifier, | ||
contentScale = contentScale, | ||
alpha = alpha, | ||
onState = { | ||
when (it) { | ||
is AsyncImagePainter.State.Error -> { | ||
|
@@ -41,6 +52,7 @@ internal fun RemoteImage( | |
) | ||
} | ||
|
||
|
||
private const val MAX_CACHE_SIZE_BYTES = 25 * 1024 * 1024L // 25 MB | ||
|
||
@Composable | ||
|
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.
This is now applying the alpha even when there's no blur.