package com.example.smartlab

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.example.smartlab.api.RepositoryImpl
import com.example.smartlab.api.RetrofitInstance
import com.example.smartlab.navigation.Navigation
import com.example.smartlab.ui.theme.SmartLabTheme
import com.example.smartlab.viewmodel.ViewModelMain
import kotlin.concurrent.thread

    class MainActivity : ComponentActivity() {
        private val viewModelSmat by viewModels<ViewModelMain>(
            factoryProducer = {
                object : ViewModelProvider.Factory {
                    override fun <T : ViewModel> create(modelClass: Class<T>): T {
                        return ViewModelMain(
                            RepositoryImpl(
                                RetrofitInstance.apiSmartLab
                            )
                        ) as T
                    }
                }
            }
        )

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            SmartLabTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    Navigation(viewModelSmat)
                }
            }
        }
    }
}
