package com.syaroful.agrilinkvocpro.control_feature

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.navigation.compose.rememberNavController
import com.syaroful.agrilinkvocpro.control_feature.di.controlModule
import com.syaroful.agrilinkvocpro.control_feature.di.networkModule
import com.syaroful.agrilinkvocpro.control_feature.di.viewModelModule
import com.syaroful.agrilinkvocpro.control_feature.navigation.NavGraph
import com.syaroful.agrilinkvocpro.control_feature.ui.theme.AgrilinkVocproTheme
import org.koin.core.context.loadKoinModules
import org.koin.core.context.unloadKoinModules

class ControlActuatorActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        // load Module
        loadKoinModules(listOf(controlModule, networkModule, viewModelModule))
        Log.d("KOIN_DEBUG", "✅ controlModule loaded, yeay 🤗")
        enableEdgeToEdge()
        setContent {
            AgrilinkVocproTheme {
                val navController = rememberNavController()
                NavGraph(navController)
            }
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        unloadKoinModules(listOf(controlModule, networkModule, viewModelModule))
        Log.d("KOIN_DEBUG", "🧹 controlModule unloaded")
    }
}
