From 531b003347a24618863e51c39f325fa7d172f226 Mon Sep 17 00:00:00 2001 From: Dave Severns <149429124+dseverns-livefront@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:16:27 -0500 Subject: [PATCH] PM-15049 PW strength indicator design audit (#4334) --- .../PasswordStrengthIndicator.kt | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/completeregistration/PasswordStrengthIndicator.kt b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/completeregistration/PasswordStrengthIndicator.kt index abdc86b3f85..7835542d42f 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/completeregistration/PasswordStrengthIndicator.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/completeregistration/PasswordStrengthIndicator.kt @@ -42,14 +42,20 @@ fun PasswordStrengthIndicator( currentCharacterCount: Int, minimumCharacterCount: Int? = null, ) { + val minimumRequirementMet = (minimumCharacterCount == null) || + (currentCharacterCount >= minimumCharacterCount) val widthPercent by animateFloatAsState( - targetValue = when (state) { - PasswordStrengthState.NONE -> 0f - PasswordStrengthState.WEAK_1 -> .25f - PasswordStrengthState.WEAK_2 -> .5f - PasswordStrengthState.WEAK_3 -> .66f - PasswordStrengthState.GOOD -> .82f - PasswordStrengthState.STRONG -> 1f + targetValue = if (minimumRequirementMet) { + when (state) { + PasswordStrengthState.NONE -> 0f + PasswordStrengthState.WEAK_1 -> .25f + PasswordStrengthState.WEAK_2 -> .5f + PasswordStrengthState.WEAK_3 -> .66f + PasswordStrengthState.GOOD -> .82f + PasswordStrengthState.STRONG -> 1f + } + } else { + 0f }, label = "Width Percent State", ) @@ -107,11 +113,13 @@ fun PasswordStrengthIndicator( minimumCharacterCount = minCount, ) } - Text( - text = label(), - style = BitwardenTheme.typography.labelSmall, - color = indicatorColor, - ) + if (minimumRequirementMet) { + Text( + text = label(), + style = BitwardenTheme.typography.labelSmall, + color = indicatorColor, + ) + } } } } @@ -122,14 +130,6 @@ private fun MinimumCharacterCount( minimumRequirementMet: Boolean, minimumCharacterCount: Int, ) { - val characterCountColor by animateColorAsState( - targetValue = if (minimumRequirementMet) { - BitwardenTheme.colorScheme.status.strong - } else { - BitwardenTheme.colorScheme.text.secondary - }, - label = "minmumCharacterCountColor", - ) Row( modifier = modifier, verticalAlignment = Alignment.CenterVertically, @@ -145,14 +145,14 @@ private fun MinimumCharacterCount( Icon( painter = rememberVectorPainter(id = it), contentDescription = null, - tint = characterCountColor, + tint = BitwardenTheme.colorScheme.text.secondary, modifier = Modifier.size(12.dp), ) } Spacer(modifier = Modifier.width(2.dp)) Text( text = stringResource(R.string.minimum_characters, minimumCharacterCount), - color = characterCountColor, + color = BitwardenTheme.colorScheme.text.secondary, style = BitwardenTheme.typography.labelSmall, ) }