Reapply "Add scroll bar to quick search and download label"

This reverts commit a52ab28534.
This commit is contained in:
FooIbar committed 2024-09-26 19:12:46 +08:00
1 parent 8447760cb5
commit b67d0938b0
4 files changed
+14 -9

No files matched your search

@@ -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(),
@@ -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(),
@@ -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,
@@ -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)
}
}
}