package com.ys.bdtp.adm.mvvm.ui.screen.main

import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.ys.bdtp.adm.mvvm.ui.screen.cad.CadScreen
import com.ys.bdtp.adm.mvvm.ui.screen.flash.Flash
import com.ys.bdtp.adm.mvvm.ui.screen.login.LoginScreen
import com.ys.bdtp.adm.mvvm.ui.screen.offline.Offline
import com.ys.bdtp.adm.mvvm.ui.screen.project.Project
import com.ys.bdtp.adm.mvvm.ui.screen.task.Task
import com.ys.bdtp.adm.mvvm.ui.screen.task.Tasks

val LocalNavHostController = compositionLocalOf<NavHostController?> { null }

@Composable
fun Main() {
    val navController = rememberNavController()
    CompositionLocalProvider(LocalNavHostController provides navController) {
        NavHost(navController = navController, startDestination = Route.Flash) {
            composable(Route.Flash) {
                Flash()
            }
            composable(Route.Login) {
                LoginScreen()
            }
            composable(Route.Project) {
                Project()
            }
            composable("${Route.Task}/{projectId}") { backStackEntry ->
                Task(backStackEntry.arguments?.getString("projectId")!!)
            }
            composable(Route.Tasks) {
                Tasks()
            }
            composable("${Route.Offline}/{projectId}") { backStackEntry ->
                Offline(backStackEntry.arguments?.getString("projectId")!!)
            }
            composable("${Route.Cad}/{projectId}") { backStackEntry ->
                CadScreen(backStackEntry.arguments?.getString("projectId")!!)
            }
        }
    }
}