diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt index 797f9f1e5..c313f2c2c 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt @@ -20,7 +20,6 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.systemBars -import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState @@ -300,7 +299,7 @@ fun AnimatedVisibilityScope.DownloadsScreen(navigator: DestinationsNavigator) = hapticFeedback.performHapticFeedback(HapticFeedbackType.MOVE) } var fromIndex by remember { mutableIntStateOf(-1) } - LazyColumn( + FastScrollLazyColumn( modifier = Modifier.fillMaxSize(), state = labelsListState, contentPadding = WindowInsets.systemBars.only(WindowInsetsSides.Bottom).asPaddingValues(), diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt index bf51693ba..93a43de92 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt @@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.systemBars -import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.grid.rememberLazyGridState import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState @@ -127,6 +126,7 @@ import com.hippo.ehviewer.ui.main.ImageSearch import com.hippo.ehviewer.ui.main.SearchFilter import com.hippo.ehviewer.ui.tools.Await import com.hippo.ehviewer.ui.tools.EmptyWindowInsets +import com.hippo.ehviewer.ui.tools.FastScrollLazyColumn import com.hippo.ehviewer.ui.tools.HapticFeedbackType import com.hippo.ehviewer.ui.tools.animateFloatMergePredictiveBackAsState import com.hippo.ehviewer.ui.tools.delegateSnapshotUpdate @@ -375,7 +375,7 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De hapticFeedback.performHapticFeedback(HapticFeedbackType.MOVE) } var fromIndex by remember { mutableIntStateOf(-1) } - LazyColumn( + FastScrollLazyColumn( modifier = Modifier.fillMaxSize(), state = quickSearchListState, contentPadding = WindowInsets.systemBars.only(WindowInsetsSides.Bottom).asPaddingValues(), diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/Dialog.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/Dialog.kt index 17268d9e8..e05cce628 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/Dialog.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/Dialog.kt @@ -459,7 +459,7 @@ class DialogState { style = MaterialTheme.typography.headlineSmall, ) } - LazyColumn { + FastScrollLazyColumn { itemsIndexed(items) { index, text -> CheckableItem( text = text, @@ -495,7 +495,7 @@ class DialogState { modifier = Modifier.padding(horizontal = 24.dp, vertical = 8.dp), style = MaterialTheme.typography.headlineSmall, ) - LazyColumn { + FastScrollLazyColumn { itemsIndexed(items) { index, text -> CheckableItem( text = text, diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/LazyList.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/LazyList.kt index 93353c472..04fa9b0fe 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/LazyList.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/LazyList.kt @@ -1,7 +1,6 @@ package com.hippo.ehviewer.ui.tools import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListScope @@ -11,6 +10,8 @@ import androidx.compose.foundation.scrollbar.rememberScrollbarAdapter import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.Layout +import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp @Composable @@ -24,7 +25,7 @@ fun FastScrollLazyColumn( userScrollEnabled: Boolean = true, content: LazyListScope.() -> Unit, ) { - Box { + Layout({ LazyColumn( modifier = modifier, state = state, @@ -38,8 +39,13 @@ fun FastScrollLazyColumn( VerticalScrollbar( adapter = rememberScrollbarAdapter(state), isScrollInProgress = state.isScrollInProgress, - modifier = Modifier.align(Alignment.TopEnd), contentPadding = contentPadding, ) + }) { measurables, constraints -> + val (column, scrollbar) = measurables.map { it.measure(constraints) } + layout(column.width, column.height) { + column.place(IntOffset.Zero) + scrollbar.placeRelative(column.width - scrollbar.width, 0) + } } }