package com.example.pmulabs.graphs

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.example.pmulabs.basecomponents.navigate.ARTICLE_ARGUMENT_KEY
import com.example.pmulabs.basecomponents.navigate.BottomBarScreen
import com.example.pmulabs.basecomponents.navigate.CALENDAR_ARGUMENT_DATE
import com.example.pmulabs.basecomponents.navigate.SEARCHBYTAG_ARGUMENT_KEY
import com.example.pmulabs.basecomponents.navigate.SEARCH_ARGUMENT_TEXT
import com.example.pmulabs.screensMobile.ArticlePageScreen
import com.example.pmulabs.screensMobile.CoopScreen
import com.example.pmulabs.screensMobile.InfoScreen
import com.example.pmulabs.screensMobile.MainScreen
import com.example.pmulabs.screensMobile.ProfileScreen
import com.example.pmulabs.screensMobile.TagsScreen
import com.example.pmulabs.screensMobile.filterScreens.CalendarScreen
import com.example.pmulabs.screensMobile.filterScreens.SearchByTagScreen
import com.example.pmulabs.screensMobile.filterScreens.SearchScreen
import com.example.pmulabs.viewModels.AppViewModelProvider
import com.example.pmulabs.viewModels.ArticlePageScreenViewModel
import com.example.pmulabs.viewModels.ArticleScreenViewModel
import com.example.pmulabs.viewModels.CurrentUserViewModel
import com.example.pmulabs.viewModels.TagItemViewModel

@Composable
fun HomeNavGraph(navController: NavHostController,articlePageScreenViewModel: ArticlePageScreenViewModel = viewModel(factory = AppViewModelProvider.Factory), tagItemViewModel: TagItemViewModel = viewModel(factory = AppViewModelProvider.Factory), articleScreenViewModel: ArticleScreenViewModel= viewModel(factory = AppViewModelProvider.Factory), currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory)){
    NavHost(
        navController = navController,
        route = Graph.MAIN,
        startDestination = BottomBarScreen.Main.route
        ){
        composable(
            route=BottomBarScreen.Main.route
            ){
            MainScreen(navController,Modifier,articleScreenViewModel,currentUserViewModel)
        }
        composable(
            route=BottomBarScreen.SearchByTag.route,
            arguments = listOf(navArgument(SEARCHBYTAG_ARGUMENT_KEY){
                type= NavType.StringType
            })
        ){
            SearchByTagScreen(navController,Modifier,articleScreenViewModel,currentUserViewModel)
        }
        composable(
            route=BottomBarScreen.ArticlePage.route,
            arguments = listOf(navArgument(ARTICLE_ARGUMENT_KEY){
                type= NavType.StringType
            })
        ){
            ArticlePageScreen(navController,Modifier,articlePageScreenViewModel,currentUserViewModel)
        }
        composable(
            route=BottomBarScreen.Search.route,
            arguments = listOf(navArgument(SEARCH_ARGUMENT_TEXT){
                type= NavType.StringType
            })
        ){
            SearchScreen(navController,Modifier,articleScreenViewModel,currentUserViewModel)
        }
        composable(
            route=BottomBarScreen.Calendar.route,
            arguments = listOf(navArgument(CALENDAR_ARGUMENT_DATE){
                type= NavType.StringType
            })
        ){
            CalendarScreen(navController,articleScreenViewModel,Modifier,currentUserViewModel)
        }
        composable(route=BottomBarScreen.Profile.route){
            ProfileScreen(navController,Modifier,articleScreenViewModel, tagItemViewModel, articlePageScreenViewModel,currentUserViewModel)
        }
        composable(route=BottomBarScreen.Info.route){
            InfoScreen(navController,Modifier)
        }
        composable(route=BottomBarScreen.Cooperation.route){
            CoopScreen(navController,Modifier)
        }
        composable(route=BottomBarScreen.Categories.route){
            TagsScreen(navController,Modifier, tagItemViewModel, currentUserViewModel)
        }
    }
}