[img]https:// i.sstatic.net/fzmVJY56.png[/img]
За основу я взял следующее решение: https://github.com/germainkevinbusiness ... ree/master
Вот мой код:
Код: Выделить всё
@Composable
private fun CollapsingLayout(
modifier: Modifier,
collapsedContent: @Composable (Modifier) -> Unit,
expandedContent: @Composable (Modifier) -> Unit,
scrollBehavior: CollapsingTopBarScrollBehavior,
) = with(scrollBehavior) {
Surface(
modifier = modifier
.fillMaxWidth()
.height(currentTopBarHeight)
.verticalScroll(topBarVerticalScrollState.invoke()),
color = Color.Unspecified,
contentColor = Color.Unspecified,
elevation = 0.dp,
) {
Box {
// Display expanded content
expandedContent(Modifier
.alpha(expandedColumnAlpha.invoke().value)
.fillMaxWidth()
.height(currentTopBarHeight))
// Collapsed content with AnimatedVisibility for smooth transition
AnimatedVisibility(
visible = collapsedTitleAlpha.invoke().value in 0F..1F,
enter = fadeIn(initialAlpha = collapsedTitleAlpha.invoke().value),
exit = fadeOut()
) {
collapsedContent(
Modifier
.fillMaxWidth()
.height(scrollBehavior.collapsedTopBarHeight)
.align(Alignment.BottomStart),
)
}
}
}
}
P.S. частично свернутый составной объект должен оставаться фиксированным вверху и не прокручиваться по списку.
Подробнее здесь: https://stackoverflow.com/questions/791 ... composable
Мобильная версия