package com.example.triphelper.view.navigation

import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.triphelper.view.Auth.Auth
import com.example.triphelper.view.LawScreen.DescriptionLaws
import com.example.triphelper.view.MainScreen.LawScreen
import com.example.triphelper.view.MainScreen.MainScreen
import com.example.triphelper.view.Registration.Registration

@RequiresApi(Build.VERSION_CODES.O)
@Composable
fun Navigation(controller: NavHostController, barsIsVisible: MutableState<Boolean>,
               iconsLawIsActivity: MutableState<Boolean>, iconsProfileIsActivity: MutableState<Boolean>,
               iconsAdviceIsActivity: MutableState<Boolean>,iconsMainIsActivity: MutableState<Boolean>, iconsRoutsIsActivity: MutableState<Boolean>) {
    NavHost(navController = controller,
        startDestination = NavigationRoutes.LAW)
    {
        composable( NavigationRoutes.AUTH){
            barsIsVisible.value = false
            Auth(controller)
        }
        composable(NavigationRoutes.REG){
            barsIsVisible.value = false
            Registration(controller)
        }
        composable(NavigationRoutes.MAIN){
            barsIsVisible.value = true
            iconsLawIsActivity.value = false
            iconsAdviceIsActivity.value = false
            iconsProfileIsActivity.value = false
            iconsMainIsActivity.value = false
            MainScreen(controller, iconsMainIsActivity)
        }
        composable(NavigationRoutes.LAW){
            barsIsVisible.value = true
            iconsLawIsActivity.value = false
            iconsAdviceIsActivity.value = false
            iconsProfileIsActivity.value = false
            iconsMainIsActivity.value = false
            LawScreen(controller, iconsLawIsActivity)
        }
        composable(route =  "${NavigationRoutes.DESCLAW}/{title}"){
            backStackEntry ->
            val title = backStackEntry.arguments?.getString("title")
            barsIsVisible.value = true
            iconsLawIsActivity.value = false
            iconsAdviceIsActivity.value = false
            iconsProfileIsActivity.value = false
            iconsMainIsActivity.value = false
            if (title != null) {
                DescriptionLaws(controller, iconsLawIsActivity, title)
            }
        }
    }
}