diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt index 7082913f0..d01f3c6de 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt @@ -14,12 +14,19 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.Button +import androidx.compose.material.Icon +import androidx.compose.material.IconButton import androidx.compose.material.MaterialTheme import androidx.compose.material.OutlinedTextField import androidx.compose.material.Text +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Visibility +import androidx.compose.material.icons.outlined.VisibilityOff import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.ContentScale @@ -28,7 +35,9 @@ import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.text.input.VisualTransformation import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -47,7 +56,7 @@ fun LoginPage(accountViewModel: AccountStateViewModel) { style = TextStyle( fontSize = 14.sp, textDecoration = TextDecoration.Underline, - color = Purple700 + color = MaterialTheme.colors.primary ) ) } @@ -70,6 +79,10 @@ fun LoginPage(accountViewModel: AccountStateViewModel) { //Text(text = "Insert your private or public key (view-only)") + var showPassword by remember { + mutableStateOf(false) + } + OutlinedTextField( value = key.value, onValueChange = { key.value = it }, @@ -83,7 +96,16 @@ fun LoginPage(accountViewModel: AccountStateViewModel) { text = "nsec / npub / hex private key", color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) ) - } + }, + trailingIcon = { + IconButton(onClick = { showPassword = !showPassword }) { + Icon( + imageVector = if (showPassword) Icons.Outlined.VisibilityOff else Icons.Outlined.Visibility, + contentDescription = if (showPassword) "Show Password" else "Hide Password" + ) + } + }, + visualTransformation = if (showPassword) VisualTransformation.None else PasswordVisualTransformation() ) Spacer(modifier = Modifier.height(20.dp))