package com.example.development

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import com.example.development.mainActivity.components.RegistrationScreen
import com.example.development.ui.theme.DevelopmentTheme
import com.example.development.mainActivity.MainViewModel
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.development.mainActivity.components.AuthorizationScreen
import com.example.development.mainActivity.components.UserProfileForUnauthorizedUser

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent { val viewModel = MainViewModel()
            DevelopmentTheme {
                Surface(color = MaterialTheme.colorScheme.background) {
                    val navController = rememberNavController()

                    NavHost(
                        navController = navController,
                        startDestination = "SplashScreen"
                    ){
                        composable("RegistrationScreen")
                        {
                            RegistrationScreen(navController, viewModel)
                        }
                        composable("AuthorizationScreen")
                        {
                            AuthorizationScreen(navController, viewModel)
                        }
                    }
                }
            }
        }
    }
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    DevelopmentTheme {
        UserProfileForUnauthorizedUser()
    }
}