Skip to content

Instantly share code, notes, and snippets.

@Ahmed-Sellami
Last active Aug 26, 2021
Embed
What would you like to do?
private var maxRadiusPx = 0f
@ExperimentalAnimationApi
@Composable
fun ShoesCard(shoesArticle: ShoesArticle, isVisible: Boolean) {
val particleRadius: Float
with(LocalDensity.current) {
particleRadius = dimensionResource(id = R.dimen.particle_radius).toPx()
}
var radius by remember { mutableStateOf(particleRadius) }
var visibilityAlpha by remember { mutableStateOf(0f) }
Box(
Modifier.padding(horizontal = 16.dp)
) {
Column(
modifier = Modifier
.clip(RoundedCornerShape(8.dp))
.background(
color = Color.Transparent
)
.onGloballyPositioned { coordinates ->
if (maxRadiusPx == 0f) {
maxRadiusPx = hypot(coordinates.size.width / 2f, coordinates.size.height / 2f)
}
}
.drawBehind {
drawCircle(
color = if (isVisible) shoesArticle.color else Color.Transparent,
radius = radius
)
}
.padding(dimensionResource(id = R.dimen.slot_padding))
.align(Alignment.CenterStart)
.fillMaxWidth(),
) {
Text(
/* ... */
modifier = Modifier.alpha(visibilityAlpha)
)
/* ... */
Row(
modifier = Modifier
.height(IntrinsicSize.Min)
.alpha(visibilityAlpha),
/* ... */
) {
/* ... */
}
}
Image(
modifier = Modifier
.align(Alignment.CenterEnd)
.size(dimensionResource(id = R.dimen.image_size))
.alpha(visibilityAlpha),
/* ... */
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment