Nthily
04/17/2024, 5:22 PMIan Lake
04/17/2024, 6:47 PMDoris Liu
04/17/2024, 6:59 PMNthily
04/18/2024, 7:13 AMif statements or the animation APIs (like AnimatedContent) to control the display or movement of the Bottom Bar doesn't seem to work well in sync with the screens.
Shared Element Transition seems to apply when there is a common element directly between two screens. How should I achieve the effect seen in the video? 🤔Stylianos Gakis
04/18/2024, 8:16 AMNthily
04/18/2024, 8:26 AMSharedTransitionLayout {
Scaffold(
containerColor = Color.Black,
modifier = Modifier.fillMaxSize()
) {
NavHost(
navController = navController,
startDestination = "first",
modifier = Modifier.fillMaxSize(),
enterTransition = {
defaultSlideIntoContainer()
},
exitTransition = {
defaultSlideOutContainer()
},
popEnterTransition = {
defaultSlideIntoContainer(forward = false)
},
popExitTransition = {
defaultSlideOutContainer(forward = false)
}
) {
composable("first") {
Column {
Box(
Modifier
.fillMaxWidth()
.height(80.dp)
.background(Color.Red)
)
LazyColumn(Modifier.fillMaxSize().background(Color.White)) {
items(100) {
CenterRow {
Text(text = "items $it")
WidthSpacer(value = 20.dp)
AsyncImage(
model = "<https://pbs.twimg.com/media/GLOzjMmWkAA0SOQ?format=png&name=small>",
contentDescription = null,
modifier = Modifier
.size(72.dp)
.sharedElement(
state = rememberSharedContentState(key = "image $it"),
animatedVisibilityScope = this@composable
)
.clickable {
navController.navigate("second/$it")
},
)
}
}
}
}
}
composable(
route = "second/{imageId}",
arguments = listOf(
navArgument("imageId") { type = NavType.IntType }
)
) { backStackEntry ->
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Gray), Alignment.Center
) {
AsyncImage(
model = "<https://pbs.twimg.com/media/GLOzjMmWkAA0SOQ?format=png&name=small>",
contentDescription = null,
modifier = Modifier
.size(272.dp)
.sharedElement(
state = rememberSharedContentState(
key = "image ${backStackEntry.arguments?.getInt("imageId")}"
),
animatedVisibilityScope = this@composable
),
)
}
}
}
}
}Nthily
04/18/2024, 8:31 AMNthily
04/18/2024, 9:06 AMNullPointException will be triggered.
https://android.googlesource.com/platform/frameworks/support/+/715250d4e5a067d26174522ca8[…]mpose/animation/demos/sharedelement/ListToDetailsDemo.kt
this sample code just can reproduces this issueDoris Liu
04/18/2024, 11:34 PM