package llc.arma.ble.app.ui.screen.inspection.host.view.table

import llc.arma.ble.app.ui.common.ViewEvent
import llc.arma.ble.app.ui.common.ViewSideEffect
import llc.arma.ble.app.ui.common.ViewState
import llc.arma.ble.domain.model.BleInfo
import llc.arma.ble.domain.model.BleName

class BleTableEditContract {

    sealed class Event : ViewEvent {

        data object OnHideWritePreview: Event()

        data object OnWritePreview: Event()

        data object OnWrite: Event()

        data class OnStart(
            val serial: String
        ) : Event()

        data class OnAddBle(
            val ble: BleName
        ) : Event()

    }

    sealed class State : ViewState {

        data object Loading : State()

        data object Error : State()

        data class Display(
            val bleAround: List<BleInfo>,
            val newTable: List<BleName>,
            val savedBleTable: List<BleName>,
            val writeState: WriteState?
        ) : State() {

            sealed class WriteState {

                data class DisplayPreview(
                    val writeRequest: List<BleName>
                ) : WriteState()

                data class Writing(
                    val writeRequest: List<BleName>
                ) : WriteState()

                data object Success : WriteState()

                data object Failure : WriteState()

            }

        }

    }

    sealed class Effect : ViewSideEffect {

        sealed class Navigation : Effect() {

            data object NavigateUp : Navigation()

        }

    }

}