Skip to content

Instantly share code, notes, and snippets.

@Ahmed-Sellami
Last active August 26, 2021 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ahmed-Sellami/d3e974e1e38b4184a71f41e924b7e1dd to your computer and use it in GitHub Desktop.
Save Ahmed-Sellami/d3e974e1e38b4184a71f41e924b7e1dd to your computer and use it in GitHub Desktop.
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