aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-11-18 11:15:38 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2022-11-18 11:15:38 +0530
commit35a6e3b8ff0e4c4d8ab1936e442509294b606d41 (patch)
treea4dc5a70fd1cee029367612647fbc9fc6e28334c /app/src/main
parent6a4c0a223fc1ca3a65840513a75f53fa766f2c98 (diff)
fix: add an explicit delete button to PGP key list items
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt29
1 files changed, 23 insertions, 6 deletions
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