aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-03-24 13:15:02 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-03-24 13:17:54 +0530
commit29eaa09427bed23440270bdbf1733144f7978fdf (patch)
tree00228f8eae1e56f7957e2d02738c15f78bc499b7
parent965c80bbe40a61628abf24ac1aa725ee2c043daa (diff)
feat: add user guidance in PGP key manager screen
-rw-r--r--app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt48
1 files changed, 38 insertions, 10 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 40d9223c..e7702a91 100644
--- a/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt
+++ b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt
@@ -1,7 +1,10 @@
package app.passwordstore.ui.pgp
+import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
@@ -24,6 +27,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import app.passwordstore.R
import app.passwordstore.crypto.GpgIdentifier
+import app.passwordstore.ui.compose.theme.APSThemePreview
@Composable
fun KeyList(
@@ -31,8 +35,24 @@ fun KeyList(
onItemClick: (identifier: GpgIdentifier) -> Unit,
modifier: Modifier = Modifier,
) {
- LazyColumn(modifier = modifier) {
- items(identifiers) { identifier -> KeyItem(identifier = identifier, onItemClick = onItemClick) }
+ if (identifiers.isEmpty()) {
+ Column(
+ modifier = modifier.fillMaxSize(),
+ verticalArrangement = Arrangement.Center,
+ horizontalAlignment = Alignment.CenterHorizontally,
+ ) {
+ Image(
+ painter = painterResource(id = R.drawable.ic_launcher_foreground),
+ contentDescription = "Password Store logo"
+ )
+ Text("Import a key using the add button below")
+ }
+ } else {
+ LazyColumn(modifier = modifier) {
+ items(identifiers) { identifier ->
+ KeyItem(identifier = identifier, onItemClick = onItemClick)
+ }
+ }
}
}
@@ -97,12 +117,20 @@ private inline fun DeleteConfirmationDialog(
@Preview
@Composable
private fun KeyListPreview() {
- KeyList(
- identifiers =
- listOfNotNull(
- GpgIdentifier.fromString("john.doe@example.com"),
- GpgIdentifier.fromString("0xB950AE2813841585")
- ),
- onItemClick = {}
- )
+ APSThemePreview {
+ KeyList(
+ identifiers =
+ listOfNotNull(
+ GpgIdentifier.fromString("john.doe@example.com"),
+ GpgIdentifier.fromString("0xB950AE2813841585")
+ ),
+ onItemClick = {}
+ )
+ }
+}
+
+@Preview
+@Composable
+fun EmptyKeyListPreview() {
+ APSThemePreview { KeyList(identifiers = emptyList(), onItemClick = {}) }
}