60022bcd8419

feat: D3 tags UI — chip editor in EntryEdit, filter strip + row chips in VaultList (live combine), read-only tag row in EntryDetail (v2.1.32)

time
2026-06-09 04:23 UTC · 5 months ago
machine
koh2
agent
claude-opus-4-8
session
peach remaining gaps
parent
734a5ce9e86d
11 files app/drafts/D3/DetailTagRow.kt+0 −70app/drafts/D3/TagChipEditor.kt+0 −176app/drafts/D3/TagListWidgets.kt+0 −95app/src/main/java/com/peachpasswords/ui/vault/DetailTagRow.kt+71 −0app/src/main/java/com/peachpasswords/ui/vault/EntryDetailScreen.kt+6 −0app/src/main/java/com/peachpasswords/ui/vault/EntryEditScreen.kt+6 −0app/src/main/java/com/peachpasswords/ui/vault/EntryEditViewModel.kt+13 −0app/src/main/java/com/peachpasswords/ui/vault/TagChipEditor.kt+177 −0app/src/main/java/com/peachpasswords/ui/vault/TagListWidgets.kt+96 −0app/src/main/java/com/peachpasswords/ui/vault/VaultListScreen.kt+13 −0app/src/main/java/com/peachpasswords/ui/vault/VaultListViewModel.kt+12 −2
app/drafts/D3/DetailTagRow.kt+0 −70
@@ -1,70 +0,0 @@1-package com.peachpasswords.ui.vault2-3-import androidx.compose.foundation.background4-import androidx.compose.foundation.border5-import androidx.compose.foundation.clickable6-import androidx.compose.foundation.layout.Arrangement7-import androidx.compose.foundation.layout.Column8-import androidx.compose.foundation.layout.ExperimentalLayoutApi9-import androidx.compose.foundation.layout.FlowRow10-import androidx.compose.foundation.layout.Spacer11-import androidx.compose.foundation.layout.fillMaxWidth12-import androidx.compose.foundation.layout.height13-import androidx.compose.foundation.layout.padding14-import androidx.compose.foundation.shape.RoundedCornerShape15-import androidx.compose.runtime.Composable16-import androidx.compose.ui.Modifier17-import androidx.compose.ui.draw.clip18-import androidx.compose.ui.unit.dp19-import androidx.compose.ui.unit.em20-import com.peachpasswords.ui.theme.LocalPeachAccent21-import com.peachpasswords.ui.theme.PeachColors22-import com.peachpasswords.ui.theme.PeachType23-24-/**25- * Read-only tag row for EntryDetailScreen, mirroring the FieldShell label/hairline26- * style. A trailing "+" chip routes to the editor so the user can change tags.27- */28-@OptIn(ExperimentalLayoutApi::class)29-@Composable30-internal fun DetailTagRow(tags: List<String>, onEditTags: () -> Unit) {31-    val accent = LocalPeachAccent.current32-    Column(33-        Modifier.fillMaxWidth().padding(vertical = 10.dp),34-    ) {35-        Text(36-            "TAGS",37-            color = PeachColors.T2,38-            style = PeachType.labelMono.copy(letterSpacing = 0.08.em),39-        )40-        Spacer(Modifier.height(8.dp))41-        FlowRow(42-            modifier = Modifier.fillMaxWidth(),43-            horizontalArrangement = Arrangement.spacedBy(6.dp),44-            verticalArrangement = Arrangement.spacedBy(6.dp),45-        ) {46-            tags.forEach { tag ->47-                Text(48-                    text = tag,49-                    color = accent,50-                    style = PeachType.labelMono,51-                    modifier = Modifier52-                        .clip(RoundedCornerShape(6.dp))53-                        .background(accent.copy(alpha = 0.12f))54-                        .border(1.dp, accent.copy(alpha = 0.28f), RoundedCornerShape(6.dp))55-                        .padding(horizontal = 8.dp, vertical = 4.dp),56-                )57-            }58-            Text(59-                text = "+",60-                color = accent,61-                style = PeachType.labelMono,62-                modifier = Modifier63-                    .clip(RoundedCornerShape(6.dp))64-                    .border(1.dp, accent.copy(alpha = 0.28f), RoundedCornerShape(6.dp))65-                    .clickable(onClick = onEditTags)66-                    .padding(horizontal = 10.dp, vertical = 4.dp),67-            )68-        }69-    }70-}

view file at the parent

