package com.tt.honeyDue.ui.haptics

/**
 * The full haptic taxonomy, modeled after iOS:
 *   - LIGHT / MEDIUM / HEAVY → UIImpactFeedbackGenerator(style:)
 *   - SUCCESS / WARNING / ERROR → UINotificationFeedbackGenerator
 */
enum class HapticEvent { LIGHT, MEDIUM, HEAVY, SUCCESS, WARNING, ERROR }

/**
 * Pluggable backend so tests can swap out platform-specific mechanisms
 * (Vibrator/HapticFeedbackConstants on Android, UI*FeedbackGenerator on iOS).
 */
interface HapticBackend {
    fun perform(event: HapticEvent)
}

/** Backend that does nothing — used on JVM/Web/test fallbacks. */
object NoopHapticBackend : HapticBackend {
    override fun perform(event: HapticEvent) { /* no-op */ }
}

/**
 * Cross-platform haptic feedback API.
 *
 * Call-sites in common code stay terse:
 *   - [Haptics.light]   — selection/tap (iOS UIImpactFeedbackGenerator.light)
 *   - [Haptics.medium]  — confirmations
 *   - [Haptics.heavy]   — important actions
 *   - [Haptics.success] — positive completion (iOS UINotificationFeedbackGenerator.success)
 *   - [Haptics.warning] — caution
 *   - [Haptics.error]   — validation / failure
 *
 * Each platform provides a default [HapticBackend]. Tests may override via
 * [Haptics.setBackend] and restore via [Haptics.resetBackend].
 */
expect object Haptics {
    fun light()
    fun medium()
    fun heavy()
    fun success()
    fun warning()
    fun error()

    /** Override the active backend (for tests or custom delegation). */
    fun setBackend(backend: HapticBackend)

    /** Restore the platform default backend. */
    fun resetBackend()
}
