1package com.peachpasswords.ui.settings23import androidx.compose.foundation.Canvas4import androidx.compose.foundation.layout.size5import androidx.compose.runtime.Composable6import androidx.compose.runtime.remember7import androidx.compose.ui.Modifier8import androidx.compose.ui.geometry.Offset9import androidx.compose.ui.graphics.Color10import androidx.compose.ui.graphics.StrokeCap11import androidx.compose.ui.graphics.StrokeJoin12import androidx.compose.ui.graphics.drawscope.Stroke13import androidx.compose.ui.graphics.drawscope.scale14import androidx.compose.ui.graphics.vector.PathParser15import androidx.compose.ui.unit.Dp16import androidx.compose.ui.unit.dp17181920212223enum class StackIcon { Spark, Shield, Lock, Sync, Sun, Bubble }2425private val ICON_PATHS: Map<StackIcon, List<String>> = mapOf(26 StackIcon.Shield to listOf(27 "M8 2.2 3.4 4.4v3.2c0 3 2.1 5.1 4.6 6.2 2.5-1.1 4.6-3.2 4.6-6.2V4.4L8 2.2Z",28 "M6.3 8.1 7.4 9.2 9.9 6.6",29 ),30 StackIcon.Lock to listOf(31 "M3 7h10v7H3Z",32 "M5.8 7V5.4a2.2 2.2 0 0 1 4.4 0V7",33 ),34 StackIcon.Sync to listOf(35 "M4 8a4 4 0 0 1 6.8-2.8",36 "M11 3.6v2.2H8.8",37 "M12 8a4 4 0 0 1-6.8 2.8",38 "M5 12.4v-2.2h2.2",39 ),40 StackIcon.Sun to listOf(41 "M8 5.2a2.8 2.8 0 1 0 0 5.6 2.8 2.8 0 0 0 0-5.6Z",42 "M8 1.8v1.3M8 12.9v1.3M1.8 8h1.3M12.9 8h1.3M3.6 3.6l.9.9M11.5 11.5l.9.9M12.4 3.6l-.9.9M4.5 11.5l-.9.9",43 ),44 StackIcon.Spark to listOf(45 "M8 1.8 9.2 6l4.1 1.2-4.1 1.2L8 12.6 6.8 8.4 2.7 7.2 6.8 6 8 1.8Z",46 "m12 11 .5 1.5L14 13l-1.5.5L12 15l-.5-1.5L10 13l1.5-.5L12 11Z",47 ),48 StackIcon.Bubble to listOf(49 "M3 4.2h10a1 1 0 0 1 1 1v5.6a1 1 0 0 1-1 1H6l-3.2 2V5.2a1 1 0 0 1 1-1Z",50 "M5.5 7h5M5.5 9.2h3.2",51 ),52)5354@Composable55fun CardIcon(56 kind: StackIcon,57 color: Color,58 modifier: Modifier = Modifier,59 size: Dp = 16.dp,60) {61 val paths = remember(kind) {62 ICON_PATHS.getValue(kind).map { PathParser().parsePathString(it).toPath() }63 }64 val stroke = remember {65 Stroke(width = 1.25f, cap = StrokeCap.Round, join = StrokeJoin.Round)66 }67 Canvas(modifier = modifier.size(size)) {68 val s = this.size.minDimension / 16f69 scale(scaleX = s, scaleY = s, pivot = Offset.Zero) {70 paths.forEach { drawPath(it, color, style = stroke) }71 }72 }73}