package com.fastest.pass.splash.presentation.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import com.fastest.pass.splash.presentation.ui.components.SplashScreen
import com.fastest.pass.splash.presentation.viewmodels.SplashViewModel
import dagger.hilt.android.AndroidEntryPoint
import androidx.fragment.app.viewModels
import com.fastest.pass.BaseFragment
import com.fastest.pass.splash.utils.SplashNavigation
import com.fastest.pass.splash.utils.SplashRoute
import com.fastest.pass.ui.theme.FastestPassTheme
import javax.inject.Inject

@AndroidEntryPoint
class SplashFragment : BaseFragment() {

    val viewModel: SplashViewModel by viewModels()

    @Inject
    lateinit var navigation : SplashNavigation

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        navigation.navigate(this)
    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        return ComposeView(requireActivity()).apply {
            setContent {

//                viewModel.navigateToLogin.value?.let {
//                    viewModel.navigateTo(SplashRoute.OpenWelcome)
//                }

                viewModel.checkAuthentication()

                FastestPassTheme {
                    SplashScreen(viewModel)
                }
            }
        }
    }
}