package com.vpn.fastestvpnservice

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.rememberNavController
import com.vpn.fastestvpnservice.beans.isDarkTheme
import com.vpn.fastestvpnservice.beans.selectedtheme
import com.vpn.fastestvpnservice.beans.themesList
import com.vpn.fastestvpnservice.navigation.SetUpNavGraph
import com.vpn.fastestvpnservice.ui.theme.FastestVPNTheme
import com.vpn.fastestvpnservice.viewmodels.LoginViewModel

class MainActivity : ComponentActivity() {
    val loginViewModel: LoginViewModel by viewModels()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {

            val isSystemInDarkTheme = isSystemInDarkTheme()
            val systemTheme by remember { mutableStateOf(isSystemInDarkTheme) }
            if (selectedtheme.value == themesList[0])
            {
                Log.d("test_theme", "System 0 -> ${selectedtheme.value}")
                isDarkTheme.value = systemTheme
            }

            FastestVPNTheme(isDarkTheme.value) {
                window.statusBarColor = colorResource(id = R.color.blue_text).toArgb()
                val navController = rememberNavController()
                SetUpNavGraph(navHostController = navController)
            }

        }
    }
}

