ShellBackground.kt

2.4 KB · raw

1package com.peachpasswords.ui.theme23import androidx.compose.foundation.layout.Box4import androidx.compose.foundation.layout.BoxScope5import androidx.compose.foundation.layout.fillMaxSize6import androidx.compose.runtime.Composable7import androidx.compose.ui.Modifier8import androidx.compose.ui.draw.drawBehind9import androidx.compose.ui.geometry.Offset10import androidx.compose.ui.geometry.Size11import androidx.compose.ui.graphics.Brush12import androidx.compose.ui.graphics.Color1314/**15 * The two-bloom shell background that sits behind every screen.16 *17 * Mirrors the browser shell (popup.css):18 *   radial-gradient(120% 80% at 0% 0%,   accent 8%, transparent 65%)19 *   radial-gradient(85% 100% at 100% 100%, accent 6%, transparent 70%)20 * over a flat --bg fill. Compose radial gradients are circular, so each21 * bloom is sized off the dominant CSS axis to land in the same corner.22 */23@Composable24fun ShellBackground(25    modifier: Modifier = Modifier,26    content: @Composable BoxScope.() -> Unit,27) {28    val accent = LocalPeachAccent.current29    val base = MaterialTheme_background()30    Box(31        modifier = modifier32            .fillMaxSize()33            .drawBehind {34                drawRect(color = base)3536                // Top-left bloom — CSS 120% × 80% at 0% 0%, accent 8% → transparent @65%.37                val topRadius = size.width * 1.2f38                drawRect(39                    brush = Brush.radialGradient(40                        colors = listOf(accent.copy(alpha = 0.08f), Color.Transparent),41                        center = Offset(0f, 0f),42                        radius = topRadius,43                    ),44                    size = Size(size.width, size.height),45                )4647                // Bottom-right bloom — CSS 85% × 100% at 100% 100%, accent 6% → transparent @70%.48                val bottomRadius = size.height * 1.0f49                drawRect(50                    brush = Brush.radialGradient(51                        colors = listOf(accent.copy(alpha = 0.06f), Color.Transparent),52                        center = Offset(size.width, size.height),53                        radius = bottomRadius,54                    ),55                    size = Size(size.width, size.height),56                )57            },58        content = content,59    )60}6162@Composable63private fun MaterialTheme_background(): Color =64    androidx.compose.material3.MaterialTheme.colorScheme.background