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, Keys, 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.Keys to listOf(45 "M3 5h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Z",46 "M10 7h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1Z",47 "M7 7h2M7 9h2",48 ),49 StackIcon.Spark to listOf(50 "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",51 "m12 11 .5 1.5L14 13l-1.5.5L12 15l-.5-1.5L10 13l1.5-.5L12 11Z",52 ),53 StackIcon.Bubble to listOf(54 "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",55 "M5.5 7h5M5.5 9.2h3.2",56 ),57)5859@Composable60fun CardIcon(61 kind: StackIcon,62 color: Color,63 modifier: Modifier = Modifier,64 size: Dp = 16.dp,65) {66 val paths = remember(kind) {67 ICON_PATHS.getValue(kind).map { PathParser().parsePathString(it).toPath() }68 }69 val stroke = remember {70 Stroke(width = 1.25f, cap = StrokeCap.Round, join = StrokeJoin.Round)71 }72 Canvas(modifier = modifier.size(size)) {73 val s = this.size.minDimension / 16f74 scale(scaleX = s, scaleY = s, pivot = Offset.Zero) {75 paths.forEach { drawPath(it, color, style = stroke) }76 }77 }78}