Apply spotless

pull/1837/head
Ben Trengrove 2 years ago
parent a7c7b520a4
commit 41a7a697da

@ -20,7 +20,6 @@ import android.annotation.SuppressLint
import androidx.compose.animation.animateColorAsState import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.Spring import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.SpringSpec import androidx.compose.animation.core.SpringSpec
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.Orientation.Horizontal import androidx.compose.foundation.gestures.Orientation.Horizontal
import androidx.compose.foundation.gestures.Orientation.Vertical import androidx.compose.foundation.gestures.Orientation.Vertical
@ -49,7 +48,6 @@ import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorProducer import androidx.compose.ui.graphics.ColorProducer
import androidx.compose.ui.graphics.Outline import androidx.compose.ui.graphics.Outline
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.drawOutline import androidx.compose.ui.graphics.drawOutline
import androidx.compose.ui.graphics.drawscope.ContentDrawScope import androidx.compose.ui.graphics.drawscope.ContentDrawScope
import androidx.compose.ui.node.DrawModifierNode import androidx.compose.ui.node.DrawModifierNode
@ -60,10 +58,7 @@ import androidx.compose.ui.unit.dp
import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.ThumbState.Active import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.ThumbState.Active
import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.ThumbState.Dormant import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.ThumbState.Dormant
import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.ThumbState.Inactive import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.ThumbState.Inactive
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.launch
/** /**
* The time period for showing the scrollbar thumb after interacting with it, before it fades away * The time period for showing the scrollbar thumb after interacting with it, before it fades away
@ -175,14 +170,14 @@ private fun ScrollableState.DecorativeScrollbarThumb(
@Composable @Composable
private fun Modifier.scrollThumb( private fun Modifier.scrollThumb(
scrollableState: ScrollableState, scrollableState: ScrollableState,
interactionSource: InteractionSource interactionSource: InteractionSource,
): Modifier { ): Modifier {
val colorState = scrollbarThumbColor(scrollableState, interactionSource) val colorState = scrollbarThumbColor(scrollableState, interactionSource)
return this then ScrollThumbElement { colorState.value } return this then ScrollThumbElement { colorState.value }
} }
private data class ScrollThumbElement(val colorProducer: ColorProducer) private data class ScrollThumbElement(val colorProducer: ColorProducer) :
: ModifierNodeElement<ScrollThumbNode>() { ModifierNodeElement<ScrollThumbNode>() {
override fun create(): ScrollThumbNode = ScrollThumbNode(colorProducer) override fun create(): ScrollThumbNode = ScrollThumbNode(colorProducer)
override fun update(node: ScrollThumbNode) { override fun update(node: ScrollThumbNode) {
node.colorProducer = colorProducer node.colorProducer = colorProducer
@ -221,7 +216,7 @@ private class ScrollThumbNode(var colorProducer: ColorProducer): DrawModifierNod
@Composable @Composable
private fun scrollbarThumbColor( private fun scrollbarThumbColor(
scrollableState: ScrollableState, scrollableState: ScrollableState,
interactionSource: InteractionSource interactionSource: InteractionSource,
): State<Color> { ): State<Color> {
var state by remember { mutableStateOf(Dormant) } var state by remember { mutableStateOf(Dormant) }
val pressed by interactionSource.collectIsPressedAsState() val pressed by interactionSource.collectIsPressedAsState()

@ -39,7 +39,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.PointerInputChange import androidx.compose.ui.input.pointer.PointerInputChange
@ -48,7 +47,6 @@ import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.layout import androidx.compose.ui.layout.layout
import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInRoot import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.IntSize
@ -340,13 +338,13 @@ fun Scrollbar(
Horizontal -> { Horizontal -> {
constraints.copy( constraints.copy(
minWidth = thumbSizePx.roundToInt(), minWidth = thumbSizePx.roundToInt(),
maxWidth = thumbSizePx.roundToInt() maxWidth = thumbSizePx.roundToInt(),
) )
} }
Vertical -> { Vertical -> {
constraints.copy( constraints.copy(
minHeight = thumbSizePx.roundToInt(), minHeight = thumbSizePx.roundToInt(),
maxHeight = thumbSizePx.roundToInt() maxHeight = thumbSizePx.roundToInt(),
) )
} }
} }
@ -392,8 +390,6 @@ fun Scrollbar(
interactionThumbTravelPercent = currentThumbMovedPercent interactionThumbTravelPercent = currentThumbMovedPercent
delay(SCROLLBAR_PRESS_DELAY_MS) delay(SCROLLBAR_PRESS_DELAY_MS)
} }
} }
} }

Loading…
Cancel
Save