package com.tt.honeyDue.ui.components.common

import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

/**
 * Enforce the Material 3 minimum 48dp touch target on a composable.
 *
 * Applies [defaultMinSize] so the element grows to 48dp when smaller but
 * leaves larger elements untouched. Use around small icon-buttons, pills,
 * and X-remove badges that would otherwise render below the spec.
 */
fun Modifier.minTouchTarget(size: Dp = 48.dp): Modifier =
    this.defaultMinSize(minWidth = size, minHeight = size)

/**
 * `.clickable` with an explicit `MutableInteractionSource` + ambient ripple.
 *
 * The default `.clickable { }` on non-Material containers (Box, Column, Row)
 * omits ripple feedback entirely, which hurts perceived responsiveness on
 * Android. Use this helper to get the same ripple pattern as Material
 * buttons while retaining full Modifier chain composability.
 *
 * @param enabled whether the click is currently active.
 * @param onClickLabel a11y label describing the action (prefer something
 *   meaningful, e.g. "Remove photo", over passing null).
 * @param onClick the click handler.
 */
fun Modifier.clickableWithRipple(
    enabled: Boolean = true,
    onClickLabel: String? = null,
    onClick: () -> Unit,
): Modifier = composed {
    this.clickable(
        interactionSource = remember { MutableInteractionSource() },
        indication = LocalIndication.current,
        enabled = enabled,
        onClickLabel = onClickLabel,
        onClick = onClick,
    )
}
