Use pointerInput instead of combinedClickable

because it's fucking laggy
This commit is contained in:
MM20 2022-09-02 19:42:20 +02:00
parent 6e411e9555
commit e55ab9116b
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389

View File

@ -9,6 +9,7 @@ import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween import androidx.compose.animation.core.tween
import androidx.compose.foundation.* import androidx.compose.foundation.*
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding 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.drawIntoCanvas
import androidx.compose.ui.graphics.drawscope.scale import androidx.compose.ui.graphics.drawscope.scale
import androidx.compose.ui.graphics.drawscope.withTransform import androidx.compose.ui.graphics.drawscope.withTransform
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
@ -91,13 +93,12 @@ fun ShapedLauncherIcon(
clip = currentIcon?.backgroundLayer !is TransparentLayer clip = currentIcon?.backgroundLayer !is TransparentLayer
this.shape = shape this.shape = shape
} }
.combinedClickable( .pointerInput(null) {
enabled = onClick != null || onLongClick != null, detectTapGestures(
onClick = { onLongPress = { onLongClick?.invoke() },
onClick?.invoke() onTap = { onClick?.invoke() },
}, )
onLongClick = onLongClick, },
),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
currentIcon?.let { currentIcon?.let {
@ -123,13 +124,12 @@ fun ShapedLauncherIcon(
modifier = Modifier modifier = Modifier
.size(size * 0.33f) .size(size * 0.33f)
.align(Alignment.BottomEnd) .align(Alignment.BottomEnd)
.combinedClickable( .pointerInput(null) {
enabled = onClick != null || onLongClick != null, detectTapGestures(
onClick = { onLongPress = { onLongClick?.invoke() },
onClick?.invoke() onTap = { onClick?.invoke() },
}, )
onLongClick = onLongClick, },
),
color = MaterialTheme.colorScheme.secondary, color = MaterialTheme.colorScheme.secondary,
shape = CircleShape shape = CircleShape
) { ) {