aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2024-05-28 00:42:40 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2024-05-28 00:43:36 +0530
commit68d735c28e3f164b3cb4b08a3043d8f8481ffb35 (patch)
tree3c56f391b2aa6e0bc295a7a69806546cd45df728
parent1b936f623a3d89f84afb08d189458130399b9998 (diff)
feat(compose): add a password item composable
-rw-r--r--ui/compose/src/main/kotlin/app/passwordstore/ui/compose/PasswordItem.kt81
1 files changed, 81 insertions, 0 deletions
diff --git a/ui/compose/src/main/kotlin/app/passwordstore/ui/compose/PasswordItem.kt b/ui/compose/src/main/kotlin/app/passwordstore/ui/compose/PasswordItem.kt
new file mode 100644
index 00000000..63cc8304
--- /dev/null
+++ b/ui/compose/src/main/kotlin/app/passwordstore/ui/compose/PasswordItem.kt
@@ -0,0 +1,81 @@
+package app.passwordstore.ui.compose
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.clickable
+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.layout.wrapContentWidth
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
+import androidx.compose.material3.HorizontalDivider
+import androidx.compose.material3.Icon
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
+import androidx.compose.material3.minimumInteractiveComponentSize
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.vector.rememberVectorPainter
+import androidx.compose.ui.unit.dp
+import app.passwordstore.ui.compose.preview.DevicePreviews
+import app.passwordstore.ui.compose.preview.ThemePreviews
+import app.passwordstore.ui.compose.theme.APSTheme
+
+public enum class ItemType {
+ File,
+ Folder,
+}
+
+@Composable
+public fun PasswordItem(
+ label: String,
+ type: ItemType,
+ onClick: () -> Unit,
+ modifier: Modifier = Modifier
+) {
+ Row(
+ modifier =
+ modifier
+ .clickable(enabled = true, onClick = onClick)
+ .background(MaterialTheme.colorScheme.background)
+ .minimumInteractiveComponentSize()
+ .padding(horizontal = 16.dp)
+ .fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Text(
+ text = label,
+ modifier = Modifier.wrapContentWidth(),
+ style = MaterialTheme.typography.titleMedium,
+ color = MaterialTheme.colorScheme.onBackground,
+ )
+ when (type) {
+ ItemType.File -> {}
+ ItemType.Folder -> {
+ Icon(
+ painter = rememberVectorPainter(Icons.AutoMirrored.Filled.KeyboardArrowRight),
+ contentDescription = "Folder indicator",
+ tint = MaterialTheme.colorScheme.onBackground,
+ )
+ }
+ }
+ }
+}
+
+@ThemePreviews
+@DevicePreviews
+@Composable
+private fun PasswordItemPreview() {
+ APSTheme {
+ LazyColumn {
+ items(20) {
+ PasswordItem(label = "Title $it", type = ItemType.entries.random(), onClick = {})
+ HorizontalDivider()
+ }
+ }
+ }
+}