From acf0526226bb34a3f7082e4be57fb39d9f35d7c3 Mon Sep 17 00:00:00 2001 From: TJ Dahunsi Date: Thu, 11 May 2023 09:54:05 +0100 Subject: [PATCH] Add hoverable to scrollbar --- .../core/designsystem/component/scrollbar/Scrollbar.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/Scrollbar.kt b/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/Scrollbar.kt index 4984946bc..dfe0ce1f0 100644 --- a/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/Scrollbar.kt +++ b/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/Scrollbar.kt @@ -21,6 +21,7 @@ import androidx.compose.foundation.gestures.Orientation import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.gestures.draggable import androidx.compose.foundation.gestures.rememberDraggableState +import androidx.compose.foundation.hoverable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.PressInteraction import androidx.compose.foundation.layout.Box @@ -221,9 +222,10 @@ fun Scrollbar( Box( modifier = modifier .run { + val withHover = interactionSource?.let(::hoverable) ?: this when (orientation) { - Orientation.Vertical -> fillMaxHeight() - Orientation.Horizontal -> fillMaxWidth() + Orientation.Vertical -> withHover.fillMaxHeight() + Orientation.Horizontal -> withHover.fillMaxWidth() } } .onGloballyPositioned { coordinates ->