package com.pixelized.desktop.lwa.ui.navigation.screen

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.rememberNavController
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.SplashDestination
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.composableSplash
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.composableLevelUp
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.composableMainPage
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.composableSettingsPage

val LocalScreenController = compositionLocalOf<NavHostController> {
    error("MainNavHost controller is not yet ready")
}

@Composable
fun MainNavHost(
    controller: NavHostController = rememberNavController(),
    startDestination: String = SplashDestination.navigationRoute(),
) {
    CompositionLocalProvider(
        LocalScreenController provides controller,
    ) {
        NavHost(
            navController = controller,
            startDestination = startDestination,
        ) {
            composableSplash()
            composableMainPage()
            composableSettingsPage()
            composableLevelUp()
        }
    }
}