aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-10-08 18:35:16 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2022-10-08 18:35:16 +0530
commit224d956e28be0e09832371c98112a5af692194e8 (patch)
tree4042c683312eec7c68df9e3de7e129659d396d86 /app
parent5dd7c9103808b5014def75dfcf45662f4c2e575a (diff)
feat(app): refactor `CopyButton` and add missing spacing
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/app/passwordstore/ui/crypto/DecryptScreen.kt24
1 files changed, 18 insertions, 6 deletions
diff --git a/app/src/main/java/app/passwordstore/ui/crypto/DecryptScreen.kt b/app/src/main/java/app/passwordstore/ui/crypto/DecryptScreen.kt
index 3c2ee025..d48e70a7 100644
--- a/app/src/main/java/app/passwordstore/ui/crypto/DecryptScreen.kt
+++ b/app/src/main/java/app/passwordstore/ui/crypto/DecryptScreen.kt
@@ -49,15 +49,20 @@ fun PasswordEntryScreen(
)
},
) { paddingValues ->
- val clipboard = LocalClipboardManager.current
Box(modifier = modifier.fillMaxSize().padding(paddingValues)) {
Column(modifier = Modifier.padding(8.dp)) {
Text(
text = entryName,
style = MaterialTheme.typography.headlineSmall,
+ modifier = Modifier.padding(bottom = 8.dp),
)
if (entry.password != null) {
- PasswordField(value = entry.password!!, label = "Password", initialVisibility = false)
+ PasswordField(
+ value = entry.password!!,
+ label = "Password",
+ initialVisibility = false,
+ modifier = Modifier.padding(bottom = 8.dp),
+ )
}
if (entry.hasTotp()) {
val totp by entry.totp.collectAsState(runBlocking { entry.totp.first() })
@@ -66,7 +71,8 @@ fun PasswordEntryScreen(
onValueChange = {},
readOnly = true,
label = { Text("OTP (expires in ${totp.remainingTime.inWholeSeconds}s)") },
- trailingIcon = { CopyButton { clipboard.setText(AnnotatedString(totp.value)) } }
+ trailingIcon = { CopyButton({ totp.value }) },
+ modifier = Modifier.padding(bottom = 8.dp),
)
}
if (entry.username != null) {
@@ -75,7 +81,8 @@ fun PasswordEntryScreen(
onValueChange = {},
readOnly = true,
label = { Text("Username") },
- trailingIcon = { CopyButton { clipboard.setText(AnnotatedString(entry.username!!)) } },
+ trailingIcon = { CopyButton({ entry.username!! }) },
+ modifier = Modifier.padding(bottom = 8.dp),
)
}
}
@@ -84,9 +91,14 @@ fun PasswordEntryScreen(
}
@Composable
-private fun CopyButton(onClick: () -> Unit) {
+private fun CopyButton(
+ textToCopy: () -> String,
+ modifier: Modifier = Modifier,
+) {
+ val clipboard = LocalClipboardManager.current
IconButton(
- onClick = onClick,
+ onClick = { clipboard.setText(AnnotatedString(textToCopy())) },
+ modifier = modifier,
) {
Icon(
painter = painterResource(R.drawable.ic_content_copy),