package com.craigvg.lichun_android.utils import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.composed import androidx.compose.ui.platform.LocalView /** * Compose modifier extensions for haptic feedback * Ported from iOS View+Haptics.swift */ /** * Clickable with light haptic feedback on tap. */ fun Modifier.hapticClickable( style: HapticStyle = HapticStyle.LIGHT, onClick: () -> Unit ): Modifier = composed { val view = LocalView.current this.clickable { when (style) { HapticStyle.LIGHT -> HapticFeedback.light(view) HapticStyle.MEDIUM -> HapticFeedback.medium(view) HapticStyle.HEAVY -> HapticFeedback.heavy(view) HapticStyle.SUCCESS -> HapticFeedback.success(view) } onClick() } } /** * Clickable with no ripple and haptic feedback. */ fun Modifier.hapticClickableNoRipple( style: HapticStyle = HapticStyle.LIGHT, onClick: () -> Unit ): Modifier = composed { val view = LocalView.current val interactionSource = remember { MutableInteractionSource() } this.clickable( interactionSource = interactionSource, indication = null ) { when (style) { HapticStyle.LIGHT -> HapticFeedback.light(view) HapticStyle.MEDIUM -> HapticFeedback.medium(view) HapticStyle.HEAVY -> HapticFeedback.heavy(view) HapticStyle.SUCCESS -> HapticFeedback.success(view) } onClick() } } /** * Haptic feedback style enum matching iOS HapticStyle. */ enum class HapticStyle { LIGHT, MEDIUM, HEAVY, SUCCESS }