Minor cleanup
This commit is contained in:
1 parent
a9b300d357
commit
e559520df3
14 files changed
+28
-233
No files matched your search
+6
-182
@@ -16,16 +16,8 @@
|
||||
|
||||
package androidx.compose.foundation.gestures
|
||||
|
||||
import androidx.compose.animation.core.AnimationSpec
|
||||
import androidx.compose.animation.core.DecayAnimationSpec
|
||||
import androidx.compose.animation.core.FloatDecayAnimationSpec
|
||||
import androidx.compose.animation.core.generateDecayAnimationSpec
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.gestures.HorizontalDragEvent.DragDelta
|
||||
import androidx.compose.foundation.gestures.snapping.SnapLayoutInfoProvider
|
||||
import androidx.compose.foundation.gestures.snapping.snapFlingBehavior
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.input.pointer.PointerInputChange
|
||||
@@ -35,23 +27,15 @@ import androidx.compose.ui.layout.MeasureResult
|
||||
import androidx.compose.ui.layout.MeasureScope
|
||||
import androidx.compose.ui.node.LayoutModifierNode
|
||||
import androidx.compose.ui.node.ModifierNodeElement
|
||||
import androidx.compose.ui.node.ObserverModifierNode
|
||||
import androidx.compose.ui.node.currentValueOf
|
||||
import androidx.compose.ui.node.observeReads
|
||||
import androidx.compose.ui.node.requireLayoutDirection
|
||||
import androidx.compose.ui.platform.InspectorInfo
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.debugInspectorInfo
|
||||
import androidx.compose.ui.unit.Constraints
|
||||
import androidx.compose.ui.unit.Density
|
||||
import androidx.compose.ui.unit.IntSize
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
import androidx.compose.ui.unit.Velocity
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.math.sign
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@ExperimentalFoundationApi
|
||||
@@ -61,7 +45,7 @@ fun <T> Modifier.anchoredHorizontalDraggable(
|
||||
enableDragFromEndToStart: Boolean = true,
|
||||
enabled: Boolean = true,
|
||||
startDragImmediately: Boolean = state.isAnimationRunning,
|
||||
flingBehavior: FlingBehavior? = null,
|
||||
flingBehavior: FlingBehavior,
|
||||
): Modifier = this then AnchoredHorizontalDraggableElement(
|
||||
state = state,
|
||||
canDrag = { (x, y) ->
|
||||
@@ -78,7 +62,7 @@ private class AnchoredHorizontalDraggableElement<T>(
|
||||
private val canDrag: (Offset) -> Boolean,
|
||||
private val enabled: Boolean,
|
||||
private val startDragImmediately: Boolean,
|
||||
private val flingBehavior: FlingBehavior?,
|
||||
private val flingBehavior: FlingBehavior,
|
||||
) : ModifierNodeElement<AnchoredHorizontalDraggableNode<T>>() {
|
||||
override fun create() = AnchoredHorizontalDraggableNode(
|
||||
state,
|
||||
@@ -136,45 +120,12 @@ private class AnchoredHorizontalDraggableNode<T>(
|
||||
private var canDrag: (Offset) -> Boolean,
|
||||
enabled: Boolean,
|
||||
private var startDragImmediately: Boolean,
|
||||
private var flingBehavior: FlingBehavior?,
|
||||
) : HorizontalDragGestureNode(enabled = enabled),
|
||||
ObserverModifierNode {
|
||||
|
||||
lateinit var resolvedFlingBehavior: FlingBehavior
|
||||
lateinit var density: Density
|
||||
private var flingBehavior: FlingBehavior,
|
||||
) : HorizontalDragGestureNode(enabled = enabled) {
|
||||
|
||||
private val isReverseDirection: Boolean
|
||||
get() = requireLayoutDirection() == LayoutDirection.Rtl
|
||||
|
||||
override fun onAttach() {
|
||||
updateFlingBehavior(flingBehavior)
|
||||
}
|
||||
|
||||
override fun onObservedReadsChanged() {
|
||||
val newDensity = currentValueOf(LocalDensity)
|
||||
if (density != newDensity) {
|
||||
density = newDensity
|
||||
updateFlingBehavior(flingBehavior)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateFlingBehavior(newFlingBehavior: FlingBehavior?) {
|
||||
// Fall back to default fling behavior if the new fling behavior is null
|
||||
this.resolvedFlingBehavior =
|
||||
if (newFlingBehavior == null) {
|
||||
// Only register for LocalDensity snapshot updates if we are creating a decay
|
||||
observeReads { density = currentValueOf(LocalDensity) }
|
||||
anchoredDraggableFlingBehavior(
|
||||
snapAnimationSpec = AnchoredDraggableDefaults.SnapAnimationSpec,
|
||||
positionalThreshold = AnchoredDraggableDefaults.PositionalThreshold,
|
||||
density = density,
|
||||
state = state,
|
||||
)
|
||||
} else {
|
||||
newFlingBehavior
|
||||
}
|
||||
}
|
||||
|
||||
override fun canDrag(change: PointerInputChange): Boolean = canDrag(change.positionChange().reverseIfNeeded())
|
||||
|
||||
override suspend fun drag(forEachDelta: suspend ((dragDelta: DragDelta) -> Unit) -> Unit) {
|
||||
@@ -206,7 +157,7 @@ private class AnchoredHorizontalDraggableNode<T>(
|
||||
return consumed
|
||||
}
|
||||
}
|
||||
with(resolvedFlingBehavior) {
|
||||
with(flingBehavior) {
|
||||
leftoverVelocity = scrollScope.performFling(velocity)
|
||||
}
|
||||
}
|
||||
@@ -220,7 +171,7 @@ private class AnchoredHorizontalDraggableNode<T>(
|
||||
canDrag: (Offset) -> Boolean,
|
||||
enabled: Boolean,
|
||||
startDragImmediately: Boolean,
|
||||
flingBehavior: FlingBehavior?,
|
||||
flingBehavior: FlingBehavior,
|
||||
) {
|
||||
this.flingBehavior = flingBehavior
|
||||
|
||||
@@ -228,7 +179,6 @@ private class AnchoredHorizontalDraggableNode<T>(
|
||||
|
||||
if (this.state != state) {
|
||||
this.state = state
|
||||
updateFlingBehavior(flingBehavior)
|
||||
resetPointerInputHandling = true
|
||||
}
|
||||
|
||||
@@ -248,132 +198,6 @@ private class AnchoredHorizontalDraggableNode<T>(
|
||||
internal fun <T> AnchoredDraggableState<T>.newOffsetForDelta(delta: Float) = ((if (offset.isNaN()) 0f else offset) + delta)
|
||||
.coerceIn(anchors.minPosition(), anchors.maxPosition())
|
||||
|
||||
/**
|
||||
* Compute the target anchor based on the [currentOffset], [velocity] and [positionalThreshold] and
|
||||
* [velocityThreshold].
|
||||
*
|
||||
* @return The suggested target anchor
|
||||
*/
|
||||
@ExperimentalFoundationApi
|
||||
private fun <T> DraggableAnchors<T>.computeTarget(
|
||||
currentOffset: Float,
|
||||
velocity: Float,
|
||||
positionalThreshold: (totalDistance: Float) -> Float,
|
||||
velocityThreshold: () -> Float,
|
||||
): T {
|
||||
val currentAnchors = this
|
||||
require(!currentOffset.isNaN()) { "The offset provided to computeTarget must not be NaN." }
|
||||
val velocitySign = sign(velocity)
|
||||
val isMovingForward = velocitySign == 1.0f
|
||||
val isMoving = isMovingForward || velocitySign == -1.0f
|
||||
// When we're not moving, just pick the closest anchor and don't consider directionality
|
||||
return if (!isMoving) {
|
||||
currentAnchors.closestAnchor(currentOffset)!!
|
||||
} else if (abs(velocity) >= abs(velocityThreshold())) {
|
||||
currentAnchors.closestAnchor(currentOffset, searchUpwards = isMovingForward)!!
|
||||
} else {
|
||||
val left = currentAnchors.closestAnchor(currentOffset, false)!!
|
||||
val leftAnchorPosition = currentAnchors.positionOf(left)
|
||||
val right = currentAnchors.closestAnchor(currentOffset, true)!!
|
||||
val rightAnchorPosition = currentAnchors.positionOf(right)
|
||||
val distance = abs(leftAnchorPosition - rightAnchorPosition)
|
||||
val relativeThreshold = abs(positionalThreshold(distance))
|
||||
val closestAnchorFromStart =
|
||||
if (isMovingForward) leftAnchorPosition else rightAnchorPosition
|
||||
val relativePosition = abs(closestAnchorFromStart - currentOffset)
|
||||
if (relativePosition <= relativeThreshold) left else right
|
||||
}
|
||||
}
|
||||
|
||||
// https://issuetracker.google.com/374241709
|
||||
@Composable
|
||||
fun <T> flingBehavior(
|
||||
state: AnchoredDraggableState<T>,
|
||||
positionalThreshold: (totalDistance: Float) -> Float = AnchoredDraggableDefaults.PositionalThreshold,
|
||||
animationSpec: AnimationSpec<Float> = AnchoredDraggableDefaults.SnapAnimationSpec,
|
||||
): TargetedFlingBehavior {
|
||||
val density = LocalDensity.current
|
||||
return remember(density, state, positionalThreshold, animationSpec) {
|
||||
anchoredDraggableFlingBehavior(
|
||||
state = state,
|
||||
density = density,
|
||||
positionalThreshold = positionalThreshold,
|
||||
snapAnimationSpec = animationSpec,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a [FlingBehavior] for use with [Modifier.anchoredDraggable].
|
||||
*
|
||||
* @param state The [AnchoredDraggableState] that will be used for the fling animation
|
||||
* @param positionalThreshold A positional threshold that needs to be crossed in order to reach the
|
||||
* next anchor when flinging, in pixels. This can be a derived from the distance that the lambda
|
||||
* is invoked with.
|
||||
* @param snapAnimationSpec The animation spec that will be used to snap to a new state.
|
||||
*/
|
||||
@ExperimentalFoundationApi
|
||||
internal fun <T> anchoredDraggableFlingBehavior(
|
||||
state: AnchoredDraggableState<T>,
|
||||
density: Density,
|
||||
positionalThreshold: (totalDistance: Float) -> Float,
|
||||
snapAnimationSpec: AnimationSpec<Float>,
|
||||
): TargetedFlingBehavior = snapFlingBehavior(
|
||||
decayAnimationSpec = NoOpDecayAnimationSpec,
|
||||
snapAnimationSpec = snapAnimationSpec,
|
||||
snapLayoutInfoProvider =
|
||||
AnchoredDraggableLayoutInfoProvider(
|
||||
state = state,
|
||||
positionalThreshold = positionalThreshold,
|
||||
velocityThreshold = { with(density) { 125.dp.toPx() } },
|
||||
),
|
||||
)
|
||||
|
||||
@Suppress("FunctionName")
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
private fun <T> AnchoredDraggableLayoutInfoProvider(
|
||||
state: AnchoredDraggableState<T>,
|
||||
positionalThreshold: (totalDistance: Float) -> Float,
|
||||
velocityThreshold: () -> Float,
|
||||
): SnapLayoutInfoProvider = object : SnapLayoutInfoProvider {
|
||||
|
||||
// We never decay in AnchoredDraggable's fling
|
||||
override fun calculateApproachOffset(velocity: Float, decayOffset: Float) = 0f
|
||||
|
||||
override fun calculateSnapOffset(velocity: Float): Float {
|
||||
val currentOffset = state.requireOffset()
|
||||
val target =
|
||||
state.anchors.computeTarget(
|
||||
currentOffset = currentOffset,
|
||||
velocity = velocity,
|
||||
positionalThreshold = positionalThreshold,
|
||||
velocityThreshold = velocityThreshold,
|
||||
)
|
||||
return state.anchors.positionOf(target) - currentOffset
|
||||
}
|
||||
}
|
||||
|
||||
private val NoOpDecayAnimationSpec: DecayAnimationSpec<Float> =
|
||||
object : FloatDecayAnimationSpec {
|
||||
override val absVelocityThreshold = 0f
|
||||
|
||||
override fun getValueFromNanos(
|
||||
playTimeNanos: Long,
|
||||
initialValue: Float,
|
||||
initialVelocity: Float,
|
||||
) = 0f
|
||||
|
||||
override fun getDurationNanos(initialValue: Float, initialVelocity: Float) = 0L
|
||||
|
||||
override fun getVelocityFromNanos(
|
||||
playTimeNanos: Long,
|
||||
initialValue: Float,
|
||||
initialVelocity: Float,
|
||||
) = 0f
|
||||
|
||||
override fun getTargetValue(initialValue: Float, initialVelocity: Float) = 0f
|
||||
}.generateDecayAnimationSpec()
|
||||
|
||||
/**
|
||||
* This Modifier allows configuring an [AnchoredDraggableState]'s anchors based on this layout
|
||||
* node's size and offsetting it.
|
||||
|
||||
@@ -7,11 +7,11 @@ import androidx.compose.animation.core.TweenSpec
|
||||
import androidx.compose.animation.core.animate
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.gestures.AnchoredDraggableDefaults
|
||||
import androidx.compose.foundation.gestures.AnchoredDraggableState
|
||||
import androidx.compose.foundation.gestures.DraggableAnchors
|
||||
import androidx.compose.foundation.gestures.anchoredHorizontalDraggable
|
||||
import androidx.compose.foundation.gestures.detectTapGestures
|
||||
import androidx.compose.foundation.gestures.flingBehavior
|
||||
import androidx.compose.foundation.gestures.snapTo
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -249,7 +249,7 @@ fun ModalSideDrawer(
|
||||
enableDragFromStartToEnd = drawerState.isOpen,
|
||||
enableDragFromEndToStart = drawerState.isClosed,
|
||||
enabled = gesturesEnabled,
|
||||
flingBehavior = flingBehavior(
|
||||
flingBehavior = AnchoredDraggableDefaults.flingBehavior(
|
||||
state = drawerState.anchoredDraggableState,
|
||||
animationSpec = AnimationSpec,
|
||||
),
|
||||
|
||||
@@ -18,13 +18,13 @@ package androidx.compose.material3.fork
|
||||
|
||||
import androidx.annotation.FloatRange
|
||||
import androidx.compose.animation.core.SpringSpec
|
||||
import androidx.compose.foundation.gestures.AnchoredDraggableDefaults
|
||||
import androidx.compose.foundation.gestures.AnchoredDraggableState
|
||||
import androidx.compose.foundation.gestures.DraggableAnchors
|
||||
import androidx.compose.foundation.gestures.Orientation
|
||||
import androidx.compose.foundation.gestures.anchoredHorizontalDraggable
|
||||
import androidx.compose.foundation.gestures.animateTo
|
||||
import androidx.compose.foundation.gestures.draggableAnchors
|
||||
import androidx.compose.foundation.gestures.flingBehavior
|
||||
import androidx.compose.foundation.gestures.snapTo
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -186,7 +186,7 @@ fun SwipeToDismissBox(
|
||||
enableDragFromStartToEnd = enableDismissFromStartToEnd,
|
||||
enableDragFromEndToStart = enableDismissFromEndToStart,
|
||||
enabled = gesturesEnabled && state.currentValue == SwipeToDismissBoxValue.Settled,
|
||||
flingBehavior = flingBehavior(
|
||||
flingBehavior = AnchoredDraggableDefaults.flingBehavior(
|
||||
state = state.anchoredDraggableState,
|
||||
positionalThreshold = SwipeToDismissBoxDefaults.positionalThreshold,
|
||||
animationSpec = SnapAnimationSpec,
|
||||
|
||||
@@ -84,7 +84,7 @@ fun GalleryList(
|
||||
modifier: Modifier = Modifier,
|
||||
data: LazyPagingItems<BaseGalleryInfo>,
|
||||
contentModifier: Modifier = Modifier,
|
||||
contentPadding: PaddingValues = PaddingValues(0.dp),
|
||||
contentPadding: PaddingValues = PaddingValues.Zero,
|
||||
listMode: Int,
|
||||
detailListState: LazyGridState = rememberLazyGridState(),
|
||||
detailItemContent: @Composable (LazyGridItemScope.(BaseGalleryInfo) -> Unit),
|
||||
|
||||
@@ -49,6 +49,7 @@ import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.BlendMode
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.keepScreenOn
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import arrow.core.Either
|
||||
@@ -75,8 +76,8 @@ import com.hippo.ehviewer.ui.Screen
|
||||
import com.hippo.ehviewer.ui.theme.EhTheme
|
||||
import com.hippo.ehviewer.ui.tools.Await
|
||||
import com.hippo.ehviewer.ui.tools.DialogState
|
||||
import com.hippo.ehviewer.ui.tools.EmptyWindowInsets
|
||||
import com.hippo.ehviewer.ui.tools.asyncInVM
|
||||
import com.hippo.ehviewer.ui.tools.thenIf
|
||||
import com.hippo.ehviewer.util.displayString
|
||||
import com.hippo.ehviewer.util.hasAds
|
||||
import com.hippo.files.toOkioPath
|
||||
@@ -176,7 +177,6 @@ fun AnimatedVisibilityScope.ReaderScreen(args: ReaderScreenArgs, navigator: Dest
|
||||
context(MainActivity, SnackbarHostState, DialogState, CoroutineScope)
|
||||
@Composable
|
||||
fun AnimatedVisibilityScope.ReaderScreen(pageLoader: PageLoader, info: BaseGalleryInfo?) {
|
||||
ConfigureKeepScreenOn()
|
||||
LaunchedEffect(Unit) {
|
||||
val orientation = requestedOrientation
|
||||
Settings.orientationMode.valueFlow()
|
||||
@@ -195,6 +195,7 @@ fun AnimatedVisibilityScope.ReaderScreen(pageLoader: PageLoader, info: BaseGalle
|
||||
val reverseControls by Settings.readerReverseControls.collectAsState()
|
||||
val fullscreen by Settings.fullscreen.collectAsState()
|
||||
val cutoutShort by Settings.cutoutShort.collectAsState()
|
||||
val keepScreenOn by Settings.keepScreenOn.collectAsState()
|
||||
val uiController = rememberSystemUiController()
|
||||
DisposableEffect(uiController) {
|
||||
uiController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
@@ -223,7 +224,7 @@ fun AnimatedVisibilityScope.ReaderScreen(pageLoader: PageLoader, info: BaseGalle
|
||||
if (isWebtoon) lazyListState.scrollDown() else pagerState.moveToNext()
|
||||
}
|
||||
},
|
||||
).focusRequester(focusRequester).focusable(),
|
||||
).focusRequester(focusRequester).focusable().thenIf(keepScreenOn) { keepScreenOn() },
|
||||
) {
|
||||
LaunchedEffect(Unit) {
|
||||
focusRequester.requestFocus()
|
||||
@@ -256,7 +257,7 @@ fun AnimatedVisibilityScope.ReaderScreen(pageLoader: PageLoader, info: BaseGalle
|
||||
onDismissRequest = { dispose() },
|
||||
modifier = Modifier.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Top)),
|
||||
sheetState = state,
|
||||
contentWindowInsets = { EmptyWindowInsets },
|
||||
contentWindowInsets = { WindowInsets() },
|
||||
) {
|
||||
ReaderPageSheetMeta(
|
||||
retry = { pageLoader.retryPage(page.index) },
|
||||
@@ -276,7 +277,7 @@ fun AnimatedVisibilityScope.ReaderScreen(pageLoader: PageLoader, info: BaseGalle
|
||||
EhTheme(useDarkTheme = bgColor != Color.White) {
|
||||
val insets = if (fullscreen) {
|
||||
if (cutoutShort) {
|
||||
EmptyWindowInsets
|
||||
WindowInsets()
|
||||
} else {
|
||||
WindowInsets.displayCutout
|
||||
}
|
||||
@@ -360,7 +361,7 @@ fun AnimatedVisibilityScope.ReaderScreen(pageLoader: PageLoader, info: BaseGalle
|
||||
// Yeah, I know color state should not be read here, but we have to do it...
|
||||
scrimColor = scrim,
|
||||
dragHandle = null,
|
||||
contentWindowInsets = { EmptyWindowInsets },
|
||||
contentWindowInsets = { WindowInsets() },
|
||||
) {
|
||||
SettingsPager(modifier = Modifier.fillMaxSize()) { page ->
|
||||
isColorFilter = page == 2
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package com.hippo.ehviewer.ui.reader
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.compose.foundation.gestures.animateScrollBy
|
||||
import androidx.compose.foundation.gestures.scrollBy
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.foundation.pager.PagerState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.ui.AbsoluteAlignment
|
||||
import androidx.compose.ui.Alignment
|
||||
@@ -17,24 +14,6 @@ import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.layout.FixedScale
|
||||
import com.hippo.ehviewer.Settings
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||
import kotlinx.coroutines.flow.onCompletion
|
||||
|
||||
fun Window.updateKeepScreenOn(enabled: Boolean) {
|
||||
if (enabled) {
|
||||
addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
} else {
|
||||
clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Activity.ConfigureKeepScreenOn() {
|
||||
LaunchedEffect(Unit) {
|
||||
Settings.keepScreenOn.valueFlow()
|
||||
.onCompletion { window.updateKeepScreenOn(false) }
|
||||
.collect { window.updateKeepScreenOn(it) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the user preferred [orientation] on the activity.
|
||||
|
||||
@@ -109,7 +109,6 @@ import com.hippo.ehviewer.ui.navToReader
|
||||
import com.hippo.ehviewer.ui.showMoveDownloadLabelList
|
||||
import com.hippo.ehviewer.ui.tools.Await
|
||||
import com.hippo.ehviewer.ui.tools.DialogState
|
||||
import com.hippo.ehviewer.ui.tools.EmptyWindowInsets
|
||||
import com.hippo.ehviewer.ui.tools.FastScrollLazyColumn
|
||||
import com.hippo.ehviewer.ui.tools.FastScrollLazyVerticalStaggeredGrid
|
||||
import com.hippo.ehviewer.ui.tools.HapticFeedbackType
|
||||
@@ -220,7 +219,7 @@ fun AnimatedVisibilityScope.DownloadsScreen(navigator: DestinationsNavigator) =
|
||||
fun closeSheet() = launch { drawerState.close() }
|
||||
TopAppBar(
|
||||
title = { Text(text = labelsStr) },
|
||||
windowInsets = EmptyWindowInsets,
|
||||
windowInsets = WindowInsets(),
|
||||
colors = topBarOnDrawerColor(),
|
||||
actions = {
|
||||
if (DownloadsFilterMode.CUSTOM == filterMode) {
|
||||
|
||||
@@ -79,7 +79,6 @@ import com.hippo.ehviewer.ui.main.GalleryInfoGridItem
|
||||
import com.hippo.ehviewer.ui.main.GalleryInfoListItem
|
||||
import com.hippo.ehviewer.ui.main.GalleryList
|
||||
import com.hippo.ehviewer.ui.startDownload
|
||||
import com.hippo.ehviewer.ui.tools.EmptyWindowInsets
|
||||
import com.hippo.ehviewer.ui.tools.asyncState
|
||||
import com.hippo.ehviewer.ui.tools.foldToLoadResult
|
||||
import com.hippo.ehviewer.ui.tools.rememberInVM
|
||||
@@ -191,7 +190,7 @@ fun AnimatedVisibilityScope.FavouritesScreen(navigator: DestinationsNavigator) =
|
||||
val localFavCount by localFavCountFlow.collectAsState(0)
|
||||
TopAppBar(
|
||||
title = { Text(text = stringResource(id = R.string.collections)) },
|
||||
windowInsets = EmptyWindowInsets,
|
||||
windowInsets = WindowInsets(),
|
||||
colors = topBarOnDrawerColor(),
|
||||
)
|
||||
val scope = currentRecomposeScope
|
||||
|
||||
@@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
@@ -116,7 +117,6 @@ import com.hippo.ehviewer.ui.openBrowser
|
||||
import com.hippo.ehviewer.ui.startDownload
|
||||
import com.hippo.ehviewer.ui.tools.CrystalCard
|
||||
import com.hippo.ehviewer.ui.tools.DialogState
|
||||
import com.hippo.ehviewer.ui.tools.EmptyWindowInsets
|
||||
import com.hippo.ehviewer.ui.tools.FastScrollLazyVerticalGrid
|
||||
import com.hippo.ehviewer.ui.tools.FilledTertiaryIconButton
|
||||
import com.hippo.ehviewer.ui.tools.FilledTertiaryIconToggleButton
|
||||
@@ -213,7 +213,7 @@ fun GalleryDetailContent(
|
||||
dialog { cont ->
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = { cont.cancel() },
|
||||
contentWindowInsets = { EmptyWindowInsets },
|
||||
contentWindowInsets = { WindowInsets() },
|
||||
) {
|
||||
GalleryInfoBottomSheet(galleryDetail)
|
||||
}
|
||||
|
||||
@@ -111,7 +111,6 @@ import com.hippo.ehviewer.ui.main.GalleryList
|
||||
import com.hippo.ehviewer.ui.main.SearchFilter
|
||||
import com.hippo.ehviewer.ui.tools.Await
|
||||
import com.hippo.ehviewer.ui.tools.DialogState
|
||||
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.asyncState
|
||||
@@ -252,7 +251,7 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De
|
||||
ProvideSideSheetContent { sheetState ->
|
||||
TopAppBar(
|
||||
title = { Text(text = stringResource(id = R.string.toplist)) },
|
||||
windowInsets = EmptyWindowInsets,
|
||||
windowInsets = WindowInsets(),
|
||||
colors = topBarOnDrawerColor(),
|
||||
)
|
||||
toplists.forEach { (name, keyword) ->
|
||||
@@ -343,7 +342,7 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De
|
||||
)
|
||||
}
|
||||
},
|
||||
windowInsets = EmptyWindowInsets,
|
||||
windowInsets = WindowInsets(),
|
||||
)
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
val dialogState by rememberUpdatedState(implicit<DialogState>())
|
||||
|
||||
@@ -25,7 +25,7 @@ fun FastScrollLazyVerticalGrid(
|
||||
columns: GridCells,
|
||||
modifier: Modifier = Modifier,
|
||||
state: LazyGridState = rememberLazyGridState(),
|
||||
contentPadding: PaddingValues = PaddingValues(0.dp),
|
||||
contentPadding: PaddingValues = PaddingValues.Zero,
|
||||
reverseLayout: Boolean = false,
|
||||
verticalArrangement: Arrangement.Vertical = if (!reverseLayout) Arrangement.Top else Arrangement.Bottom,
|
||||
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
|
||||
@@ -59,7 +59,7 @@ fun FastScrollLazyVerticalStaggeredGrid(
|
||||
columns: StaggeredGridCells,
|
||||
modifier: Modifier = Modifier,
|
||||
state: LazyStaggeredGridState = rememberLazyStaggeredGridState(),
|
||||
contentPadding: PaddingValues = PaddingValues(0.dp),
|
||||
contentPadding: PaddingValues = PaddingValues.Zero,
|
||||
reverseLayout: Boolean = false,
|
||||
verticalItemSpacing: Dp = 0.dp,
|
||||
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
|
||||
|
||||
@@ -12,13 +12,12 @@ 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
|
||||
fun FastScrollLazyColumn(
|
||||
modifier: Modifier = Modifier,
|
||||
state: LazyListState = rememberLazyListState(),
|
||||
contentPadding: PaddingValues = PaddingValues(0.dp),
|
||||
contentPadding: PaddingValues = PaddingValues.Zero,
|
||||
reverseLayout: Boolean = false,
|
||||
verticalArrangement: Arrangement.Vertical = if (!reverseLayout) Arrangement.Top else Arrangement.Bottom,
|
||||
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
||||
|
||||
@@ -30,7 +30,7 @@ fun VerticalScrollbar(
|
||||
adapter: ScrollbarAdapter,
|
||||
isScrollInProgress: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
contentPadding: PaddingValues = PaddingValues(0.dp),
|
||||
contentPadding: PaddingValues = PaddingValues.Zero,
|
||||
reverseLayout: Boolean = false,
|
||||
) {
|
||||
val isScrolling by rememberUpdatedState(isScrollInProgress)
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.hippo.ehviewer.ui.tools
|
||||
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
|
||||
val EmptyWindowInsets = WindowInsets(0, 0, 0, 0)
|
||||
Reference in new issue
Block a user