Use duration overload for time related methods
This commit is contained in:
+6
-5
@@ -56,6 +56,7 @@ import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
/**
|
||||
* Draws vertical fast scroller to a lazy list
|
||||
@@ -174,11 +175,11 @@ fun VerticalFastScroller(
|
||||
val isThumbVisible = alpha.value > 0f
|
||||
LaunchedEffect(scrolled, alpha) {
|
||||
scrolled
|
||||
.sample(100)
|
||||
.sample(0.1.seconds)
|
||||
.collectLatest {
|
||||
if (thumbAllowed()) {
|
||||
alpha.snapTo(1f)
|
||||
delay(ScrollBarVisibilityDurationMillis)
|
||||
delay(ScrollBarVisibilityDuration)
|
||||
alpha.animateTo(0f, animationSpec = ImmediateFadeOutAnimationSpec)
|
||||
} else {
|
||||
alpha.animateTo(0f, animationSpec = ImmediateFadeOutAnimationSpec)
|
||||
@@ -364,11 +365,11 @@ fun VerticalGridFastScroller(
|
||||
val isThumbVisible = alpha.value > 0f
|
||||
LaunchedEffect(scrolled, alpha) {
|
||||
scrolled
|
||||
.sample(100)
|
||||
.sample(0.1.seconds)
|
||||
.collectLatest {
|
||||
if (thumbAllowed()) {
|
||||
alpha.snapTo(1f)
|
||||
delay(ScrollBarVisibilityDurationMillis)
|
||||
delay(ScrollBarVisibilityDuration)
|
||||
alpha.animateTo(0f, animationSpec = ImmediateFadeOutAnimationSpec)
|
||||
} else {
|
||||
alpha.animateTo(0f, animationSpec = ImmediateFadeOutAnimationSpec)
|
||||
@@ -463,7 +464,7 @@ object Scroller {
|
||||
private val ThumbLength = 48.dp
|
||||
private val ThumbThickness = 12.dp
|
||||
private val ThumbShape = RoundedCornerShape(ThumbThickness / 2)
|
||||
private val ScrollBarVisibilityDurationMillis = 2000L
|
||||
private val ScrollBarVisibilityDuration = 2.seconds
|
||||
private val ImmediateFadeOutAnimationSpec = tween<Float>(
|
||||
durationMillis = ViewConfiguration.getScrollBarFadeDuration(),
|
||||
)
|
||||
|
||||
@@ -69,6 +69,8 @@ import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.sample
|
||||
import tachiyomi.presentation.core.components.Scroller.STICKY_HEADER_KEY_PREFIX
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
/**
|
||||
* Draws horizontal scrollbar to a LazyList.
|
||||
@@ -216,10 +218,10 @@ private fun Modifier.drawScrollbar(
|
||||
val alpha = remember { Animatable(0f) }
|
||||
LaunchedEffect(scrolled, alpha) {
|
||||
scrolled
|
||||
.sample(100)
|
||||
.sample(0.1.seconds)
|
||||
.collectLatest {
|
||||
alpha.snapTo(1f)
|
||||
delay(ScrollBarVisibilityDurationMillis)
|
||||
delay(ScrollBarVisibilityDurationMillis.milliseconds)
|
||||
alpha.animateTo(0f, animationSpec = ImmediateFadeOutAnimationSpec)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user