Fix crashes on changing grouping
This commit is contained in:
parent
141cd959f2
commit
bc76490967
@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.key
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
@ -53,8 +54,10 @@ fun LibraryContent(
|
||||
end = contentPadding.calculateEndPadding(LocalLayoutDirection.current),
|
||||
),
|
||||
) {
|
||||
val coercedCurrentPage = remember { currentPage().coerceIn(0, categories.lastIndex) }
|
||||
val pagerState = rememberPagerState(coercedCurrentPage)
|
||||
// SY -->
|
||||
val coercedCurrentPage = remember(categories) { currentPage().coerceIn(0, categories.lastIndex) }
|
||||
val pagerState = key(categories) { rememberPagerState(coercedCurrentPage) }
|
||||
// SY <--
|
||||
|
||||
val scope = rememberCoroutineScope()
|
||||
var isRefreshing by remember(pagerState.currentPage) { mutableStateOf(false) }
|
||||
|
@ -19,11 +19,15 @@ fun LibraryTabs(
|
||||
getNumberOfMangaForCategory: (Category) -> Int?,
|
||||
onTabItemClick: (Int) -> Unit,
|
||||
) {
|
||||
// SY -->
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val currentPageIndex = currentPageIndex.coerceAtMost(categories.lastIndex)
|
||||
// SY <--
|
||||
Column {
|
||||
ScrollableTabRow(
|
||||
selectedTabIndex = currentPageIndex,
|
||||
edgePadding = 0.dp,
|
||||
indicator = { TabIndicator(it[currentPageIndex]) },
|
||||
indicator = { TabIndicator(it[currentPageIndex.coerceAtMost(categories.lastIndex)]) },
|
||||
// TODO: use default when width is fixed upstream
|
||||
// https://issuetracker.google.com/issues/242879624
|
||||
divider = {},
|
||||
|
Loading…
x
Reference in New Issue
Block a user