From 9bdbd552049d845383675c35c1323372d46a37b9 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 8 Oct 2022 18:28:04 +0530 Subject: feat(ui-compose): add a `PasswordField` composable and switch decrypt screen to it --- .../main/java/app/passwordstore/ui/crypto/DecryptScreen.kt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'app') 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 41687985..3dc2a401 100644 --- a/app/src/main/java/app/passwordstore/ui/crypto/DecryptScreen.kt +++ b/app/src/main/java/app/passwordstore/ui/crypto/DecryptScreen.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.unit.dp import app.passwordstore.R import app.passwordstore.data.passfile.PasswordEntry import app.passwordstore.ui.APSAppBar +import app.passwordstore.ui.compose.PasswordField import app.passwordstore.ui.compose.theme.APSThemePreview import app.passwordstore.util.time.UserClock import app.passwordstore.util.totp.UriTotpFinder @@ -56,13 +57,7 @@ fun PasswordEntryScreen( style = MaterialTheme.typography.headlineSmall, ) if (entry.password != null) { - TextField( - value = entry.password!!, - onValueChange = {}, - readOnly = true, - label = { Text("Password") }, - trailingIcon = { CopyButton { clipboard.setText(AnnotatedString(entry.password!!)) } }, - ) + PasswordField(value = entry.password!!, label = "Password", initialVisibility = false) } if (entry.hasTotp()) { val totp by entry.totp.collectAsState(runBlocking { entry.totp.first() }) @@ -97,7 +92,7 @@ private fun PasswordEntryPreview() { APSThemePreview { PasswordEntryScreen("Test Entry", createTestEntry()) } } -fun createTestEntry() = +private fun createTestEntry() = PasswordEntry( UserClock(), UriTotpFinder(), -- cgit v1.2.3