package dev.ulfrx.recipe.ui.screens.auth

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.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import dev.ulfrx.recipe.ui.components.controls.RecipeLoadingIndicator
import dev.ulfrx.recipe.ui.theme.RecipeTheme
import org.jetbrains.compose.resources.stringResource
import recipe.composeapp.generated.resources.Res
import recipe.composeapp.generated.resources.auth_app_name

/**
 * Visible during [dev.ulfrx.recipe.auth.AuthState.Loading]. Wordmark + circular progress.
 * No marketing copy, no tagline. Background is `surface` so the Login transition has no
 * color flash.
 */
@Composable
@Preview
fun SplashScreen() {
    Box(
        modifier =
            Modifier
                .fillMaxSize()
                .background(RecipeTheme.colors.surface),
    ) {
        Column(
            modifier =
                Modifier
                    .fillMaxSize()
                    .safeContentPadding()
                    .padding(horizontal = 16.dp),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.Center,
        ) {
            BasicText(
                text = stringResource(Res.string.auth_app_name),
                style = RecipeTheme.typography.display.copy(color = RecipeTheme.colors.content),
            )
            Spacer(Modifier.height(8.dp))
            RecipeLoadingIndicator()
        }
    }
}
