[修复] 在发现页内切换样式时,不会继续加载下一页的问题
This commit is contained in:
1 file changed
+18
-14
@@ -123,27 +123,31 @@ fun ExploreShowScreen(
|
|||||||
val gridColumnCount = remember(context.resources.configuration.orientation) {
|
val gridColumnCount = remember(context.resources.configuration.orientation) {
|
||||||
context.bookshelfLayoutGrid
|
context.bookshelfLayoutGrid
|
||||||
}
|
}
|
||||||
val shouldLoadMore = remember {
|
|
||||||
|
val shouldLoadMoreList = remember {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
val totalItems: Int
|
val total = listState.layoutInfo.totalItemsCount
|
||||||
val lastVisibleIndex: Int
|
val last = listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0
|
||||||
if (isGridMode) {
|
total > 0 && last >= total - 6
|
||||||
totalItems = gridState.layoutInfo.totalItemsCount
|
|
||||||
lastVisibleIndex = gridState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0
|
|
||||||
} else {
|
|
||||||
totalItems = listState.layoutInfo.totalItemsCount
|
|
||||||
lastVisibleIndex = listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0
|
|
||||||
}
|
|
||||||
totalItems > 0 && lastVisibleIndex >= totalItems - 6
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(shouldLoadMore.value) {
|
val shouldLoadMoreGrid = remember {
|
||||||
if (shouldLoadMore.value) {
|
derivedStateOf {
|
||||||
viewModel.loadMore()
|
val total = gridState.layoutInfo.totalItemsCount
|
||||||
|
val last = gridState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0
|
||||||
|
total > 0 && last >= total - 6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(shouldLoadMoreList.value, isGridMode) {
|
||||||
|
if (!isGridMode && shouldLoadMoreList.value) viewModel.loadMore()
|
||||||
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(shouldLoadMoreGrid.value, isGridMode) {
|
||||||
|
if (isGridMode && shouldLoadMoreGrid.value) viewModel.loadMore()
|
||||||
|
}
|
||||||
|
|
||||||
LaunchedEffect(shouldTriggerAutoLoad) {
|
LaunchedEffect(shouldTriggerAutoLoad) {
|
||||||
if (shouldTriggerAutoLoad) {
|
if (shouldTriggerAutoLoad) {
|
||||||
viewModel.loadMore()
|
viewModel.loadMore()
|
||||||
|
|||||||
Reference in new issue
Block a user