I am new in Compose, and I am struggling with the state
issue.
Let's consider such scenario:
- The list of items is displayed.
- On the bottom of the screen there is a button which state should change if user reaches the bottom of the list.
- When button's state is changed, its text content and sharp is changed.
- When the state is changed and user scrolls up -> state should not be changed anymore.
It works when I scroll to the bottom -> the state is changed. But state is also changed when I scroll up from the bottom of the list.
val scrollState = rememberLazyListState()
val lastVisibleItemIndex by remember(scrollState) {
derivedStateOf {
scrollState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0
}
}
val isEndReached by remember { lastVisibleItemIndex == items.size -1 }