ea7e63f21211
feat: D12 VaultList long-press context menu (copy pw/user/TOTP, edit, trash) + multi-select mode with batch soft-delete and UNDO snackbar (v2.1.35)
- time
- 2026-06-09 04:45 UTC · 5 months ago
- machine
- koh2
- agent
- claude-opus-4-8
- session
- peach remaining gaps
- parent
- 3d354b664dc8
↓ peach-android-ea7e63f2.tar.gzatlas at this save
files changed6 files
app/drafts/D12/ContextMenuSheet.kt+0 −173app/drafts/D12/MultiSelectUi.kt+0 −115app/src/main/java/com/peachpasswords/ui/vault/ContextMenuSheet.kt+173 −0app/src/main/java/com/peachpasswords/ui/vault/MultiSelectUi.kt+115 −0app/src/main/java/com/peachpasswords/ui/vault/VaultListScreen.kt+89 −6app/src/main/java/com/peachpasswords/ui/vault/VaultListViewModel.kt+68 −0app/drafts/D12/ContextMenuSheet.kt+0 −173
@@ -1,173 +0,0 @@1-package com.peachpasswords.ui.vault2-3-import androidx.compose.foundation.background4-import androidx.compose.foundation.clickable5-import androidx.compose.foundation.interaction.MutableInteractionSource6-import androidx.compose.foundation.interaction.collectIsPressedAsState7-import androidx.compose.foundation.layout.Arrangement8-import androidx.compose.foundation.layout.Box9-import androidx.compose.foundation.layout.Column10-import androidx.compose.foundation.layout.Row11-import androidx.compose.foundation.layout.Spacer12-import androidx.compose.foundation.layout.fillMaxWidth13-import androidx.compose.foundation.layout.height14-import androidx.compose.foundation.layout.heightIn15-import androidx.compose.foundation.layout.navigationBarsPadding16-import androidx.compose.foundation.layout.padding17-import androidx.compose.material3.ExperimentalMaterial3Api18-import androidx.compose.material3.ModalBottomSheet19-import androidx.compose.material3.Text20-import androidx.compose.material3.rememberModalBottomSheetState21-import androidx.compose.runtime.Composable22-import androidx.compose.runtime.getValue23-import androidx.compose.runtime.remember24-import androidx.compose.ui.Alignment25-import androidx.compose.ui.Modifier26-import androidx.compose.ui.draw.drawBehind27-import androidx.compose.ui.geometry.Offset28-import androidx.compose.ui.geometry.Size29-import androidx.compose.ui.graphics.Color30-import androidx.compose.ui.text.font.FontStyle31-import androidx.compose.ui.text.style.TextAlign32-import androidx.compose.ui.unit.dp33-import androidx.compose.ui.unit.sp34-import com.peachpasswords.ui.theme.LocalPeachAccent35-import com.peachpasswords.ui.theme.PeachColors36-import com.peachpasswords.ui.theme.PeachType37-import com.peachpasswords.vault.VaultEntry38-import com.peachpasswords.vault.hasTOTP39-40-/**41- * D12 long-press context menu (spec §9). A glass ModalBottomSheet over an entry42- * row offering quick copy / edit / trash without opening the detail screen.43- *44- * Self-contained, drop-in. Triggered from VaultListScreen on a 500ms long-press45- * (see INTEGRATION.md for the pointerInput anchor). Callbacks are wired to the46- * VM in the host; this composable owns no business logic.47- */48-@OptIn(ExperimentalMaterial3Api::class)49-@Composable50-fun ContextMenuSheet(51- entry: VaultEntry,52- onCopyPassword: () -> Unit,53- onCopyUsername: () -> Unit,54- onCopyTotp: () -> Unit,55- onEdit: () -> Unit,56- onMoveToTrash: () -> Unit,57- onDismiss: () -> Unit,58-) {59- val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)60-61- ModalBottomSheet(62- onDismissRequest = onDismiss,63- sheetState = sheetState,64- containerColor = PeachColors.SurfaceElevated,65- dragHandle = null,66- ) {67- Column(68- Modifier69- .fillMaxWidth()70- .padding(top = 8.dp)71- .navigationBarsPadding(),72- ) {73- // Entry name header — non-interactive title.74- Text(75- text = entry.title,76- color = PeachColors.T0,77- style = PeachType.entryNameList.copy(fontSize = 15.sp),78- modifier = Modifier.padding(horizontal = 20.dp, vertical = 12.dp),79- )80- Divider()81-82- val username = entry.username ?: entry.email83- if (!entry.password.isNullOrEmpty()) {84- ActionRow(label = "Copy password", onClick = { onCopyPassword(); onDismiss() })85- }86- if (!username.isNullOrEmpty()) {87- ActionRow(label = "Copy username", onClick = { onCopyUsername(); onDismiss() })88- }89- if (entry.hasTOTP()) {90- ActionRow(label = "Copy TOTP code", onClick = { onCopyTotp(); onDismiss() })91- }92- ActionRow(label = "Edit", onClick = { onEdit(); onDismiss() })93- ActionRow(94- label = "Move to trash",95- textColor = PeachColors.Breach,96- onClick = { onMoveToTrash(); onDismiss() },97- )98-99- Divider()100- CancelRow(onClick = onDismiss)101- Spacer(Modifier.height(4.dp))102- }103- }104-}105-106-@Composable107-private fun Divider() {108- Box(109- Modifier110- .fillMaxWidth()111- .height(1.dp)112- .background(PeachColors.T3),113- )114-}115-116-/**117- * A single action row: 44dp min height, IBM Plex Mono 12sp, with a 2dp accent118- * left-border that fades in on press (the spec's "accent left-border on press").119- */120-@Composable121-private fun ActionRow(122- label: String,123- textColor: Color = PeachColors.T0,124- onClick: () -> Unit,125-) {126- val accent = LocalPeachAccent.current127- val interaction = remember { MutableInteractionSource() }128- val pressed by interaction.collectIsPressedAsState()129- Row(130- modifier = Modifier131- .fillMaxWidth()132- .heightIn(min = 44.dp)133- .clickable(interactionSource = interaction, indication = null, onClick = onClick)134- .background(if (pressed) PeachColors.T4 else Color.Transparent)135- .drawBehind {136- if (pressed) {137- drawRect(138- color = accent,139- topLeft = Offset.Zero,140- size = Size(2.dp.toPx(), size.height),141- )142- }143- }144- .padding(horizontal = 20.dp, vertical = 12.dp),145- verticalAlignment = Alignment.CenterVertically,146- ) {147- Text(148- text = label,149- color = textColor,150- style = PeachType.bodyMono.copy(fontSize = 12.sp),151- )152- }153-}154-155-@Composable156-private fun CancelRow(onClick: () -> Unit) {157- Row(158- modifier = Modifier159- .fillMaxWidth()160- .heightIn(min = 44.dp)161- .clickable(onClick = onClick)162- .padding(horizontal = 20.dp, vertical = 12.dp),163- horizontalArrangement = Arrangement.Center,164- verticalAlignment = Alignment.CenterVertically,165- ) {166- Text(167- text = "Cancel",168- color = PeachColors.T2,169- style = PeachType.labelMono.copy(fontSize = 11.sp),170- textAlign = TextAlign.Center,171- )172- }173-}app/drafts/D12/MultiSelectUi.kt+0 −115
@@ -1,115 +0,0 @@1-package com.peachpasswords.ui.vault2-3-import androidx.compose.animation.animateColorAsState4-import androidx.compose.foundation.background5-import androidx.compose.foundation.border6-import androidx.compose.foundation.clickable7-import androidx.compose.foundation.layout.Arrangement8-import androidx.compose.foundation.layout.Box9-import androidx.compose.foundation.layout.Row10-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.layout.size15-import androidx.compose.foundation.layout.statusBarsPadding16-import androidx.compose.foundation.layout.width17-import androidx.compose.foundation.shape.CircleShape18-import androidx.compose.foundation.shape.RoundedCornerShape19-import androidx.compose.material.icons.Icons20-import androidx.compose.material.icons.rounded.Check21-import androidx.compose.material3.Icon22-import androidx.compose.material3.Text23-import androidx.compose.runtime.Composable24-import androidx.compose.runtime.getValue25-import androidx.compose.ui.Alignment26-import androidx.compose.ui.Modifier27-import androidx.compose.ui.draw.clip28-import androidx.compose.ui.graphics.Color29-import androidx.compose.ui.unit.dp30-import androidx.compose.ui.unit.sp31-import com.peachpasswords.ui.theme.LocalPeachAccent32-import com.peachpasswords.ui.theme.PeachColors33-import com.peachpasswords.ui.theme.PeachType34-35-/**36- * D12 multi-select per-row checkbox (spec §9). 20dp circle: unchecked = 1dp t237- * border on a transparent fill; checked = accent fill with a white check.38- */39-@Composable40-fun MultiSelectCheckbox(checked: Boolean, modifier: Modifier = Modifier) {41- val accent = LocalPeachAccent.current42- val fill by animateColorAsState(43- targetValue = if (checked) accent else Color.Transparent,44- label = "checkbox-fill",45- )46- Box(47- modifier = modifier48- .size(20.dp)49- .clip(CircleShape)50- .background(fill)51- .then(52- if (checked) Modifier53- else Modifier.border(1.dp, PeachColors.T2, CircleShape),54- ),55- contentAlignment = Alignment.Center,56- ) {57- if (checked) {58- Icon(59- Icons.Rounded.Check,60- contentDescription = "selected",61- tint = Color.White,62- modifier = Modifier.size(13.dp),63- )64- }65- }66-}67-68-/**69- * D12 multi-select top bar (spec §9). Replaces the wordmark/icons row while70- * [com.peachpasswords.ui.vault.VaultListViewModel.isMultiSelectMode] is on:71- * "[N] selected" + a breach-colored Delete + a t2 Cancel.72- */73-@Composable74-fun MultiSelectTopBar(75- count: Int,76- onDelete: () -> Unit,77- onCancel: () -> Unit,78-) {79- Row(80- modifier = Modifier81- .fillMaxWidth()82- .statusBarsPadding()83- .height(56.dp)84- .padding(horizontal = 16.dp),85- verticalAlignment = Alignment.CenterVertically,86- horizontalArrangement = Arrangement.SpaceBetween,87- ) {88- Text(89- text = "$count selected",90- color = PeachColors.T0,91- style = PeachType.bodyMono.copy(fontSize = 13.sp),92- )93- Row(verticalAlignment = Alignment.CenterVertically) {94- Text(95- text = "Delete",96- color = if (count > 0) PeachColors.Breach else PeachColors.T2,97- style = PeachType.labelMono.copy(fontSize = 11.sp),98- modifier = Modifier99- .clip(RoundedCornerShape(4.dp))100- .clickable(enabled = count > 0, onClick = onDelete)101- .padding(horizontal = 8.dp, vertical = 6.dp),102- )103- Spacer(Modifier.width(8.dp))104- Text(105- text = "Cancel",106- color = PeachColors.T2,107- style = PeachType.labelMono.copy(fontSize = 11.sp),108- modifier = Modifier109- .clip(RoundedCornerShape(4.dp))110- .clickable(onClick = onCancel)111- .padding(horizontal = 8.dp, vertical = 6.dp),112- )113- }114- }115-}app/src/main/java/com/peachpasswords/ui/vault/ContextMenuSheet.kt+173 −0
@@ -0,0 +1,173 @@1+package com.peachpasswords.ui.vault2+3+import androidx.compose.foundation.background4+import androidx.compose.foundation.clickable5+import androidx.compose.foundation.interaction.MutableInteractionSource6+import androidx.compose.foundation.interaction.collectIsPressedAsState7+import androidx.compose.foundation.layout.Arrangement8+import androidx.compose.foundation.layout.Box9+import androidx.compose.foundation.layout.Column10+import androidx.compose.foundation.layout.Row11+import androidx.compose.foundation.layout.Spacer12+import androidx.compose.foundation.layout.fillMaxWidth13+import androidx.compose.foundation.layout.height14+import androidx.compose.foundation.layout.heightIn15+import androidx.compose.foundation.layout.navigationBarsPadding16+import androidx.compose.foundation.layout.padding17+import androidx.compose.material3.ExperimentalMaterial3Api18+import androidx.compose.material3.ModalBottomSheet19+import androidx.compose.material3.Text20+import androidx.compose.material3.rememberModalBottomSheetState21+import androidx.compose.runtime.Composable22+import androidx.compose.runtime.getValue23+import androidx.compose.runtime.remember24+import androidx.compose.ui.Alignment25+import androidx.compose.ui.Modifier26+import androidx.compose.ui.draw.drawBehind27+import androidx.compose.ui.geometry.Offset28+import androidx.compose.ui.geometry.Size29+import androidx.compose.ui.graphics.Color30+import androidx.compose.ui.text.font.FontStyle31+import androidx.compose.ui.text.style.TextAlign32+import androidx.compose.ui.unit.dp33+import androidx.compose.ui.unit.sp34+import com.peachpasswords.ui.theme.LocalPeachAccent35+import com.peachpasswords.ui.theme.PeachColors36+import com.peachpasswords.ui.theme.PeachType37+import com.peachpasswords.vault.VaultEntry38+import com.peachpasswords.vault.hasTOTP39+40+/**41+ * D12 long-press context menu (spec §9). A glass ModalBottomSheet over an entry42+ * row offering quick copy / edit / trash without opening the detail screen.43+ *44+ * Self-contained, drop-in. Triggered from VaultListScreen on a 500ms long-press45+ * (see INTEGRATION.md for the pointerInput anchor). Callbacks are wired to the46+ * VM in the host; this composable owns no business logic.47+ */48+@OptIn(ExperimentalMaterial3Api::class)49+@Composable50+fun ContextMenuSheet(51+ entry: VaultEntry,52+ onCopyPassword: () -> Unit,53+ onCopyUsername: () -> Unit,54+ onCopyTotp: () -> Unit,55+ onEdit: () -> Unit,56+ onMoveToTrash: () -> Unit,57+ onDismiss: () -> Unit,58+) {59+ val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)60+61+ ModalBottomSheet(62+ onDismissRequest = onDismiss,63+ sheetState = sheetState,64+ containerColor = PeachColors.SurfaceElevated,65+ dragHandle = null,66+ ) {67+ Column(68+ Modifier69+ .fillMaxWidth()70+ .padding(top = 8.dp)71+ .navigationBarsPadding(),72+ ) {73+ // Entry name header — non-interactive title.74+ Text(75+ text = entry.title,76+ color = PeachColors.T0,77+ style = PeachType.entryNameList.copy(fontSize = 15.sp),78+ modifier = Modifier.padding(horizontal = 20.dp, vertical = 12.dp),79+ )80+ Divider()81+82+ val username = entry.username ?: entry.email83+ if (!entry.password.isNullOrEmpty()) {84+ ActionRow(label = "Copy password", onClick = { onCopyPassword(); onDismiss() })85+ }86+ if (!username.isNullOrEmpty()) {87+ ActionRow(label = "Copy username", onClick = { onCopyUsername(); onDismiss() })88+ }89+ if (entry.hasTOTP()) {90+ ActionRow(label = "Copy TOTP code", onClick = { onCopyTotp(); onDismiss() })91+ }92+ ActionRow(label = "Edit", onClick = { onEdit(); onDismiss() })93+ ActionRow(94+ label = "Move to trash",95+ textColor = PeachColors.Breach,96+ onClick = { onMoveToTrash(); onDismiss() },97+ )98+99+ Divider()100+ CancelRow(onClick = onDismiss)101+ Spacer(Modifier.height(4.dp))102+ }103+ }104+}105+106+@Composable107+private fun Divider() {108+ Box(109+ Modifier110+ .fillMaxWidth()111+ .height(1.dp)112+ .background(PeachColors.T3),113+ )114+}115+116+/**117+ * A single action row: 44dp min height, IBM Plex Mono 12sp, with a 2dp accent118+ * left-border that fades in on press (the spec's "accent left-border on press").119+ */120+@Composable121+private fun ActionRow(122+ label: String,123+ textColor: Color = PeachColors.T0,124+ onClick: () -> Unit,125+) {126+ val accent = LocalPeachAccent.current127+ val interaction = remember { MutableInteractionSource() }128+ val pressed by interaction.collectIsPressedAsState()129+ Row(130+ modifier = Modifier131+ .fillMaxWidth()132+ .heightIn(min = 44.dp)133+ .clickable(interactionSource = interaction, indication = null, onClick = onClick)134+ .background(if (pressed) PeachColors.T4 else Color.Transparent)135+ .drawBehind {136+ if (pressed) {137+ drawRect(138+ color = accent,139+ topLeft = Offset.Zero,140+ size = Size(2.dp.toPx(), size.height),141+ )142+ }143+ }144+ .padding(horizontal = 20.dp, vertical = 12.dp),145+ verticalAlignment = Alignment.CenterVertically,146+ ) {147+ Text(148+ text = label,149+ color = textColor,150+ style = PeachType.bodyMono.copy(fontSize = 12.sp),151+ )152+ }153+}154+155+@Composable156+private fun CancelRow(onClick: () -> Unit) {157+ Row(158+ modifier = Modifier159+ .fillMaxWidth()160+ .heightIn(min = 44.dp)161+ .clickable(onClick = onClick)162+ .padding(horizontal = 20.dp, vertical = 12.dp),163+ horizontalArrangement = Arrangement.Center,164+ verticalAlignment = Alignment.CenterVertically,165+ ) {166+ Text(167+ text = "Cancel",168+ color = PeachColors.T2,169+ style = PeachType.labelMono.copy(fontSize = 11.sp),170+ textAlign = TextAlign.Center,171+ )172+ }173+}app/src/main/java/com/peachpasswords/ui/vault/MultiSelectUi.kt+115 −0
@@ -0,0 +1,115 @@1+package com.peachpasswords.ui.vault2+3+import androidx.compose.animation.animateColorAsState4+import androidx.compose.foundation.background5+import androidx.compose.foundation.border6+import androidx.compose.foundation.clickable7+import androidx.compose.foundation.layout.Arrangement8+import androidx.compose.foundation.layout.Box9+import androidx.compose.foundation.layout.Row10+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.layout.size15+import androidx.compose.foundation.layout.statusBarsPadding16+import androidx.compose.foundation.layout.width17+import androidx.compose.foundation.shape.CircleShape18+import androidx.compose.foundation.shape.RoundedCornerShape19+import androidx.compose.material.icons.Icons20+import androidx.compose.material.icons.rounded.Check21+import androidx.compose.material3.Icon22+import androidx.compose.material3.Text23+import androidx.compose.runtime.Composable24+import androidx.compose.runtime.getValue25+import androidx.compose.ui.Alignment26+import androidx.compose.ui.Modifier27+import androidx.compose.ui.draw.clip28+import androidx.compose.ui.graphics.Color29+import androidx.compose.ui.unit.dp30+import androidx.compose.ui.unit.sp31+import com.peachpasswords.ui.theme.LocalPeachAccent32+import com.peachpasswords.ui.theme.PeachColors33+import com.peachpasswords.ui.theme.PeachType34+35+/**36+ * D12 multi-select per-row checkbox (spec §9). 20dp circle: unchecked = 1dp t237+ * border on a transparent fill; checked = accent fill with a white check.38+ */39+@Composable40+fun MultiSelectCheckbox(checked: Boolean, modifier: Modifier = Modifier) {41+ val accent = LocalPeachAccent.current42+ val fill by animateColorAsState(43+ targetValue = if (checked) accent else Color.Transparent,44+ label = "checkbox-fill",45+ )46+ Box(47+ modifier = modifier48+ .size(20.dp)49+ .clip(CircleShape)50+ .background(fill)51+ .then(52+ if (checked) Modifier53+ else Modifier.border(1.dp, PeachColors.T2, CircleShape),54+ ),55+ contentAlignment = Alignment.Center,56+ ) {57+ if (checked) {58+ Icon(59+ Icons.Rounded.Check,60+ contentDescription = "selected",61+ tint = Color.White,62+ modifier = Modifier.size(13.dp),63+ )64+ }65+ }66+}67+68+/**69+ * D12 multi-select top bar (spec §9). Replaces the wordmark/icons row while70+ * [com.peachpasswords.ui.vault.VaultListViewModel.isMultiSelectMode] is on:71+ * "[N] selected" + a breach-colored Delete + a t2 Cancel.72+ */73+@Composable74+fun MultiSelectTopBar(75+ count: Int,76+ onDelete: () -> Unit,77+ onCancel: () -> Unit,78+) {79+ Row(80+ modifier = Modifier81+ .fillMaxWidth()82+ .statusBarsPadding()83+ .height(56.dp)84+ .padding(horizontal = 16.dp),85+ verticalAlignment = Alignment.CenterVertically,86+ horizontalArrangement = Arrangement.SpaceBetween,87+ ) {88+ Text(89+ text = "$count selected",90+ color = PeachColors.T0,91+ style = PeachType.bodyMono.copy(fontSize = 13.sp),92+ )93+ Row(verticalAlignment = Alignment.CenterVertically) {94+ Text(95+ text = "Delete",96+ color = if (count > 0) PeachColors.Breach else PeachColors.T2,97+ style = PeachType.labelMono.copy(fontSize = 11.sp),98+ modifier = Modifier99+ .clip(RoundedCornerShape(4.dp))100+ .clickable(enabled = count > 0, onClick = onDelete)101+ .padding(horizontal = 8.dp, vertical = 6.dp),102+ )103+ Spacer(Modifier.width(8.dp))104+ Text(105+ text = "Cancel",106+ color = PeachColors.T2,107+ style = PeachType.labelMono.copy(fontSize = 11.sp),108+ modifier = Modifier109+ .clip(RoundedCornerShape(4.dp))110+ .clickable(onClick = onCancel)111+ .padding(horizontal = 8.dp, vertical = 6.dp),112+ )113+ }114+ }115+}app/src/main/java/com/peachpasswords/ui/vault/VaultListScreen.kt+89 −6
@@ -5,6 +5,7 @@55 import androidx.compose.foundation.border66 import androidx.compose.foundation.clickable77 import androidx.compose.foundation.gestures.detectHorizontalDragGestures8+import androidx.compose.foundation.gestures.detectTapGestures89 import androidx.compose.foundation.interaction.MutableInteractionSource910 import androidx.compose.foundation.interaction.collectIsPressedAsState1011 import androidx.compose.foundation.layout.Arrangement@@ -32,11 +33,19 @@3233 import androidx.compose.material.icons.rounded.Search3334 import androidx.compose.material.icons.rounded.Settings3435 import androidx.compose.material3.Icon36+import androidx.compose.material3.Snackbar37+import androidx.compose.material3.SnackbarDuration38+import androidx.compose.material3.SnackbarHost39+import androidx.compose.material3.SnackbarHostState40+import androidx.compose.material3.SnackbarResult3541 import androidx.compose.material3.Text3642 import androidx.compose.runtime.Composable43+import androidx.compose.runtime.LaunchedEffect3744 import androidx.compose.runtime.getValue45+import androidx.compose.runtime.mutableStateOf3846 import androidx.compose.runtime.produceState3947 import androidx.compose.runtime.remember48+import androidx.compose.runtime.setValue4049 import androidx.compose.ui.Alignment4150 import androidx.compose.ui.Modifier4251 import androidx.compose.ui.draw.clip@@ -48,6 +57,7 @@4857 import androidx.compose.ui.input.pointer.pointerInput4958 import androidx.compose.ui.input.pointer.positionChange5059 import androidx.compose.ui.platform.LocalContext60+import androidx.compose.ui.platform.LocalView5161 import androidx.compose.ui.text.TextStyle5262 import androidx.compose.ui.unit.dp5363 import androidx.compose.ui.unit.sp@@ -78,13 +88,39 @@7888 val flashId by vm.flashId.collectAsState()7989 val allTags by vm.allTags.collectAsState()8090 val activeTagFilter by vm.activeTagFilter.collectAsState()91+ val isMultiSelect by vm.isMultiSelectMode.collectAsState()92+ val selectedIds by vm.selectedIds.collectAsState()93+ val undoEvent by vm.undoEvent.collectAsState()94+ val snackbarHostState = remember { SnackbarHostState() }95+ var menuEntry by remember { mutableStateOf<VaultEntry?>(null) }96+ val view = LocalView.current8197 98+ LaunchedEffect(undoEvent) {99+ val ev = undoEvent ?: return@LaunchedEffect100+ vm.consumeUndoEvent()101+ val result = snackbarHostState.showSnackbar(102+ message = ev.message,103+ actionLabel = "UNDO",104+ duration = SnackbarDuration.Short,105+ )106+ if (result == SnackbarResult.ActionPerformed) vm.restoreEntries(ev.ids)107+ }108+82109 ShellBackground {110+ Box(Modifier.fillMaxSize()) {83111 Column(Modifier.fillMaxSize()) {84- TopBar(85- onSettings = { onNavigate(PeachNav.Settings) },86- onAdd = { onNavigate(PeachNav.EntryEdit(null)) },87- )112+ if (isMultiSelect) {113+ MultiSelectTopBar(114+ count = selectedIds.size,115+ onDelete = { vm.batchSoftDelete() },116+ onCancel = { vm.exitMultiSelect() },117+ )118+ } else {119+ TopBar(120+ onSettings = { onNavigate(PeachNav.Settings) },121+ onAdd = { onNavigate(PeachNav.EntryEdit(null)) },122+ )123+ }88124 SearchBar(89125 value = search,90126 onChange = vm::setSearch,@@ -111,8 +147,17 @@111147 EntryRow(112148 entry = entry,113149 flashing = flashId == entry.id,114- canSwipeCopy = vm.canSwipeCopy(entry),115- onTap = { onNavigate(PeachNav.EntryDetail(entry.id)) },150+ canSwipeCopy = vm.canSwipeCopy(entry) && !isMultiSelect,151+ multiSelect = isMultiSelect,152+ selected = entry.id in selectedIds,153+ onTap = {154+ if (isMultiSelect) vm.toggleSelected(entry.id)155+ else onNavigate(PeachNav.EntryDetail(entry.id))156+ },157+ onLongPress = {158+ if (isMultiSelect) vm.toggleSelected(entry.id)159+ else menuEntry = entry160+ },116161 onSwipeCopy = { vm.copyPassword(entry) },117162 )118163 }@@ -122,7 +167,31 @@122167 }123168 }124169 }170+ SnackbarHost(171+ hostState = snackbarHostState,172+ modifier = Modifier.align(Alignment.BottomCenter).navigationBarsPadding(),173+ ) { data ->174+ Snackbar(175+ containerColor = PeachColors.SurfaceElevated,176+ contentColor = PeachColors.T0,177+ actionContentColor = LocalPeachAccent.current,178+ snackbarData = data,179+ )180+ }181+ } // Box125182 }183+184+ menuEntry?.let { e ->185+ ContextMenuSheet(186+ entry = e,187+ onCopyPassword = { vm.copyPassword(e); PeachHaptics.onCopy(view) },188+ onCopyUsername = { vm.copyUsername(e); PeachHaptics.onCopy(view) },189+ onCopyTotp = { vm.copyTotp(e); PeachHaptics.onCopy(view) },190+ onEdit = { onNavigate(PeachNav.EntryEdit(e.id)) },191+ onMoveToTrash = { vm.softDelete(e) },192+ onDismiss = { menuEntry = null },193+ )194+ }126195 }127196 128197 @Composable@@ -251,7 +320,10 @@251320 entry: VaultEntry,252321 flashing: Boolean,253322 canSwipeCopy: Boolean,323+ multiSelect: Boolean,324+ selected: Boolean,254325 onTap: () -> Unit,326+ onLongPress: () -> Unit,255327 onSwipeCopy: () -> Unit,256328 ) {257329 val context = LocalContext.current@@ -290,11 +362,22 @@290362 onHorizontalDrag = { change, amount -> dx += amount; dy += change.positionChange().y },291363 )292364 }365+ .pointerInput(entry.id, multiSelect) {366+ detectTapGestures(367+ onLongPress = {368+ PeachHaptics.onLongPress(context)369+ onLongPress()370+ },371+ )372+ }293373 .clickable(interactionSource = interaction, indication = null, onClick = onTap)294374 .padding(horizontal = 16.dp, vertical = 9.dp),295375 horizontalArrangement = Arrangement.spacedBy(10.dp),296376 verticalAlignment = Alignment.CenterVertically,297377 ) {378+ if (multiSelect) {379+ MultiSelectCheckbox(checked = selected)380+ }298381 FaviconInitials(source = entry.url ?: entry.title, size = 26.dp)299382 Column(Modifier.weight(1f)) {300383 Text(app/src/main/java/com/peachpasswords/ui/vault/VaultListViewModel.kt+68 −0
@@ -5,6 +5,7 @@55 import android.content.Context66 import androidx.lifecycle.ViewModel77 import androidx.lifecycle.viewModelScope8+import com.peachpasswords.vault.TOTPGenerator89 import com.peachpasswords.vault.VaultEntry910 import com.peachpasswords.vault.VaultRepository1011 import com.peachpasswords.vault.isLogin@@ -63,6 +64,73 @@6364 fun setTagFilter(tag: String?) { _tagFilter.value = tag }6465 6566 fun lock() = vault.lock()67+68+ // ── Multi-select ────────────────────────────────────────────────────────69+ private val _isMultiSelectMode = MutableStateFlow(false)70+ val isMultiSelectMode: StateFlow<Boolean> = _isMultiSelectMode.asStateFlow()71+72+ private val _selectedIds = MutableStateFlow<Set<String>>(emptySet())73+ val selectedIds: StateFlow<Set<String>> = _selectedIds.asStateFlow()74+75+ fun enterMultiSelect(id: String) {76+ _isMultiSelectMode.value = true77+ _selectedIds.value = setOf(id)78+ }79+80+ fun toggleSelected(id: String) {81+ val next = _selectedIds.value.toMutableSet()82+ if (!next.add(id)) next.remove(id)83+ _selectedIds.value = next84+ }85+86+ fun exitMultiSelect() {87+ _isMultiSelectMode.value = false88+ _selectedIds.value = emptySet()89+ }90+91+ // ── Soft delete + undo ──────────────────────────────────────────────────92+ /** One-shot undo event for the snackbar: label + ids to restore. */93+ data class UndoEvent(val message: String, val ids: List<String>)94+95+ private val _undoEvent = MutableStateFlow<UndoEvent?>(null)96+ val undoEvent: StateFlow<UndoEvent?> = _undoEvent.asStateFlow()97+ fun consumeUndoEvent() { _undoEvent.value = null }98+99+ fun softDelete(entry: VaultEntry) {100+ viewModelScope.launch {101+ runCatching { vault.deleteEntry(entry.id) }102+ _undoEvent.value = UndoEvent("${entry.title} moved to trash", listOf(entry.id))103+ }104+ }105+106+ fun batchSoftDelete() {107+ val ids = _selectedIds.value.toList()108+ if (ids.isEmpty()) return109+ viewModelScope.launch {110+ ids.forEach { id -> runCatching { vault.deleteEntry(id) } }111+ exitMultiSelect()112+ _undoEvent.value = UndoEvent("${ids.size} entries moved to trash", ids)113+ }114+ }115+116+ fun restoreEntries(ids: List<String>) {117+ viewModelScope.launch { ids.forEach { id -> runCatching { vault.restoreEntry(id) } } }118+ }119+120+ // ── Context-menu copy helpers ───────────────────────────────────────────121+ private fun copyText(value: String?) {122+ val v = value?.takeIf { it.isNotEmpty() } ?: return123+ val cm = appContext.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager124+ cm.setPrimaryClip(ClipData.newPlainText("peach", v))125+ }126+127+ fun copyUsername(entry: VaultEntry) = copyText(entry.username ?: entry.email)128+129+ /** Copy the LIVE TOTP code, never the stored seed. */130+ fun copyTotp(entry: VaultEntry) {131+ val seed = entry.totp ?: return132+ copyText(TOTPGenerator.generateCode(seed))133+ }66134 67135 /** Copy a login's password, flash the row, and fire the swipe-copy haptic. */68136 fun copyPassword(entry: VaultEntry) {