package com.isidroid.c23.ui.navigation

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import com.isidroid.c23.constant.Argument
import com.isidroid.c23.ext.BasicNavHost
import com.isidroid.c23.ext.isDebug
import com.isidroid.c23.ext.makeNavArgument
import com.isidroid.c23.ui.navigation.destinations.ContentScreenDestination
import com.isidroid.c23.ui.navigation.destinations.HomeScreenDestination
import com.isidroid.c23.ui.navigation.destinations.MapScreenDestination
import com.isidroid.c23.ui.navigation.destinations.PrintJobsScreenDestination
import com.isidroid.c23.ui.navigation.destinations.RenderScreenDestination

@Composable
fun AppNavHost(
    navController: NavHostController,
    modifier: Modifier = Modifier
) {
    val startDestination = if (isDebug()) Home.route else Home.route

    BasicNavHost(
        navController = navController,
        startDestination = startDestination,
        modifier = modifier,
    ) {
        composable(route = Home.route) { HomeScreenDestination(navController) }
        composable(route = routeSelectContent()) { ContentScreenDestination(navController) }
        composable(route = routePrintJobs()) { PrintJobsScreenDestination(navController) }

        composable(
            route = routeRenderPreview(uris = "{${Argument.URI}}"),
            arguments = listOf(makeNavArgument(Argument.URI, NavType.StringType)),
            content = { RenderScreenDestination(navController) }
        )

        composable(
            route = routeMap(lat = "{${Argument.LATITUDE}}", lng = "{${Argument.LONGITUDE}}", spotCode = "{${Argument.SPOT_CODE}}"),
            arguments = listOf(
                makeNavArgument(Argument.LATITUDE, NavType.StringType, nullable = true),
                makeNavArgument(Argument.LONGITUDE, NavType.StringType, nullable = true),
                makeNavArgument(Argument.SPOT_CODE, NavType.StringType, nullable = true),
            ),
            content = { MapScreenDestination(navController) }
        )
    }
}

