Skip to content

Instantly share code, notes, and snippets.

@skydoves
Created April 19, 2024 06:35
Show Gist options
  • Save skydoves/229418d4e5674df553815173d4d9d21a to your computer and use it in GitHub Desktop.
Save skydoves/229418d4e5674df553815173d4d9d21a to your computer and use it in GitHub Desktop.
nav_sample_home
composable("home") {
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
itemsIndexed(pokemons) { index, item ->
Row(
modifier = Modifier.clickable {
navController.navigate("details/$index")
}
) {
Image(
painter = painterResource(id = item.image),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier
.sharedElement(
rememberSharedContentState(key = "image-$index"),
animatedVisibilityScope = this@composable,
boundsTransform = boundsTransform
)
.padding(horizontal = 20.dp)
.size(100.dp)
)
Text(
text = item.name,
fontSize = 18.sp,
modifier = Modifier
.sharedElement(
rememberSharedContentState(key = "text-$index"),
animatedVisibilityScope = this@composable,
boundsTransform = boundsTransform
)
.align(Alignment.CenterVertically)
)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment