package com.fastest.pass.forgotpassword.utils

import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import com.fastest.pass.R
import com.fastest.pass.forgotpassword.presentation.ui.ForgotPasswordVerifyFragment

class ForgotPasswordVerifyNavigation {

    fun navigate(forgotPasswordVerifyFragment: ForgotPasswordVerifyFragment) {
        forgotPasswordVerifyFragment.lifecycleScope.launchWhenStarted {
            forgotPasswordVerifyFragment.viewmodel.router.collect { router ->
                when (router) {
                    ForgotPasswordVerifyRoute.OpenNoneScreen -> {}
                    ForgotPasswordVerifyRoute.GoBackToForgotPassword -> {
                        forgotPasswordVerifyFragment.findNavController().popBackStack()
                    }
                    ForgotPasswordVerifyRoute.OpenForgotConfirmPasswordScreen -> {
                        forgotPasswordVerifyFragment.findNavController().navigate(R.id.forgotPasswordConfirmFragment)
                    }
                }

                forgotPasswordVerifyFragment.viewmodel.navigateTo(ForgotPasswordVerifyRoute.OpenNoneScreen)
            }
        }
    }

}