package com.fastest.pass.home.utils

import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import com.fastest.pass.R
import com.fastest.pass.home.presentation.ui.fragment.HomeFragment

class HomeNavigation {

    fun navigate(homeFragment: HomeFragment) {
        homeFragment.lifecycleScope.launchWhenStarted {
            homeFragment.viewmodel.router.collect { router ->
               when (router) {
                   HomeRoute.OpenAddNewItemsScreen -> {
                       homeFragment.findNavController().navigate(R.id.addNewItemsFragment)
                   }
                   HomeRoute.OpenNoneScreen -> {}
               }

                homeFragment.viewmodel.navigateTo(HomeRoute.OpenNoneScreen)
            }
        }
    }
}