mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-05 12:54:35 +00:00
Fix wrong selection behaviour
This commit is contained in:
+20
-12
@@ -110,8 +110,27 @@ fun EmojiItem(
|
|||||||
.background(backgroundColor, CircleShape)
|
.background(backgroundColor, CircleShape)
|
||||||
.indication(interactionSource, ripple())
|
.indication(interactionSource, ripple())
|
||||||
.pointerInput(item) {
|
.pointerInput(item) {
|
||||||
|
// Always detect long press and tap gestures
|
||||||
|
detectTapGestures(
|
||||||
|
onPress = { pressOffset ->
|
||||||
|
val press = PressInteraction.Press(pressOffset)
|
||||||
|
interactionSource.emit(press)
|
||||||
|
if (tryAwaitRelease()) {
|
||||||
|
interactionSource.emit(PressInteraction.Release(press))
|
||||||
|
if (hasSkinTones) {
|
||||||
|
onSelectEmoji(item)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
interactionSource.emit(PressInteraction.Cancel(press))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onTap = { onSelectEmoji(item) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.then(
|
||||||
// Only detect drag after long press for those items which have a skin tone picker
|
// Only detect drag after long press for those items which have a skin tone picker
|
||||||
if (hasSkinTones) {
|
if (hasSkinTones) {
|
||||||
|
Modifier.pointerInput(item) {
|
||||||
val slotWidthPx = with(density) { SkinToneSlotSize.toPx() }
|
val slotWidthPx = with(density) { SkinToneSlotSize.toPx() }
|
||||||
val spacingPx = with(density) { SkinToneSlotSpacing.toPx() }
|
val spacingPx = with(density) { SkinToneSlotSpacing.toPx() }
|
||||||
val paddingPx = with(density) { SkinTonePadding.toPx() }
|
val paddingPx = with(density) { SkinTonePadding.toPx() }
|
||||||
@@ -186,21 +205,10 @@ fun EmojiItem(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always detect long press and tap gestures
|
|
||||||
detectTapGestures(
|
|
||||||
onPress = { pressOffset ->
|
|
||||||
val press = PressInteraction.Press(pressOffset)
|
|
||||||
interactionSource.emit(press)
|
|
||||||
if (tryAwaitRelease()) {
|
|
||||||
interactionSource.emit(PressInteraction.Release(press))
|
|
||||||
} else {
|
} else {
|
||||||
interactionSource.emit(PressInteraction.Cancel(press))
|
Modifier
|
||||||
}
|
}
|
||||||
},
|
|
||||||
onTap = { onSelectEmoji(item) },
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
.clearAndSetSemantics {
|
.clearAndSetSemantics {
|
||||||
contentDescription = description
|
contentDescription = description
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user