package com.tt.honeyDue.ui.animation

/**
 * P5 Stream R — pure-Kotlin state holder for the dev-only animation
 * testing screen. Mirrors the behavior of the iOS
 * `AnimationTestingView.swift`.
 *
 * Kept free of Compose types so commonTest can exercise it without a
 * runtime. The Compose composable [com.tt.honeyDue.ui.screens.dev.AnimationTestingScreen]
 * wraps an instance of this class in `remember { mutableStateOf(...) }`.
 */
class AnimationTestingScreenState {

    /** Every registered animation the screen will list. */
    val available: List<TaskAnimations.TaskAnimationSpec> = TaskAnimations.all

    /** Currently-selected row, or null when nothing has been tapped yet. */
    var selected: TaskAnimations.TaskAnimationSpec? = null
        private set

    /** Number of times the user has hit "Play" on [selected]. */
    var playCount: Int = 0
        private set

    /** Select a row. Swapping selection simply replaces the previous value. */
    fun onRowTap(spec: TaskAnimations.TaskAnimationSpec) {
        selected = spec
    }

    /** Fire the "Play" action. No-op when nothing is selected — this
     *  matches the iOS disabled-button behavior without a separate
     *  enabled flag. */
    fun onPlay() {
        if (selected == null) return
        playCount += 1
    }

    /** Reset to launch state. */
    fun onReset() {
        selected = null
        playCount = 0
    }
}
