package com.isidroid.c23.ui.screen.render_preview

import android.net.Uri
import androidx.compose.runtime.Stable
import androidx.compose.ui.unit.IntSize
import com.isidroid.core.vm.ViewEvent
import com.isidroid.core.vm.ViewSideEffect
import com.isidroid.core.vm.ViewState
import com.isidroid.rendering.constant.PrintOrientation
import com.isidroid.rendering.constant.PrintSize
import com.isidroid.rendering.model.RenderSettingsV2
import com.isidroid.spot.model.PrintProfile
import com.isidroid.spot.model.RichSpot

class RenderContract {
    sealed interface Event : ViewEvent {
        data object Click : Event
        data object OpenCopiesSettings : Event
        data object OpenPrintSizeSettings : Event
        data object OpenOrientationSettings : Event
        data object ToBack : Event
        data object OpenMap : Event
        data object OpenListProfiles : Event

        data class OnPageOpened(val page: Int, val containerSize: IntSize?) : Event
        data class UpdateRenderSettings(
            @PrintSize val size: Int? = null,
            @PrintOrientation val orientation: Int? = null,
            val increaseCopy: Boolean? = null
        ) : Event

        data class ChangePrintProfile(val profileId: String?) : Event
    }

    sealed interface Effect : ViewSideEffect {
        sealed interface Navigation : Effect {
            data object ToMap : Navigation
            data object ToBack : Navigation
        }
    }

    @Stable
    data class State(
        val renderSettings: RenderSettingsV2 = RenderSettingsV2(),
        val uris: List<Uri> = emptyList(),
        val printProfile: PrintProfile? = null,
        val renderSeed: Int = 0,
        @PrintSize val openPrintSize: Int? = null,
        @PrintOrientation val openOrientation: Int? = null,
        val openCopies: Int? = null,
        var richSpot: RichSpot? = null,
        val spotHasNoPrintProfiles: Boolean = false,
        val printProfilesSelector: List<PrintProfile>? = null
    ) : ViewState
}