Implemented completely new UI for the login scene
This commit is contained in:
@ -8,6 +8,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
|
||||
@ -46,19 +47,27 @@ public final class LoginScene {
|
||||
private PasswordField repeatPasswordField;
|
||||
|
||||
@FXML
|
||||
private Label repeatPasswordLabel;
|
||||
|
||||
@FXML
|
||||
private CheckBox registerCheckBox;
|
||||
private Button registerSwitch;
|
||||
|
||||
@FXML
|
||||
private Label connectionLabel;
|
||||
|
||||
@FXML
|
||||
private Button loginButton;
|
||||
|
||||
@FXML
|
||||
private Button offlineModeButton;
|
||||
|
||||
@FXML
|
||||
private Label registerTextLabel;
|
||||
|
||||
private Client client;
|
||||
private LocalDB localDB;
|
||||
private CacheMap cacheMap;
|
||||
private SceneContext sceneContext;
|
||||
|
||||
private boolean registration = false;
|
||||
|
||||
private static final Logger logger = EnvoyLog.getLogger(LoginScene.class);
|
||||
private static final EventBus eventBus = EventBus.getInstance();
|
||||
private static final ClientConfig config = ClientConfig.getInstance();
|
||||
@ -100,13 +109,13 @@ public final class LoginScene {
|
||||
private void loginButtonPressed() {
|
||||
|
||||
// Prevent registration with unequal passwords
|
||||
if (registerCheckBox.isSelected() && !passwordField.getText().equals(repeatPasswordField.getText())) {
|
||||
if (registration && !passwordField.getText().equals(repeatPasswordField.getText())) {
|
||||
new Alert(AlertType.ERROR, "The entered password is unequal to the repeated one").showAndWait();
|
||||
repeatPasswordField.clear();
|
||||
} else if (!Bounds.isValidContactName(userTextField.getText())) {
|
||||
new Alert(AlertType.ERROR, "The entered user name is not valid (" + Bounds.CONTACT_NAME_PATTERN + ")").showAndWait();
|
||||
userTextField.clear();
|
||||
} else performHandshake(new LoginCredentials(userTextField.getText(), passwordField.getText(), registerCheckBox.isSelected(),
|
||||
} else performHandshake(new LoginCredentials(userTextField.getText(), passwordField.getText(), registration,
|
||||
Startup.VERSION));
|
||||
}
|
||||
|
||||
@ -116,11 +125,24 @@ public final class LoginScene {
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void registerCheckboxChanged() {
|
||||
private void registerSwitchPressed() {
|
||||
registration = !registration;
|
||||
|
||||
// Make repeat password field and label visible / invisible
|
||||
repeatPasswordField.setVisible(registerCheckBox.isSelected());
|
||||
repeatPasswordLabel.setVisible(registerCheckBox.isSelected());
|
||||
repeatPasswordField.setVisible(registration);
|
||||
if (loginButton.getText().equals("Login")) {
|
||||
loginButton.setText("Register");
|
||||
loginButton.setPadding(new Insets(2, 116, 2, 116));
|
||||
registerTextLabel.setText("Already an account?");
|
||||
registerSwitch.setText("Login");
|
||||
offlineModeButton.setDisable(true);
|
||||
} else {
|
||||
loginButton.setText("Login");
|
||||
loginButton.setPadding(new Insets(2, 125, 2, 125));
|
||||
registerTextLabel.setText("No account yet?");
|
||||
registerSwitch.setText("Register");
|
||||
offlineModeButton.setDisable(false);
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
Reference in New Issue
Block a user