package com.example.oscellamobile.screens

import android.graphics.Picture
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.example.oscellamobile.R
import androidx.navigation.NavHostController
import kotlinx.coroutines.delay
import org.intellij.lang.annotations.JdkConstants.HorizontalAlignment

@Composable
fun SplashScreen(navController: NavHostController) {
    val configuration = LocalConfiguration.current

    LaunchedEffect(key1 = true) {
        delay(1500L)
        navController.navigate("Auth") {
            popUpTo("SplashScreen") { inclusive = true }
        }
    }

    Canvas(modifier = androidx.compose.ui.Modifier
        .fillMaxWidth()
        .fillMaxHeight())
    {
        val gradient = Brush.linearGradient(
            colors = listOf(
                Color(0xFF2EC4B6),
                Color(0xFFFF9F1C),
                Color(0xFFE71D36)
            ),
            start = Offset(size.width, 1200f),
            end = Offset(150f, size.height)
        )

        drawRect(brush = gradient)
    }
    Column (
        modifier = Modifier
            .fillMaxWidth()
            .fillMaxHeight(),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Center
    )
    {
       Icon(
          painter = painterResource(id = R.drawable.logo),
           contentDescription = "",
          modifier = Modifier.size(300.dp))
    }
}