aboutsummaryrefslogtreecommitdiff
path: root/ui-compose
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-07-18 22:26:32 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2022-07-18 22:53:02 +0530
commitb92a2ca18b50d479e22ad68400b3c6f33e2dc477 (patch)
tree43505dc4e2eca900ee289ba0f8659e707455a374 /ui-compose
parentc0f04bec778e8150fd0e783213a5b5478b25fd1b (diff)
Add KeyList composable
Diffstat (limited to 'ui-compose')
-rw-r--r--ui-compose/build.gradle.kts2
-rw-r--r--ui-compose/src/main/kotlin/app/passwordstore/ui/pgp/PGPKeyList.kt39
2 files changed, 40 insertions, 1 deletions
diff --git a/ui-compose/build.gradle.kts b/ui-compose/build.gradle.kts
index 901896a3..8dfee593 100644
--- a/ui-compose/build.gradle.kts
+++ b/ui-compose/build.gradle.kts
@@ -18,7 +18,7 @@ android {
dependencies {
api(libs.compose.foundation.core)
api(libs.compose.foundation.layout)
- api(libs.compose.material)
api(libs.compose.material3)
api(libs.compose.ui.core)
+ implementation(projects.cryptoPgpainless)
}
diff --git a/ui-compose/src/main/kotlin/app/passwordstore/ui/pgp/PGPKeyList.kt b/ui-compose/src/main/kotlin/app/passwordstore/ui/pgp/PGPKeyList.kt
new file mode 100644
index 00000000..ccc6fa01
--- /dev/null
+++ b/ui-compose/src/main/kotlin/app/passwordstore/ui/pgp/PGPKeyList.kt
@@ -0,0 +1,39 @@
+package app.passwordstore.ui.pgp
+
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Box
+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.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.dp
+import app.passwordstore.crypto.GpgIdentifier
+
+@Composable
+public fun KeyList(
+ identifiers: List<GpgIdentifier>,
+ onItemClick: (identifier: GpgIdentifier) -> Unit,
+ modifier: Modifier = Modifier,
+) {
+ LazyColumn(modifier = modifier) {
+ items(identifiers) { identifier ->
+ KeyItem(identifier = identifier, modifier = Modifier.clickable { onItemClick(identifier) })
+ }
+ }
+}
+
+@Composable
+private fun KeyItem(
+ identifier: GpgIdentifier,
+ modifier: Modifier = Modifier,
+) {
+ val label =
+ when (identifier) {
+ is GpgIdentifier.KeyId -> identifier.id.toString()
+ is GpgIdentifier.UserId -> identifier.email
+ }
+ Box(modifier = modifier.padding(16.dp).fillMaxWidth()) { Text(text = label) }
+}