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

import llc.arma.ble.app.ui.common.ViewEvent
import llc.arma.ble.app.ui.common.ViewSideEffect
import llc.arma.ble.app.ui.common.ViewState

class ChangePasswordContract {

    sealed class Event : ViewEvent {

        data class OnPasswordChanged(
            val password: String
        ) : Event()

        data class OnRePasswordChanged(
            val password: String
        ) : Event()

        object OnChange : Event()

        object OnNavigateUp : Event()

    }

    data class State(
        val password: String,
        val rePassword: String,
        val exception: ValidationException?,
        val loading: LoadingState?
    ) : ViewState {

        sealed class LoadingState {

            object Loading : LoadingState()

            object Success : LoadingState()

            object Failure : LoadingState()

        }

        sealed class ValidationException {

            object PasswordsNotMatch : ValidationException()

            object WrongLength : ValidationException()

        }

    }

    sealed class Effect : ViewSideEffect {

        sealed class Navigation : Effect() {

            object NavigateUp : Navigation()

        }

    }

}