package com.fastest.pass.splash.presentation.viewmodels

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.fastest.pass.splash.domain.usecase.SplashUseCase
import com.fastest.pass.splash.utils.SplashRoute
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class SplashViewModel @Inject constructor(var splashUseCase: SplashUseCase) : ViewModel() {

    private val _navigateToLogin = MutableLiveData<Boolean>(false)
    val navigateToLogin: LiveData<Boolean> = _navigateToLogin

    private val _router = MutableStateFlow<SplashRoute>(SplashRoute.NoneScreen)
    val router :MutableStateFlow<SplashRoute> = _router

    fun checkAuthentication() {
        viewModelScope.launch {
            delay(2000)
            navigateTo(SplashRoute.OpenWelcome)
//            _navigateToLogin.value = true
        }
    }

    fun navigateTo(splashRoute: SplashRoute) {
        _router.value = splashRoute
    }
}