app/drafts/D3/TagChipEditor.kt+0 −176
@@ -1,176 +0,0 @@1-package com.peachpasswords.ui.vault2-3-import androidx.compose.foundation.background4-import androidx.compose.foundation.border5-import androidx.compose.foundation.clickable6-import androidx.compose.foundation.layout.Arrangement7-import androidx.compose.foundation.layout.Box8-import androidx.compose.foundation.layout.Column9-import androidx.compose.foundation.layout.ExperimentalLayoutApi10-import androidx.compose.foundation.layout.FlowRow11-import androidx.compose.foundation.layout.Row12-import androidx.compose.foundation.layout.Spacer13-import androidx.compose.foundation.layout.fillMaxWidth14-import androidx.compose.foundation.layout.height15-import androidx.compose.foundation.layout.padding16-import androidx.compose.foundation.layout.width17-import androidx.compose.foundation.layout.widthIn18-import androidx.compose.foundation.shape.RoundedCornerShape19-import androidx.compose.foundation.text.BasicTextField20-import androidx.compose.foundation.text.KeyboardActions21-import androidx.compose.foundation.text.KeyboardOptions22-import androidx.compose.runtime.Composable23-import androidx.compose.runtime.getValue24-import androidx.compose.runtime.mutableStateOf25-import androidx.compose.runtime.remember26-import androidx.compose.runtime.setValue27-import androidx.compose.ui.Alignment28-import androidx.compose.ui.Modifier29-import androidx.compose.ui.draw.clip30-import androidx.compose.ui.graphics.SolidColor31-import androidx.compose.ui.text.TextStyle32-import androidx.compose.ui.text.input.ImeAction33-import androidx.compose.ui.unit.dp34-import androidx.compose.ui.unit.sp35-import com.peachpasswords.ui.theme.LocalPeachAccent36-import com.peachpasswords.ui.theme.PeachColors37-import com.peachpasswords.ui.theme.PeachType38-39-/** Max tags per entry. */40-private const val MAX_TAGS = 1041-42-/** Max characters per tag. */43-private const val MAX_TAG_LEN = 3244-45-/** Normalise raw tag input to the canonical form (trimmed, lowercase, length-capped). */46-internal fun normalizeTag(raw: String): String =47-    raw.trim().lowercase().take(MAX_TAG_LEN)48-49-/**50- * Tag chip editor for EntryEditScreen. Self-contained: owns its own draft-input51- * state; the committed tag list and suggestion source come from the caller.52- *53- * - Commits on space or enter (also strips spaces typed mid-word into commits).54- * - Enforces max 10 tags, 32 chars, lowercase, trimmed, de-duplicated.55- * - Shows up to 4 autocomplete suggestions drawn from [allTags] minus current tags.56- */57-@OptIn(ExperimentalLayoutApi::class)58-@Composable59-internal fun TagChipEditor(60-    tags: List<String>,61-    allTags: List<String>,62-    onAdd: (String) -> Unit,63-    onRemove: (String) -> Unit,64-) {65-    val accent = LocalPeachAccent.current66-    var draft by remember { mutableStateOf("") }67-    val atLimit = tags.size >= MAX_TAGS68-69-    fun commit(value: String) {70-        val tag = normalizeTag(value)71-        if (tag.isNotEmpty() && tags.size < MAX_TAGS && tags.none { it == tag }) onAdd(tag)72-        draft = ""73-    }74-75-    val suggestions = remember(draft, allTags, tags) {76-        val needle = draft.trim().lowercase()77-        allTags.asSequence()78-            .filter { it !in tags }79-            .filter { needle.isEmpty() || (it.contains(needle) && it != needle) }80-            .take(4)81-            .toList()82-    }83-84-    Column(Modifier.fillMaxWidth().padding(bottom = 14.dp)) {85-        Text("TAGS", color = PeachColors.T1, fontFamily = PeachType.Mono, fontSize = 8.sp)86-        Spacer(Modifier.height(6.dp))87-88-        FlowRow(89-            modifier = Modifier.fillMaxWidth(),90-            horizontalArrangement = Arrangement.spacedBy(6.dp),91-            verticalArrangement = Arrangement.spacedBy(6.dp),92-        ) {93-            tags.forEach { tag ->94-                TagChip(label = tag, onRemove = { onRemove(tag) })95-            }96-            if (!atLimit) {97-                Box(98-                    Modifier99-                        .widthIn(min = 90.dp)100-                        .border(1.dp, PeachColors.T3, RoundedCornerShape(6.dp))101-                        .padding(horizontal = 10.dp, vertical = 6.dp),102-                    contentAlignment = Alignment.CenterStart,103-                ) {104-                    if (draft.isEmpty()) {105-                        Text("add a tag…", color = PeachColors.T2, style = PeachType.bodyMono)106-                    }107-                    BasicTextField(108-                        value = draft,109-                        onValueChange = { input ->110-                            // Space acts as a delimiter: commit the segment before it.111-                            if (input.endsWith(" ") || input.contains(' ')) {112-                                val parts = input.split(' ')113-                                parts.dropLast(1).forEach { commit(it) }114-                                draft = normalizeTag(parts.last())115-                            } else {116-                                draft = input.lowercase().take(MAX_TAG_LEN)117-                            }118-                        },119-                        singleLine = true,120-                        textStyle = PeachType.bodyMono.copy(color = PeachColors.T0),121-                        cursorBrush = SolidColor(accent),122-                        keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),123-                        keyboardActions = KeyboardActions(onDone = { commit(draft) }),124-                    )125-                }126-            }127-        }128-129-        if (atLimit) {130-            Spacer(Modifier.height(6.dp))131-            Text("Max $MAX_TAGS tags", color = PeachColors.T2, fontFamily = PeachType.Mono, fontSize = 9.sp)132-        } else if (suggestions.isNotEmpty()) {133-            Spacer(Modifier.height(8.dp))134-            Column(Modifier.fillMaxWidth()) {135-                suggestions.forEach { s ->136-                    Text(137-                        s,138-                        color = PeachColors.T1,139-                        style = TextStyle(fontFamily = PeachType.Mono, fontSize = 11.sp),140-                        modifier = Modifier141-                            .fillMaxWidth()142-                            .clip(RoundedCornerShape(6.dp))143-                            .clickable { commit(s) }144-                            .padding(horizontal = 8.dp, vertical = 6.dp),145-                    )146-                }147-            }148-        }149-    }150-}151-152-/** Accent-tinted removable tag pill used by the editor. */153-@Composable154-private fun TagChip(label: String, onRemove: () -> Unit) {155-    val accent = LocalPeachAccent.current156-    Row(157-        modifier = Modifier158-            .clip(RoundedCornerShape(6.dp))159-            .background(accent.copy(alpha = 0.12f))160-            .border(1.dp, accent.copy(alpha = 0.28f), RoundedCornerShape(6.dp))161-            .padding(start = 8.dp, end = 4.dp, top = 4.dp, bottom = 4.dp),162-        verticalAlignment = Alignment.CenterVertically,163-    ) {164-        Text(label, color = accent, style = PeachType.labelMono)165-        Spacer(Modifier.width(4.dp))166-        Text(167-            "×",168-            color = accent,169-            style = PeachType.labelMono,170-            modifier = Modifier171-                .clip(RoundedCornerShape(4.dp))172-                .clickable(onClick = onRemove)173-                .padding(horizontal = 4.dp, vertical = 1.dp),174-        )175-    }176-}

view file at the parent

app/drafts/D3/TagListWidgets.kt+0 −95
@@ -1,95 +0,0 @@1-package com.peachpasswords.ui.vault2-3-import androidx.compose.foundation.background4-import androidx.compose.foundation.border5-import androidx.compose.foundation.clickable6-import androidx.compose.foundation.layout.Arrangement7-import androidx.compose.foundation.layout.Row8-import androidx.compose.foundation.layout.fillMaxWidth9-import androidx.compose.foundation.layout.padding10-import androidx.compose.foundation.lazy.LazyRow11-import androidx.compose.foundation.lazy.items12-import androidx.compose.foundation.shape.RoundedCornerShape13-import androidx.compose.runtime.Composable14-import androidx.compose.ui.Modifier15-import androidx.compose.ui.draw.clip16-import androidx.compose.ui.graphics.Color17-import androidx.compose.ui.unit.dp18-import com.peachpasswords.ui.theme.LocalPeachAccent19-import com.peachpasswords.ui.theme.PeachColors20-import com.peachpasswords.ui.theme.PeachType21-22-/**23- * Horizontally scrollable tag filter strip for VaultListScreen, placed between the24- * search bar and the sort bar. The caller is responsible for hiding it when25- * [allTags] is empty.26- */27-@Composable28-internal fun TagFilterStrip(29-    allTags: List<String>,30-    activeTagFilter: String?,31-    onSelect: (String?) -> Unit,32-) {33-    val accent = LocalPeachAccent.current34-    LazyRow(35-        modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp),36-        horizontalArrangement = Arrangement.spacedBy(6.dp),37-    ) {38-        items(allTags, key = { it }) { tag ->39-            val selected = activeTagFilter == tag40-            Text(41-                text = tag.uppercase(),42-                color = if (selected) accent else PeachColors.T2,43-                style = PeachType.sortPill,44-                modifier = Modifier45-                    .clip(RoundedCornerShape(4.dp))46-                    .background(if (selected) accent.copy(alpha = 0.18f) else Color.Transparent)47-                    .border(48-                        1.dp,49-                        if (selected) accent else PeachColors.T3,50-                        RoundedCornerShape(4.dp),51-                    )52-                    // Toggle off when re-tapping the active tag.53-                    .clickable { onSelect(if (selected) null else tag) }54-                    .padding(horizontal = 8.dp, vertical = 3.dp),55-            )56-        }57-    }58-}59-60-/**61- * Up-to-2 tag chips for an entry row, with a "+N more" ghost chip when the entry62- * carries more than two tags. Smaller, non-interactive variant of the editor chip.63- */64-@Composable65-internal fun EntryRowTags(tags: List<String>) {66-    if (tags.isEmpty()) return67-    val accent = LocalPeachAccent.current68-    val shown = tags.take(2)69-    val extra = tags.size - shown.size70-    Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {71-        shown.forEach { tag ->72-            Text(73-                text = tag,74-                color = accent,75-                style = PeachType.tinyMono,76-                modifier = Modifier77-                    .clip(RoundedCornerShape(4.dp))78-                    .background(accent.copy(alpha = 0.12f))79-                    .border(0.5.dp, accent.copy(alpha = 0.28f), RoundedCornerShape(4.dp))80-                    .padding(horizontal = 5.dp, vertical = 1.dp),81-            )82-        }83-        if (extra > 0) {84-            Text(85-                text = "+$extra more",86-                color = PeachColors.T2,87-                style = PeachType.tinyMono,88-                modifier = Modifier89-                    .clip(RoundedCornerShape(4.dp))90-                    .border(0.5.dp, PeachColors.T3, RoundedCornerShape(4.dp))91-                    .padding(horizontal = 5.dp, vertical = 1.dp),92-            )93-        }94-    }95-}

view file at the parent

app/src/main/java/com/peachpasswords/ui/vault/DetailTagRow.kt+71 −0
@@ -0,0 +1,71 @@1+package com.peachpasswords.ui.vault2+3+import androidx.compose.foundation.background4+import androidx.compose.foundation.border5+import androidx.compose.foundation.clickable6+import androidx.compose.foundation.layout.Arrangement7+import androidx.compose.foundation.layout.Column8+import androidx.compose.foundation.layout.ExperimentalLayoutApi9+import androidx.compose.foundation.layout.FlowRow10+import androidx.compose.foundation.layout.Spacer11+import androidx.compose.foundation.layout.fillMaxWidth12+import androidx.compose.foundation.layout.height13+import androidx.compose.foundation.layout.padding14+import androidx.compose.foundation.shape.RoundedCornerShape15+import androidx.compose.material3.Text16+import androidx.compose.runtime.Composable17+import androidx.compose.ui.Modifier18+import androidx.compose.ui.draw.clip19+import androidx.compose.ui.unit.dp20+import androidx.compose.ui.unit.em21+import com.peachpasswords.ui.theme.LocalPeachAccent22+import com.peachpasswords.ui.theme.PeachColors23+import com.peachpasswords.ui.theme.PeachType24+25+/**26+ * Read-only tag row for EntryDetailScreen, mirroring the FieldShell label/hairline27+ * style. A trailing "+" chip routes to the editor so the user can change tags.28+ */29+@OptIn(ExperimentalLayoutApi::class)30+@Composable31+internal fun DetailTagRow(tags: List<String>, onEditTags: () -> Unit) {32+    val accent = LocalPeachAccent.current33+    Column(34+        Modifier.fillMaxWidth().padding(vertical = 10.dp),35+    ) {36+        Text(37+            "TAGS",38+            color = PeachColors.T2,39+            style = PeachType.labelMono.copy(letterSpacing = 0.08.em),40+        )41+        Spacer(Modifier.height(8.dp))42+        FlowRow(43+            modifier = Modifier.fillMaxWidth(),44+            horizontalArrangement = Arrangement.spacedBy(6.dp),45+            verticalArrangement = Arrangement.spacedBy(6.dp),46+        ) {47+            tags.forEach { tag ->48+                Text(49+                    text = tag,50+                    color = accent,51+                    style = PeachType.labelMono,52+                    modifier = Modifier53+                        .clip(RoundedCornerShape(6.dp))54+                        .background(accent.copy(alpha = 0.12f))55+                        .border(1.dp, accent.copy(alpha = 0.28f), RoundedCornerShape(6.dp))56+                        .padding(horizontal = 8.dp, vertical = 4.dp),57+                )58+            }59+            Text(60+                text = "+",61+                color = accent,62+                style = PeachType.labelMono,63+                modifier = Modifier64+                    .clip(RoundedCornerShape(6.dp))65+                    .border(1.dp, accent.copy(alpha = 0.28f), RoundedCornerShape(6.dp))66+                    .clickable(onClick = onEditTags)67+                    .padding(horizontal = 10.dp, vertical = 4.dp),68+            )69+        }70+    }71+}

view file

app/src/main/java/com/peachpasswords/ui/vault/EntryDetailScreen.kt+6 −0
@@ -251,6 +251,12 @@251251                 e.notes?.takeIf { it.isNotBlank() }?.let {252252                     FieldRow("notes", it, copiedField == "notes", mono = false) { vm.copy("notes", it) }253253                 }254+                e.tags?.takeIf { it.isNotEmpty() }?.let { tags ->255+                    DetailTagRow(256+                        tags = tags,257+                        onEditTags = { onNavigate(PeachNav.EntryEdit(e.id)) },258+                    )259+                }254260 255261                 Spacer(Modifier.height(48.dp))256262             }

view file

app/src/main/java/com/peachpasswords/ui/vault/EntryEditScreen.kt+6 −0
@@ -143,6 +143,12 @@143143                     )144144                 }145145                 Field("notes", f.notes, vm::setNotes, singleLine = false)146+                TagChipEditor(147+                    tags = f.tags,148+                    allTags = vm.allTags,149+                    onAdd = vm::addTag,150+                    onRemove = vm::removeTag,151+                )146152 147153                 f.error?.let {148154                     Spacer(Modifier.height(8.dp))

view file

app/src/main/java/com/peachpasswords/ui/vault/EntryEditViewModel.kt+13 −0
@@ -34,6 +34,7 @@3434     val cvc: String = "",3535     val showCvc: Boolean = false,3636     val cardNetwork: String = "unknown",37+    val tags: List<String> = emptyList(),3738     val showPassword: Boolean = false,3839     val generatorOpen: Boolean = false,3940     val history: List<PasswordHistoryItem> = emptyList(),@@ -73,6 +74,7 @@7374                 expiry = CardFieldUtils.displayExpiry(it.expMonth, it.expYear),7475                 cvc = it.cvc.orEmpty(),7576                 cardNetwork = it.cardNetwork ?: CardFieldUtils.detectNetwork(it.cardNumber.orEmpty()),77+                tags = it.tags.orEmpty(),7678                 history = it.passwordHistory.orEmpty(),7779             )7880         } ?: EditForm(),@@ -97,6 +99,15 @@9799         it.copy(cvc = v.filter { c -> c.isDigit() }.take(CardFieldUtils.cvcMaxDigits(it.cardNetwork)))98100     }99101     fun toggleShowCvc() = _form.update { it.copy(showCvc = !it.showCvc) }102+103+    val allTags: List<String> = vault.getDistinctTags()104+    fun addTag(raw: String) = _form.update { f ->105+        val tag = raw.trim().lowercase().take(32)106+        if (tag.isEmpty() || f.tags.size >= 10 || f.tags.any { it == tag }) f107+        else f.copy(tags = f.tags + tag)108+    }109+    fun removeTag(tag: String) = _form.update { it.copy(tags = it.tags - tag) }110+100111     fun toggleShowPassword() = _form.update { it.copy(showPassword = !it.showPassword) }101112     fun toggleGenerator() = _form.update { it.copy(generatorOpen = !it.generatorOpen, showHistory = false) }102113     fun toggleHistory() = _form.update { it.copy(showHistory = !it.showHistory, generatorOpen = false) }@@ -158,6 +169,7 @@158169                             expYear = f.expiry.filter { it.isDigit() }.drop(2).take(2).ifBlank { null },159170                             cvc = f.cvc.ifBlank { null },160171                             cardNetwork = f.cardNetwork.takeIf { it != "unknown" },172+                            tags = f.tags.ifEmpty { null },161173                             createdAt = 0, modifiedAt = 0,162174                         ),163175                     )@@ -177,6 +189,7 @@177189                             expYear = f.expiry.filter { it.isDigit() }.drop(2).take(2).ifBlank { null },178190                             cvc = f.cvc.ifBlank { null },179191                             cardNetwork = f.cardNetwork.takeIf { it != "unknown" },192+                            tags = f.tags.ifEmpty { null },180193                         ),181194                     )182195                 }

