package com.laseroptek.raman.ui.screens.splash

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.laseroptek.raman.R
import com.laseroptek.raman.const.preHeatingMillis
import com.laseroptek.raman.navigation.Routes
import com.laseroptek.raman.ui.screens.main.MainViewModel
import com.laseroptek.raman.utils.ext.px


@Composable
fun SplashView(
    mainNavController: NavHostController = rememberNavController(),
    mainViewModel: MainViewModel = hiltViewModel<MainViewModel>(),
) {
    // 바탕 화면
    Box(
        modifier = Modifier
            .fillMaxSize(),
            // .background(color = Color.Black),
        contentAlignment = Alignment.Center
    ) {
        // Full Background Image
        Image(
            painter = painterResource(id = R.drawable.splash_background),
            contentDescription = "Background Image",
            modifier = Modifier.fillMaxSize(),
            contentScale = ContentScale.Crop
        )

        Column(
            modifier = Modifier.size(width = 200.px.dp, height = 97.px.dp).background(Color.Transparent),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.Center
        ) {
            ShimmeringText(text = "LASEROPTEK",)

            Spacer(Modifier.weight(1f))

            AnimatedProgressBar(
                onFinish = {
                    mainNavController.navigate(Routes.Main.route)
                },
                durationMillis = preHeatingMillis.toInt()
            )
        }
    }
}
