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.BaseFragment
import com.fastest.pass.forgotpassword.presentation.ui.components.ClickTypeForgotVerify
import com.fastest.pass.forgotpassword.presentation.ui.components.ForgotPasswordVerifyScreen
import com.fastest.pass.forgotpassword.presentation.viewmodels.ForgotPasswordVerifyViewModel
import com.fastest.pass.forgotpassword.utils.ForgotPasswordVerifyNavigation
import com.fastest.pass.forgotpassword.utils.ForgotPasswordVerifyRoute
import com.fastest.pass.ui.theme.FastestPassTheme
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class ForgotPasswordVerifyFragment : BaseFragment() {

    val viewmodel: ForgotPasswordVerifyViewModel by viewModels()

    @Inject
    lateinit var navigation: ForgotPasswordVerifyNavigation

    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 {
                    ForgotPasswordVerifyScreen { clickTypeForgotVerify ->
                        when (clickTypeForgotVerify) {
                            ClickTypeForgotVerify.GO_BACK -> {
                                viewmodel.navigateTo(ForgotPasswordVerifyRoute.GoBackToForgotPassword)
                            }
                            ClickTypeForgotVerify.GO_TO_CONFIRM_PASSWORD -> {
                                viewmodel.navigateTo(ForgotPasswordVerifyRoute.OpenForgotConfirmPasswordScreen)
                            }
                        }
                    }
                }
            }
        }
    }


}