Nthily
04/30/2024, 2:39 AMNthily
04/30/2024, 3:31 AMNthily
04/30/2024, 3:42 AManimateScrollToItem(offset = height)
🤔Swapnil Musale
04/30/2024, 5:18 AMNthily
04/30/2024, 6:12 AMimeNestedScroll
requires a gesture swipe to trigger. What I want is for LazyColumn to automatically animate with ime movement after clicking the textfieldNthily
04/30/2024, 6:13 AMStylianos Gakis
04/30/2024, 6:19 AMNthily
04/30/2024, 7:03 AMNthily
04/30/2024, 7:06 AMNthily
04/30/2024, 10:15 AMval navigationBarHeight = WindowInsets.navigationBars.getBottom(density)
val imeOffset = WindowInsets.imeAnimationTarget.getBottom(density)
var imeHeight by remember { mutableIntStateOf(0) }
val visibleItemsIndex by remember {
derivedStateOf {
listState.layoutInfo.visibleItemsInfo.fastMap { it.index }
}
}
val isContainLastIndex by remember {
derivedStateOf {
visibleItemsIndex.contains(listState.layoutInfo.totalItemsCount - 1)
}
}
SideEffect {
if (listState.layoutInfo.totalItemsCount > 0) {
scope.launch {
when (imeOffset) {
0 -> {
listState.animateScrollBy(
value = if (isContainLastIndex) 0f else -imeHeight.toFloat() + navigationBarHeight.toFloat(),
animationSpec = tween(250)
)
}
else -> {
imeHeight = imeOffset
listState.animateScrollBy(
value = imeOffset.toFloat() - navigationBarHeight.toFloat(),
animationSpec = tween(250)
)
}
}
}
}
}