Joel Denke
01/22/2024, 3:02 PMChrimaeon
01/22/2024, 4:18 PMJoel Denke
01/22/2024, 4:21 PMJoel Denke
01/22/2024, 4:21 PMJoel Denke
01/22/2024, 4:22 PMJoel Denke
01/22/2024, 4:23 PMval density = LocalDensity.current
val height by remember {
derivedStateOf {
with(density) {
val offsetLimit = variant.scrollBehavior?.state?.heightOffsetLimit?.absoluteValue?.toDp() ?: 0.dp
val fraction = 1f - (variant.scrollBehavior?.state?.collapsedFraction ?: 0f)
64.dp + (offsetLimit) * fraction
}
}
}
Box(
modifier = modifier.fillMaxWidth()
) {
Box(Modifier
.fillMaxWidth()
.height(height)
) {
variant.imageContent()
}
if (variant.size == TopBarSize.LARGE) {
LargeTopAppBar(
title = title,
colors = variant.colors,
scrollBehavior = variant.scrollBehavior,
navigationIcon = navigationIcon,
actions = actions
)
} else {
TopAppBar(
title = title,
colors = variant.colors,
scrollBehavior = variant.scrollBehavior,
navigationIcon = navigationIcon,
actions = actions
)
}
}
Chrimaeon
01/22/2024, 4:26 PMIt did work, I used a Box and then placed an image back and then LargeTopAppBar on top. And syncing states from the scrollingBehaviour 🙂Of course it works, it’s just a composable. But it does not mean that it should work like you expect it to. Just don’t use a material 3 top bar if you want other behavior 🤷♂️
Joel Denke
01/22/2024, 4:28 PMJoel Denke
01/22/2024, 4:28 PMChrimaeon
01/22/2024, 4:28 PMJoel Denke
01/22/2024, 4:30 PM