aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-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