Skip to content

Commit 9dac1b0

Browse files
authored
Use combinedClickable as basis of UnboundedRippleButton (#2531)
This allows users of user of UnboundedRippleButton to use features like long press.
1 parent 3bf122c commit 9dac1b0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Diff for: composables/api/current.api

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ package com.google.android.horologist.composables {
161161
}
162162

163163
public final class UnboundedRippleButtonKt {
164-
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void UnboundedRippleButton(kotlin.jvm.functions.Function0<kotlin.Unit> onClick, optional androidx.compose.ui.Modifier modifier, optional float rippleRadius, optional boolean enabled, optional androidx.wear.compose.material.ButtonColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.compose.ui.graphics.Shape shape, optional androidx.wear.compose.material.ButtonBorder border, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.BoxScope,kotlin.Unit> content);
164+
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void UnboundedRippleButton(kotlin.jvm.functions.Function0<kotlin.Unit> onClick, optional androidx.compose.ui.Modifier modifier, optional float rippleRadius, optional boolean enabled, optional androidx.wear.compose.material.ButtonColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.compose.ui.graphics.Shape shape, optional androidx.wear.compose.material.ButtonBorder border, optional kotlin.jvm.functions.Function0<kotlin.Unit> onLongClick, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.BoxScope,kotlin.Unit> content);
165165
}
166166

167167
}

Diff for: composables/src/main/java/com/google/android/horologist/composables/UnboundedRippleButton.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package com.google.android.horologist.composables
1818

1919
import androidx.compose.foundation.background
2020
import androidx.compose.foundation.border
21-
import androidx.compose.foundation.clickable
21+
import androidx.compose.foundation.combinedClickable
2222
import androidx.compose.foundation.interaction.MutableInteractionSource
2323
import androidx.compose.foundation.layout.Box
2424
import androidx.compose.foundation.layout.BoxScope
@@ -60,6 +60,7 @@ public fun UnboundedRippleButton(
6060
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
6161
shape: Shape = CircleShape,
6262
border: ButtonBorder = ButtonDefaults.buttonBorder(),
63+
onLongClick: (() -> Unit)? = null,
6364
content: @Composable BoxScope.() -> Unit,
6465
) {
6566
val borderStroke = border.borderStroke(enabled = enabled).value
@@ -78,7 +79,7 @@ public fun UnboundedRippleButton(
7879
Modifier
7980
},
8081
)
81-
.clickable(
82+
.combinedClickable(
8283
interactionSource = interactionSource,
8384
indication = ripple(
8485
bounded = false,
@@ -87,6 +88,7 @@ public fun UnboundedRippleButton(
8788
onClick = {
8889
onClick()
8990
},
91+
onLongClick = onLongClick,
9092
role = Role.Button,
9193
enabled = enabled,
9294
)

0 commit comments

Comments
 (0)