Skip to content

Instantly share code, notes, and snippets.

@fvilarino
Created April 20, 2024 23:26
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 fvilarino/8e5f5e2f10bf21609c47a1d0862b5bdd to your computer and use it in GitHub Desktop.
Save fvilarino/8e5f5e2f10bf21609c47a1d0862b5bdd to your computer and use it in GitHub Desktop.
Share Elem - Animated Details
@Composable
// 1
fun SharedTransitionScope.DetailsScreen(
url: String,
// 2
animatedVisibilityScope: AnimatedVisibilityScope,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
onClick = onClick
),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
AsyncImage(
model = url,
modifier = Modifier
.fillMaxWidth()
.aspectRatio(4f / 3f)
// 3
.sharedElement(
rememberSharedContentState(key = "image-$url"),
animatedVisibilityScope,
),
contentDescription = null,
)
LoremIpsum(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment