PeachMark.kt

4.0 KB · raw

1package com.peachpasswords.ui.components23import androidx.compose.foundation.Canvas4import androidx.compose.foundation.layout.size5import androidx.compose.foundation.layout.padding6import androidx.compose.runtime.Composable7import androidx.compose.runtime.remember8import androidx.compose.ui.Modifier9import androidx.compose.ui.geometry.Offset10import androidx.compose.ui.geometry.Size11import androidx.compose.ui.graphics.Color12import androidx.compose.ui.graphics.drawscope.Stroke13import androidx.compose.ui.graphics.drawscope.rotate14import androidx.compose.ui.graphics.drawscope.scale15import androidx.compose.ui.graphics.vector.PathParser16import androidx.compose.ui.unit.Dp17import androidx.compose.ui.unit.dp18import androidx.compose.ui.unit.sp1920/**21 * The Peach brand mark — a peach fruit with a single leaf. Exact port of the22 * browser PeachMark.tsx SVG (viewBox 240×240). The leaf is ALWAYS sage green23 * (#92AC65 fill, #5E7A42 vein) and the body is fixed peach tones — none of it24 * is accent-driven. [alpha] dims the whole mark for the faint lock-screen art.25 */26@Composable27fun PeachMark(28    modifier: Modifier = Modifier,29    size: Dp = 14.dp,30    alpha: Float = 1f,31) {32    val leaf = remember {  PathParser().parsePathString("M 124 64 C 134 32 168 16 200 22 C 198 56 168 72 130 66 Z").toPath() }33    val vein = remember {  PathParser().parsePathString("M 130 64 C 152 46 178 30 196 24").toPath() }34    val bodyLight = remember {  PathParser().parsePathString("M 120 60 C 75 45 28 75 22 130 C 18 185 65 222 125 222 C 185 222 222 185 220 130 C 218 78 170 45 120 60 Z").toPath() }35    val bodyShadow = remember {  PathParser().parsePathString("M 120 60 C 75 45 28 75 22 130 C 18 185 65 222 125 222 C 105 195 75 150 100 90 C 105 75 112 65 120 60 Z").toPath() }3637    Canvas(modifier = modifier.size(size)) {38        val s = this.size.minDimension / 240f39        scale(scaleX = s, scaleY = s, pivot = Offset.Zero) {40            drawPath(bodyLight, Color(0xFFFFB082), alpha = alpha)41            drawPath(bodyShadow, Color(0xFFE5805C), alpha = alpha)42            // Highlight ellipse: cx178 cy108 rx20 ry11, rotate(-26°).43            rotate(degrees = -26f, pivot = Offset(178f, 108f)) {44                drawOval(45                    color = Color(0xFFFFD0A8),46                    topLeft = Offset(178f - 20f, 108f - 11f),47                    size = Size(40f, 22f),48                    alpha = alpha * 0.7f,49                )50            }51            drawPath(leaf, Color(0xFF92AC65), alpha = alpha)52            drawPath(vein, Color(0xFF5E7A42), alpha = alpha, style = Stroke(width = 2.6f))53        }54    }55}5657/**58 * Mark + "peach" lockup, top-left on the pre-vault screens. Extracted because59 * Lock and Onboarding each hand-rolled it and drifted apart — onboarding lost60 * the mark entirely.61 */62@Composable63fun PeachWordmark(modifier: Modifier = Modifier, isPro: Boolean = false) {64    androidx.compose.foundation.layout.Row(65        modifier = modifier,66        verticalAlignment = androidx.compose.ui.Alignment.CenterVertically,67    ) {68        PeachMark(modifier = Modifier.padding(end = com.peachpasswords.ui.theme.PeachSpacing.xs))69        if (isPro) {70            androidx.compose.foundation.layout.Column {71                androidx.compose.material3.Text(72                    text = "peach",73                    color = com.peachpasswords.ui.theme.peachColors.T0,74                    style = com.peachpasswords.ui.theme.PeachType.wordmark.copy(lineHeight = 13.sp),75                )76                androidx.compose.material3.Text(77                    text = "pro",78                    color = com.peachpasswords.ui.theme.LocalPeachAccent.current,79                    style = com.peachpasswords.ui.theme.PeachType.wordmark.copy(fontSize = 10.sp, lineHeight = 9.sp),80                )81            }82        } else {83            androidx.compose.material3.Text(84                text = "peach",85                color = com.peachpasswords.ui.theme.LocalPeachAccent.current,86                style = com.peachpasswords.ui.theme.PeachType.wordmark,87            )88        }89    }90}