@@ -5,14 +5,8 @@ package top.yukonga.miuix.kmp.basic
55
66import androidx.compose.foundation.LocalIndication
77import androidx.compose.foundation.background
8- import androidx.compose.foundation.gestures.awaitEachGesture
9- import androidx.compose.foundation.gestures.awaitFirstDown
10- import androidx.compose.foundation.gestures.detectTapGestures
11- import androidx.compose.foundation.gestures.waitForUpOrCancellation
12- import androidx.compose.foundation.hoverable
13- import androidx.compose.foundation.indication
8+ import androidx.compose.foundation.combinedClickable
149import androidx.compose.foundation.interaction.MutableInteractionSource
15- import androidx.compose.foundation.interaction.PressInteraction
1610import androidx.compose.foundation.layout.Box
1711import androidx.compose.foundation.layout.Column
1812import androidx.compose.foundation.layout.ColumnScope
@@ -26,7 +20,6 @@ import androidx.compose.ui.Modifier
2620import androidx.compose.ui.draw.clip
2721import androidx.compose.ui.graphics.Color
2822import androidx.compose.ui.graphics.takeOrElse
29- import androidx.compose.ui.input.pointer.pointerInput
3023import androidx.compose.ui.semantics.isTraversalGroup
3124import androidx.compose.ui.semantics.semantics
3225import androidx.compose.ui.unit.Dp
@@ -104,43 +97,23 @@ fun Card(
10497 val pressFeedbackModifier = remember(pressFeedbackType, interactionSource) {
10598 when (pressFeedbackType) {
10699 PressFeedbackType .None -> Modifier
107- PressFeedbackType .Sink -> Modifier .pressSink(interactionSource)
108- PressFeedbackType .Tilt -> Modifier .pressTilt(interactionSource)
100+ PressFeedbackType .Sink -> Modifier .pressSink(interactionSource, immediate = true )
101+ PressFeedbackType .Tilt -> Modifier .pressTilt(interactionSource, immediate = true )
109102 }
110103 }
111104
112105 BasicCard (
113- modifier = modifier
114- .pointerInput(onClick, onLongPress) {
115- detectTapGestures(
116- onTap = { onClick?.invoke() },
117- onLongPress = { onLongPress?.invoke() }
118- )
119- }
120- .pointerInput(interactionSource) {
121- awaitEachGesture {
122- val pressInteraction: PressInteraction .Press
123- awaitFirstDown().also {
124- pressInteraction = PressInteraction .Press (it.position)
125- interactionSource.tryEmit(pressInteraction)
126- }
127- if (waitForUpOrCancellation() == null ) {
128- interactionSource.tryEmit(PressInteraction .Cancel (pressInteraction))
129- } else {
130- interactionSource.tryEmit(PressInteraction .Release (pressInteraction))
131- }
132- }
133- }
134- .hoverable(interactionSource)
135- .then(pressFeedbackModifier),
106+ modifier = modifier.then(pressFeedbackModifier),
136107 cornerRadius = cornerRadius,
137108 colors = colors
138109 ) {
139110 Column (
140111 modifier = Modifier
141- .indication (
112+ .combinedClickable (
142113 interactionSource = interactionSource,
143- indication = if (showIndication == true ) LocalIndication .current else null
114+ indication = if (showIndication == true ) LocalIndication .current else null ,
115+ onClick = { onClick?.invoke() },
116+ onLongClick = onLongPress
144117 )
145118 .padding(insideMargin),
146119 content = content
0 commit comments