fixed icon views of labels in new password screen that could only appear once

This commit is contained in:
Tobias Hagemann
2020-08-21 10:13:45 +02:00
parent 58ce1e45b8
commit 4723416d45
2 changed files with 14 additions and 10 deletions

View File

@@ -24,10 +24,12 @@ public class NewPasswordController implements FxController {
public NiceSecurePasswordField passwordField;
public NiceSecurePasswordField reenterField;
public Label passwordStrengthLabel;
public FontAwesome5IconView passwordStrengthCheckmark;
public FontAwesome5IconView passwordStrengthWarning;
public FontAwesome5IconView passwordStrengthCross;
public Label passwordMatchLabel;
public FontAwesome5IconView checkmark;
public FontAwesome5IconView warning;
public FontAwesome5IconView cross;
public FontAwesome5IconView passwordMatchCheckmark;
public FontAwesome5IconView passwordMatchCross;
public NewPasswordController(ResourceBundle resourceBundle, PasswordStrengthUtil strengthRater, ObjectProperty<CharSequence> password) {
this.resourceBundle = resourceBundle;
@@ -45,7 +47,7 @@ public class NewPasswordController implements FxController {
BooleanBinding passwordsMatch = Bindings.createBooleanBinding(this::hasSamePasswordInBothFields, passwordField.textProperty(), reenterField.textProperty());
BooleanBinding reenterFieldNotEmpty = reenterField.textProperty().isNotEmpty();
passwordMatchLabel.visibleProperty().bind(reenterFieldNotEmpty);
passwordMatchLabel.graphicProperty().bind(Bindings.when(passwordsMatch.and(reenterFieldNotEmpty)).then(checkmark).otherwise(cross));
passwordMatchLabel.graphicProperty().bind(Bindings.when(passwordsMatch.and(reenterFieldNotEmpty)).then(passwordMatchCheckmark).otherwise(passwordMatchCross));
passwordMatchLabel.textProperty().bind(Bindings.when(passwordsMatch.and(reenterFieldNotEmpty)).then(resourceBundle.getString("newPassword.passwordsMatch")).otherwise(resourceBundle.getString("newPassword.passwordsDoNotMatch")));
passwordField.textProperty().addListener(this::passwordsDidChange);
@@ -56,11 +58,11 @@ public class NewPasswordController implements FxController {
if (passwordField.getCharacters().length() == 0) {
return null;
} else if (passwordStrength.intValue() <= -1) {
return cross;
return passwordStrengthCross;
} else if (passwordStrength.intValue() < 3) {
return warning;
return passwordStrengthWarning;
} else {
return checkmark;
return passwordStrengthCheckmark;
}
}

View File

@@ -12,9 +12,11 @@
spacing="6"
alignment="CENTER_LEFT">
<fx:define>
<FontAwesome5IconView fx:id="checkmark" styleClass="glyph-icon-primary" glyph="CHECK"/>
<FontAwesome5IconView fx:id="warning" styleClass="glyph-icon-orange" glyph="EXCLAMATION_TRIANGLE"/>
<FontAwesome5IconView fx:id="cross" styleClass="glyph-icon-red" glyph="TIMES"/>
<FontAwesome5IconView fx:id="passwordStrengthCheckmark" styleClass="glyph-icon-primary" glyph="CHECK"/>
<FontAwesome5IconView fx:id="passwordStrengthWarning" styleClass="glyph-icon-orange" glyph="EXCLAMATION_TRIANGLE"/>
<FontAwesome5IconView fx:id="passwordStrengthCross" styleClass="glyph-icon-red" glyph="TIMES"/>
<FontAwesome5IconView fx:id="passwordMatchCheckmark" styleClass="glyph-icon-primary" glyph="CHECK"/>
<FontAwesome5IconView fx:id="passwordMatchCross" styleClass="glyph-icon-red" glyph="TIMES"/>
</fx:define>
<children>
<Label text="%newPassword.promptText" labelFor="$passwordField"/>