Milan Jurkulak 2 лет назад
Родитель
Сommit
a8ce1b502c

+ 22 - 0
tvlib/src/main/kotlin/org/mjdev/tvlib/extensions/ModifierExt.kt

@@ -57,6 +57,28 @@ import kotlin.math.abs
 @Suppress("MemberVisibilityCanBePrivate")
 object ModifierExt {
 
+//    private val VerticalScrollConsumer = object : NestedScrollConnection {
+//        override fun onPreScroll(available: Offset, source: NestedScrollSource) =
+//            available.copy(x = 0f)
+//        override suspend fun onPreFling(available: Velocity) =
+//            available.copy(x = 0f)
+//    }
+
+//    private val HorizontalScrollConsumer = object : NestedScrollConnection {
+//        override fun onPreScroll(available: Offset, source: NestedScrollSource) =
+//            available.copy(y = 0f)
+//        override suspend fun onPreFling(available: Velocity) =
+//            available.copy(y = 0f)
+//    }
+
+//    fun Modifier.disabledVerticalPointerInputScroll(
+//        disabled: Boolean = true
+//    ) = if (disabled) this.nestedScroll(VerticalScrollConsumer) else this
+
+//    fun Modifier.disabledHorizontalPointerInputScroll(
+//        disabled: Boolean = true
+//    ) = if (disabled) this.nestedScroll(HorizontalScrollConsumer) else this
+
     @Composable
     fun Modifier.conditional(
         condition: Boolean,

+ 3 - 3
tvlib/src/main/kotlin/org/mjdev/tvlib/ui/components/complex/VerticalScrollableBox.kt

@@ -9,7 +9,7 @@
 package org.mjdev.tvlib.ui.components.complex
 
 import android.annotation.SuppressLint
-import androidx.compose.foundation.gestures.detectDragGestures
+import androidx.compose.foundation.gestures.detectVerticalDragGestures
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.BoxScope
 import androidx.compose.runtime.Composable
@@ -38,8 +38,8 @@ fun VerticalScrollableBox(
     Box(
         modifier = modifier
             .pointerInput(Unit) {
-                detectDragGestures { _, dragAmount ->
-                    scrollDelta.value = dragAmount.y
+                detectVerticalDragGestures { _, dragAmount ->
+                    scrollDelta.value = dragAmount
                 }
             }
             .recomposeHighlighter(),

+ 3 - 3
tvlib/src/main/kotlin/org/mjdev/tvlib/ui/components/tv/CategoryRow.kt

@@ -10,7 +10,7 @@ package org.mjdev.tvlib.ui.components.tv
 
 import android.annotation.SuppressLint
 import androidx.compose.foundation.background
-import androidx.compose.foundation.gestures.detectDragGestures
+import androidx.compose.foundation.gestures.detectHorizontalDragGestures
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Column
 import androidx.compose.foundation.layout.fillMaxWidth
@@ -84,8 +84,8 @@ fun CategoryRow(
             modifier = Modifier
                 .fillMaxWidth()
                 .pointerInput(Unit) {
-                    detectDragGestures { _, dragAmount ->
-                        scrollDelta.value = dragAmount.x
+                    detectHorizontalDragGestures { _, dragAmount ->
+                        scrollDelta.value = dragAmount
                     }
                 }
                 .recomposeHighlighter(),