From 35a6e3b8ff0e4c4d8ab1936e442509294b606d41 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Fri, 18 Nov 2022 11:15:38 +0530 Subject: fix: add an explicit delete button to PGP key list items --- .idea/kotlinc.xml | 2 +- .../java/app/passwordstore/ui/pgp/PGPKeyList.kt | 29 +++++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index e1eea1d6..0e65ceac 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt index fd2369e0..8f46b8d5 100644 --- a/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt +++ b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt @@ -1,16 +1,22 @@ package app.passwordstore.ui.pgp -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import app.passwordstore.R import app.passwordstore.crypto.GpgIdentifier @Composable @@ -20,15 +26,14 @@ fun KeyList( modifier: Modifier = Modifier, ) { LazyColumn(modifier = modifier) { - items(identifiers) { identifier -> - KeyItem(identifier = identifier, modifier = Modifier.clickable { onItemClick(identifier) }) - } + items(identifiers) { identifier -> KeyItem(identifier = identifier, onItemClick = onItemClick) } } } @Composable private fun KeyItem( identifier: GpgIdentifier, + onItemClick: (identifier: GpgIdentifier) -> Unit, modifier: Modifier = Modifier, ) { val label = @@ -36,7 +41,19 @@ private fun KeyItem( is GpgIdentifier.KeyId -> identifier.id.toString() is GpgIdentifier.UserId -> identifier.email } - Box(modifier = modifier.padding(16.dp).fillMaxWidth()) { Text(text = label) } + Row( + modifier = modifier.padding(16.dp).fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, + ) { + Text(text = label) + IconButton(onClick = { onItemClick(identifier) }) { + Icon( + painter = painterResource(R.drawable.ic_delete_24dp), + stringResource(id = R.string.delete) + ) + } + } } @Preview -- cgit v1.2.3