From e55ab9116bfaf883ce4ec081d4cdf1930d36d1f1 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Fri, 2 Sep 2022 19:42:20 +0200 Subject: [PATCH] Use pointerInput instead of combinedClickable because it's fucking laggy --- .../ui/component/ShapedLauncherIcon.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/ShapedLauncherIcon.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/ShapedLauncherIcon.kt index 6600b1dd..3878c922 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/ShapedLauncherIcon.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/ShapedLauncherIcon.kt @@ -9,6 +9,7 @@ import androidx.compose.animation.core.LinearEasing import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.tween import androidx.compose.foundation.* +import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding @@ -31,6 +32,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.drawscope.drawIntoCanvas import androidx.compose.ui.graphics.drawscope.scale import androidx.compose.ui.graphics.drawscope.withTransform +import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.Dp @@ -91,13 +93,12 @@ fun ShapedLauncherIcon( clip = currentIcon?.backgroundLayer !is TransparentLayer this.shape = shape } - .combinedClickable( - enabled = onClick != null || onLongClick != null, - onClick = { - onClick?.invoke() - }, - onLongClick = onLongClick, - ), + .pointerInput(null) { + detectTapGestures( + onLongPress = { onLongClick?.invoke() }, + onTap = { onClick?.invoke() }, + ) + }, contentAlignment = Alignment.Center ) { currentIcon?.let { @@ -123,13 +124,12 @@ fun ShapedLauncherIcon( modifier = Modifier .size(size * 0.33f) .align(Alignment.BottomEnd) - .combinedClickable( - enabled = onClick != null || onLongClick != null, - onClick = { - onClick?.invoke() - }, - onLongClick = onLongClick, - ), + .pointerInput(null) { + detectTapGestures( + onLongPress = { onLongClick?.invoke() }, + onTap = { onClick?.invoke() }, + ) + }, color = MaterialTheme.colorScheme.secondary, shape = CircleShape ) {