I am trying to create a chat feature in app. We would like the layout to be reversed in the column for easier scrolling. However, we cannot get the SwipeRefresh to work in this configuration if the list is large enough to scroll. Preferably, we would like to be able to swipe up from the bottom to refresh, but even with trying to use the regular SwipeRefresh from the top, it does not work unless we remove the 'reverseLayout = true'. Has anyone been able to use the reverse layout with the SwipeRefresh or the PullRefresh?
@Composable
fun CRFilesPage(
uiState: StateFlow<ViewModel.UiState>,
refreshList: () -> Unit
) {
val state = uiState.collectAsState()
val lazyListState: LazyListState = rememberLazyListState()
val swipeRefreshState = rememberSwipeRefreshState(isRefreshing = state.value.isSending)
SwipeRefresh(
state = swipeRefreshState,
onRefresh = { refreshList.invoke() },
modifier = Modifier
) {
LazyColumn(
state = lazyListState,
reverseLayout = true
) {
items(items = state.value.comments, key = { it.id }) {
Text(text = it.comment)
}
}
}
}