package com.fastest.pass.forgotpassword.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 androidx.fragment.app.viewModels
import com.fastest.pass.forgotpassword.presentation.components.ClickTypeForgotConfirm
import com.fastest.pass.forgotpassword.presentation.components.ForgotPasswordConfirmScreen
import com.fastest.pass.forgotpassword.presentation.viewmodels.ForgotPasswordConfirmViewModel
import com.fastest.pass.forgotpassword.utils.ForgotPasswordConfirmNavigation
import com.fastest.pass.forgotpassword.utils.ForgotPasswordConfirmRoute
import com.fastest.pass.ui.theme.FastestPassTheme
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class ForgotPasswordConfirmFragment : Fragment() {

    val viewmodel: ForgotPasswordConfirmViewModel by viewModels()

    @Inject
    lateinit var navigation: ForgotPasswordConfirmNavigation

    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 {
                FastestPassTheme {
                    ForgotPasswordConfirmScreen { clickTypeForgotConfirm ->
                        when (clickTypeForgotConfirm) {
                            ClickTypeForgotConfirm.GO_BACK -> {
                                viewmodel.navigateTo(ForgotPasswordConfirmRoute.GoBackToForgotVerify)
                            }
                            ClickTypeForgotConfirm.OPEN_LOGIN_SCREEN -> {
                                viewmodel.navigateTo(ForgotPasswordConfirmRoute.OpenLoginScreen)
                            }
                        }
                    }
                }
            }
        }
    }
}