-
-
Save Ahmed-Sellami/d3e974e1e38b4184a71f41e924b7e1dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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