package llc.arma.ble.app.ui.screen.ble

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.Ble
import llc.arma.ble.domain.model.BleInfo
import llc.arma.ble.domain.model.ConnectedBleInfo

class BleListContract {

    sealed class Event : ViewEvent {

        object OnResetFilter : Event()

        object OnHideFilter : Event()

        object OnShowFilter : Event()

        data class OnConnectToBle(
            val bleAddress: String
        ) : Event()

        data class OnRssiRangeChanged(
            val rssi: ClosedFloatingPointRange<Float>
        ) : Event()

        data class OnMacFilterChanged(
            val mac: String
        ) : Event()

        data class OnNameFilterChanged(
            val name: String
        ) : Event()

        data class OnTypeChanged(
            val type: BleInfo.Type?
        ) : Event()

    }

    data class State(
        val connectedBleList: List<ConnectedBleInfo>,
        val bleList: List<BleInfo>,
        val filter: Filter
    ) : ViewState {

        data class Filter(
            val name: String = "",
            val mac: String = "",
            val rssi: ClosedFloatingPointRange<Float> = (-100f)..(-10f),
            val bleType: BleInfo.Type? = null
        )

    }

    sealed class Effect : ViewSideEffect {

        object ShowFilter : Effect()

        object HideFilter : Effect()

        sealed class Navigation : Effect() {

            data class NavigateToBle(
                val serial: String
            ) : Navigation()

        }

    }

}