Skip to content

Instantly share code, notes, and snippets.

@igorescodro
Last active January 26, 2025 17:04
Show Gist options
  • Select an option

  • Save igorescodro/32b41f85101100ef2537fab5bd5a63cc to your computer and use it in GitHub Desktop.

Select an option

Save igorescodro/32b41f85101100ef2537fab5bd5a63cc to your computer and use it in GitHub Desktop.
@Composable
fun Modifier.shimmerable(
enabled: Boolean,
color: Color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f),
shape: Shape = RoundedCornerShape(8.dp),
): Modifier {
if (!enabled) return this
return this
.shimmer() // 3rd party library call
.background(color = color, shape = shape)
.drawWithContent {
// Do not draw the actual content.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment