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.flash.Flash
import com.ys.bdtp.adm.mvvm.ui.screen.login.LoginScreen
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


object Main {
    const val Flash = "flash"
    const val Login = "login"
    const val Project = "project"
    const val Task = "task"
    const val Tasks = "tasks"
}

val LocalNavHostController = compositionLocalOf<NavHostController?> { null }

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

    }
}