mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-07 19:14:12 +08:00
feat: add combinedClickable, rippleCombinedClickable in Interaction
This commit is contained in:
@@ -36,6 +36,7 @@ import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import com.highcapable.flexiui.LocalColors
|
||||
import androidx.compose.foundation.clickable as foundationClickable
|
||||
import androidx.compose.foundation.combinedClickable as foundationCombinedClickable
|
||||
import androidx.compose.foundation.selection.selectable as foundationSelectable
|
||||
import androidx.compose.foundation.selection.toggleable as foundationToggleable
|
||||
import androidx.compose.material.ripple.rememberRipple as materialRememberRipple
|
||||
@@ -60,6 +61,19 @@ fun Modifier.clickable(
|
||||
onClick: () -> Unit
|
||||
) = foundationClickable(interactionSource, indication, enabled, onClickLabel, role, onClick)
|
||||
|
||||
@Composable
|
||||
fun Modifier.combinedClickable(
|
||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||
indication: Indication? = null,
|
||||
enabled: Boolean = true,
|
||||
onClickLabel: String? = null,
|
||||
role: Role? = null,
|
||||
onLongClickLabel: String? = null,
|
||||
onLongClick: (() -> Unit)? = null,
|
||||
onDoubleClick: (() -> Unit)? = null,
|
||||
onClick: () -> Unit
|
||||
) = foundationCombinedClickable(interactionSource, indication, enabled, onClickLabel, role, onLongClickLabel, onLongClick, onDoubleClick, onClick)
|
||||
|
||||
@Composable
|
||||
fun Modifier.toggleable(
|
||||
value: Boolean,
|
||||
@@ -97,6 +111,29 @@ fun Modifier.rippleClickable(
|
||||
role = role
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun Modifier.rippleCombinedClickable(
|
||||
rippleStyle: RippleStyle = Interaction.rippleStyle,
|
||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||
enabled: Boolean = true,
|
||||
onClickLabel: String? = null,
|
||||
role: Role? = null,
|
||||
onLongClickLabel: String? = null,
|
||||
onLongClick: (() -> Unit)? = null,
|
||||
onDoubleClick: (() -> Unit)? = null,
|
||||
onClick: () -> Unit
|
||||
) = combinedClickable(
|
||||
interactionSource = interactionSource,
|
||||
indication = rememberRipple(rippleStyle),
|
||||
enabled = enabled,
|
||||
onClickLabel = onClickLabel,
|
||||
role = role,
|
||||
onLongClickLabel = onLongClickLabel,
|
||||
onLongClick = onLongClick,
|
||||
onDoubleClick = onDoubleClick,
|
||||
onClick = onClick
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun Modifier.rippleToggleable(
|
||||
value: Boolean,
|
||||
|
Reference in New Issue
Block a user