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

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import com.pixelized.desktop.lwa.ui.navigation.screen.LocalScreenController
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.composableLevelUp
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.gamemaster.GameMasterDestination
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.gamemaster.composableGameMasterAlterationEditPage
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.gamemaster.composableGameMasterCharacterEditPage
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.gamemaster.composableGameMasterItemEditPage
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.gamemaster.composableGameMasterMainPage
import com.pixelized.desktop.lwa.ui.navigation.screen.destination.gamemaster.composableGameMasterMapEditPage

val LocalGMScreenController = compositionLocalOf<NavHostController> {
    error("GameMaster NavHost controller is not yet ready")
}

@Composable
fun GameMasterNavHost() {
    val controller = rememberNavController()

    CompositionLocalProvider(
        LocalScreenController provides controller,
        LocalGMScreenController provides rememberNavController(),
    ) {
        Surface(
            modifier = Modifier.fillMaxSize()
        ) {
            NavHost(
                modifier = Modifier.fillMaxSize(),
                navController = controller,
                startDestination = GameMasterDestination.navigationRoute(),
            ) {
                composableGameMasterMainPage()

                composableGameMasterCharacterEditPage()
                composableGameMasterAlterationEditPage()
                composableGameMasterItemEditPage()
                composableGameMasterMapEditPage()

                composableLevelUp()
            }
        }
    }
}