view file

app/src/main/java/com/peachpasswords/ui/vault/TagChipEditor.kt+177 −0
@@ -0,0 +1,177 @@1+package com.peachpasswords.ui.vault2+3+import androidx.compose.foundation.background4+import androidx.compose.foundation.border5+import androidx.compose.foundation.clickable6+import androidx.compose.foundation.layout.Arrangement7+import androidx.compose.foundation.layout.Box8+import androidx.compose.foundation.layout.Column9+import androidx.compose.foundation.layout.ExperimentalLayoutApi10+import androidx.compose.foundation.layout.FlowRow11+import androidx.compose.foundation.layout.Row12+import androidx.compose.foundation.layout.Spacer13+import androidx.compose.foundation.layout.fillMaxWidth14+import androidx.compose.foundation.layout.height15+import androidx.compose.foundation.layout.padding16+import androidx.compose.foundation.layout.width17+import androidx.compose.foundation.layout.widthIn18+import androidx.compose.foundation.shape.RoundedCornerShape19+import androidx.compose.foundation.text.BasicTextField20+import androidx.compose.foundation.text.KeyboardActions21+import androidx.compose.foundation.text.KeyboardOptions22+import androidx.compose.material3.Text23+import androidx.compose.runtime.Composable24+import androidx.compose.runtime.getValue25+import androidx.compose.runtime.mutableStateOf26+import androidx.compose.runtime.remember27+import androidx.compose.runtime.setValue28+import androidx.compose.ui.Alignment29+import androidx.compose.ui.Modifier30+import androidx.compose.ui.draw.clip31+import androidx.compose.ui.graphics.SolidColor32+import androidx.compose.ui.text.TextStyle33+import androidx.compose.ui.text.input.ImeAction34+import androidx.compose.ui.unit.dp35+import androidx.compose.ui.unit.sp36+import com.peachpasswords.ui.theme.LocalPeachAccent37+import com.peachpasswords.ui.theme.PeachColors38+import com.peachpasswords.ui.theme.PeachType39+40+/** Max tags per entry. */41+private const val MAX_TAGS = 1042+43+/** Max characters per tag. */44+private const val MAX_TAG_LEN = 3245+46+/** Normalise raw tag input to the canonical form (trimmed, lowercase, length-capped). */47+internal fun normalizeTag(raw: String): String =48+    raw.trim().lowercase().take(MAX_TAG_LEN)49+50+/**51+ * Tag chip editor for EntryEditScreen. Self-contained: owns its own draft-input52+ * state; the committed tag list and suggestion source come from the caller.53+ *54+ * - Commits on space or enter (also strips spaces typed mid-word into commits).55+ * - Enforces max 10 tags, 32 chars, lowercase, trimmed, de-duplicated.56+ * - Shows up to 4 autocomplete suggestions drawn from [allTags] minus current tags.57+ */58+@OptIn(ExperimentalLayoutApi::class)59+@Composable60+internal fun TagChipEditor(61+    tags: List<String>,62+    allTags: List<String>,63+    onAdd: (String) -> Unit,64+    onRemove: (String) -> Unit,65+) {66+    val accent = LocalPeachAccent.current67+    var draft by remember { mutableStateOf("") }68+    val atLimit = tags.size >= MAX_TAGS69+70+    fun commit(value: String) {71+        val tag = normalizeTag(value)72+        if (tag.isNotEmpty() && tags.size < MAX_TAGS && tags.none { it == tag }) onAdd(tag)73+        draft = ""74+    }75+76+    val suggestions = remember(draft, allTags, tags) {77+        val needle = draft.trim().lowercase()78+        allTags.asSequence()79+            .filter { it !in tags }80+            .filter { needle.isEmpty() || (it.contains(needle) && it != needle) }81+            .take(4)82+            .toList()83+    }84+85+    Column(Modifier.fillMaxWidth().padding(bottom = 14.dp)) {86+        Text("TAGS", color = PeachColors.T1, fontFamily = PeachType.Mono, fontSize = 8.sp)87+        Spacer(Modifier.height(6.dp))88+89+        FlowRow(90+            modifier = Modifier.fillMaxWidth(),91+            horizontalArrangement = Arrangement.spacedBy(6.dp),92+            verticalArrangement = Arrangement.spacedBy(6.dp),93+        ) {94+            tags.forEach { tag ->95+                TagChip(label = tag, onRemove = { onRemove(tag) })96+            }97+            if (!atLimit) {98+                Box(99+                    Modifier100+                        .widthIn(min = 90.dp)101+                        .border(1.dp, PeachColors.T3, RoundedCornerShape(6.dp))102+                        .padding(horizontal = 10.dp, vertical = 6.dp),103+                    contentAlignment = Alignment.CenterStart,104+                ) {105+                    if (draft.isEmpty()) {106+                        Text("add a tag…", color = PeachColors.T2, style = PeachType.bodyMono)107+                    }108+                    BasicTextField(109+                        value = draft,110+                        onValueChange = { input ->111+                            // Space acts as a delimiter: commit the segment before it.112+                            if (input.endsWith(" ") || input.contains(' ')) {113+                                val parts = input.split(' ')114+                                parts.dropLast(1).forEach { commit(it) }115+                                draft = normalizeTag(parts.last())116+                            } else {117+                                draft = input.lowercase().take(MAX_TAG_LEN)118+                            }119+                        },120+                        singleLine = true,121+                        textStyle = PeachType.bodyMono.copy(color = PeachColors.T0),122+                        cursorBrush = SolidColor(accent),123+                        keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),124+                        keyboardActions = KeyboardActions(onDone = { commit(draft) }),125+                    )126+                }127+            }128+        }129+130+        if (atLimit) {131+            Spacer(Modifier.height(6.dp))132+            Text("Max $MAX_TAGS tags", color = PeachColors.T2, fontFamily = PeachType.Mono, fontSize = 9.sp)133+        } else if (suggestions.isNotEmpty()) {134+            Spacer(Modifier.height(8.dp))135+            Column(Modifier.fillMaxWidth()) {136+                suggestions.forEach { s ->137+                    Text(138+                        s,139+                        color = PeachColors.T1,140+                        style = TextStyle(fontFamily = PeachType.Mono, fontSize = 11.sp),141+                        modifier = Modifier142+                            .fillMaxWidth()143+                            .clip(RoundedCornerShape(6.dp))144+                            .clickable { commit(s) }145+                            .padding(horizontal = 8.dp, vertical = 6.dp),146+                    )147+                }148+            }149+        }150+    }151+}152+153+/** Accent-tinted removable tag pill used by the editor. */154+@Composable155+private fun TagChip(label: String, onRemove: () -> Unit) {156+    val accent = LocalPeachAccent.current157+    Row(158+        modifier = Modifier159+            .clip(RoundedCornerShape(6.dp))160+            .background(accent.copy(alpha = 0.12f))161+            .border(1.dp, accent.copy(alpha = 0.28f), RoundedCornerShape(6.dp))162+            .padding(start = 8.dp, end = 4.dp, top = 4.dp, bottom = 4.dp),163+        verticalAlignment = Alignment.CenterVertically,164+    ) {165+        Text(label, color = accent, style = PeachType.labelMono)166+        Spacer(Modifier.width(4.dp))167+        Text(168+            "×",169+            color = accent,170+            style = PeachType.labelMono,171+            modifier = Modifier172+                .clip(RoundedCornerShape(4.dp))173+                .clickable(onClick = onRemove)174+                .padding(horizontal = 4.dp, vertical = 1.dp),175+        )176+    }177+}

view file

app/src/main/java/com/peachpasswords/ui/vault/TagListWidgets.kt+96 −0
@@ -0,0 +1,96 @@1+package com.peachpasswords.ui.vault2+3+import androidx.compose.foundation.background4+import androidx.compose.foundation.border5+import androidx.compose.foundation.clickable6+import androidx.compose.foundation.layout.Arrangement7+import androidx.compose.foundation.layout.Row8+import androidx.compose.foundation.layout.fillMaxWidth9+import androidx.compose.foundation.layout.padding10+import androidx.compose.foundation.lazy.LazyRow11+import androidx.compose.foundation.lazy.items12+import androidx.compose.foundation.shape.RoundedCornerShape13+import androidx.compose.material3.Text14+import androidx.compose.runtime.Composable15+import androidx.compose.ui.Modifier16+import androidx.compose.ui.draw.clip17+import androidx.compose.ui.graphics.Color18+import androidx.compose.ui.unit.dp19+import com.peachpasswords.ui.theme.LocalPeachAccent20+import com.peachpasswords.ui.theme.PeachColors21+import com.peachpasswords.ui.theme.PeachType22+23+/**24+ * Horizontally scrollable tag filter strip for VaultListScreen, placed between the25+ * search bar and the sort bar. The caller is responsible for hiding it when26+ * [allTags] is empty.27+ */28+@Composable29+internal fun TagFilterStrip(30+    allTags: List<String>,31+    activeTagFilter: String?,32+    onSelect: (String?) -> Unit,33+) {34+    val accent = LocalPeachAccent.current35+    LazyRow(36+        modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp),37+        horizontalArrangement = Arrangement.spacedBy(6.dp),38+    ) {39+        items(allTags, key = { it }) { tag ->40+            val selected = activeTagFilter == tag41+            Text(42+                text = tag.uppercase(),43+                color = if (selected) accent else PeachColors.T2,44+                style = PeachType.sortPill,45+                modifier = Modifier46+                    .clip(RoundedCornerShape(4.dp))47+                    .background(if (selected) accent.copy(alpha = 0.18f) else Color.Transparent)48+                    .border(49+                        1.dp,50+                        if (selected) accent else PeachColors.T3,51+                        RoundedCornerShape(4.dp),52+                    )53+                    // Toggle off when re-tapping the active tag.54+                    .clickable { onSelect(if (selected) null else tag) }55+                    .padding(horizontal = 8.dp, vertical = 3.dp),56+            )57+        }58+    }59+}60+61+/**62+ * Up-to-2 tag chips for an entry row, with a "+N more" ghost chip when the entry63+ * carries more than two tags. Smaller, non-interactive variant of the editor chip.64+ */65+@Composable66+internal fun EntryRowTags(tags: List<String>) {67+    if (tags.isEmpty()) return68+    val accent = LocalPeachAccent.current69+    val shown = tags.take(2)70+    val extra = tags.size - shown.size71+    Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {72+        shown.forEach { tag ->73+            Text(74+                text = tag,75+                color = accent,76+                style = PeachType.tinyMono,77+                modifier = Modifier78+                    .clip(RoundedCornerShape(4.dp))79+                    .background(accent.copy(alpha = 0.12f))80+                    .border(0.5.dp, accent.copy(alpha = 0.28f), RoundedCornerShape(4.dp))81+                    .padding(horizontal = 5.dp, vertical = 1.dp),82+            )83+        }84+        if (extra > 0) {85+            Text(86+                text = "+$extra more",87+                color = PeachColors.T2,88+                style = PeachType.tinyMono,89+                modifier = Modifier90+                    .clip(RoundedCornerShape(4.dp))91+                    .border(0.5.dp, PeachColors.T3, RoundedCornerShape(4.dp))92+                    .padding(horizontal = 5.dp, vertical = 1.dp),93+            )94+        }95+    }96+}

view file

app/src/main/java/com/peachpasswords/ui/vault/VaultListScreen.kt+13 −0
@@ -76,6 +76,8 @@7676     val search by vm.search.collectAsState()7777     val total by vm.totalCount.collectAsState()7878     val flashId by vm.flashId.collectAsState()79+    val allTags by vm.allTags.collectAsState()80+    val activeTagFilter by vm.activeTagFilter.collectAsState()7981 8082     ShellBackground {8183         Column(Modifier.fillMaxSize()) {@@ -88,6 +90,13 @@8890                 onChange = vm::setSearch,8991                 count = if (search.isNotBlank()) "${entries.size}/$total" else "$total",9092             )93+            if (allTags.isNotEmpty()) {94+                TagFilterStrip(95+                    allTags = allTags,96+                    activeTagFilter = activeTagFilter,97+                    onSelect = vm::setTagFilter,98+                )99+            }91100             SortBar(92101                 active = sort,93102                 onSort = vm::setSort,@@ -301,6 +310,10 @@301310                     style = TextStyle(fontFamily = PeachType.Mono, fontSize = 9.sp),302311                     maxLines = 1,303312                 )313+            }314+            entry.tags?.takeIf { it.isNotEmpty() }?.let { tags ->315+                Spacer(Modifier.height(4.dp))316+                EntryRowTags(tags)304317             }305318         }306319         if (entry.hasTOTP()) {

view file

app/src/main/java/com/peachpasswords/ui/vault/VaultListViewModel.kt+12 −2
@@ -34,6 +34,9 @@3434     private val _search = MutableStateFlow("")3535     val search: StateFlow<String> = _search.asStateFlow()3636 37+    private val _tagFilter = MutableStateFlow<String?>(null)38+    val activeTagFilter: StateFlow<String?> = _tagFilter.asStateFlow()39+3740     private val _flashId = MutableStateFlow<String?>(null)3841     val flashId: StateFlow<String?> = _flashId.asStateFlow()3942 @@ -41,16 +44,23 @@4144 4245     /** Live, filtered + sorted active entries. */4346     val entries: StateFlow<List<VaultEntry>> =44-        combine(vault.entries, _sort, _search) { list, sort, query ->45-            applyFilterSort(list, sort, query)47+        combine(vault.entries, _sort, _search, _tagFilter) { list, sort, query, tag ->48+            val base = if (tag == null) list49+                       else list.filter { e -> e.tags?.any { it.equals(tag, ignoreCase = true) } == true }50+            applyFilterSort(base, sort, query)4651         }.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList())4752 53+    val allTags: StateFlow<List<String>> =54+        vault.entries.map { vault.getDistinctTags() }55+            .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList())56+4857     val totalCount: StateFlow<Int> =4958         vault.entries.map { it.size }5059             .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0)5160 5261     fun setSort(order: SortOrder) { _sort.value = order }5362     fun setSearch(q: String) { _search.value = q }63+    fun setTagFilter(tag: String?) { _tagFilter.value = tag }5464 5565     fun lock() = vault.lock()5666 

view file