Skip to content

Commit

Permalink
feat: add email, password fields and register navigation to LoginPage…
Browse files Browse the repository at this point in the history
…View
  • Loading branch information
MatheaGjerde committed Mar 11, 2026
1 parent 83063c9 commit c1ce598
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 12 deletions.
13 changes: 13 additions & 0 deletions src/main/java/edu/group5/app/control/LoginPageController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package edu.group5.app.control;

public class LoginPageController {
private final MainController controller;

public LoginPageController(MainController controller) {
this.controller = controller;
}
public void handleRegisterBtn() {
System.out.println("Sign in button pressed");
controller.showSignInPage();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package edu.group5.app.control;

public class SignInPageController {
}
74 changes: 62 additions & 12 deletions src/main/java/edu/group5/app/view/loginpage/LoginPageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,87 @@


import edu.group5.app.control.HeaderController;
import edu.group5.app.view.Header;
import edu.group5.app.control.LoginPageController;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.*;

import java.util.Objects;

public class LoginPageView extends BorderPane {
private final LoginPageController controller;

public LoginPageView(HeaderController headerController) {
public LoginPageView(LoginPageController loginPageController, HeaderController headerController) {
this.controller = loginPageController;
LoginHeader loginHeaderView = new LoginHeader(headerController);
setTop(loginHeaderView);

HBox content = new HBox();
content.setFillHeight(true);
HBox.setHgrow(content, Priority.ALWAYS);

VBox loginSection = new VBox();
loginSection.setAlignment(Pos.CENTER);
HBox.setHgrow(loginSection, Priority.ALWAYS);

StackPane imageSection = new StackPane();
imageSection.setId("image-section");
HBox.setHgrow(imageSection, Priority.ALWAYS);


content.getChildren().addAll(loginSection, imageSection);
content.getChildren().addAll(getOuterSection(), getImageSection());

String css = Objects.requireNonNull(
getClass().getResource("/loginpage/login.css")).toExternalForm();
content.getStylesheets().add(css);

setCenter(content);
}
private VBox getOuterSection() {
VBox outerSection = new VBox(12);
outerSection.setAlignment(Pos.CENTER);
HBox.setHgrow(outerSection, Priority.ALWAYS);
outerSection.getChildren().addAll(getLoginBox(), getRegisterBtn());
return outerSection;
}
private VBox getLoginBox() {
VBox loginSection = new VBox(12);
loginSection.setAlignment(Pos.CENTER);
loginSection.setId("login-box");
loginSection.getChildren().addAll(getEmailBox(), getPasswordBox(), getLoginBtn());
return loginSection;
}
private VBox getEmailBox() {
VBox emailBox = new VBox();
emailBox.setMaxWidth(300);
TextField emailField = new TextField();
emailField.setPromptText("aurafarmer@gmail.com");
emailField.setMaxWidth(300);
emailBox.getChildren().addAll(new Label("Email"), emailField);
return emailBox;
}
private VBox getPasswordBox() {
VBox passwordBox = new VBox();
passwordBox.setMaxWidth(300);
PasswordField passwordField = new PasswordField();
passwordField.setMaxWidth(300);
passwordBox.getChildren().addAll(new Label("Password"), passwordField);
return passwordBox;
}
private Button getLoginBtn() {
Button loginBtn = new Button("Log In");
loginBtn.setMaxWidth(300);
loginBtn.setId("login-btn");
return loginBtn;
}
public Button getRegisterBtn() {
Button registerBtn = new Button("Don't have an account? Sign In");
registerBtn.setMaxWidth(300);
registerBtn.setOnMouseClicked(e -> controller.handleRegisterBtn());
registerBtn.setId("register-btn");
return registerBtn;
}
private StackPane getImageSection() {
StackPane imageSection = new StackPane();
imageSection.setId("image-section");
HBox.setHgrow(imageSection, Priority.ALWAYS);
return imageSection;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package edu.group5.app.view.loginpage;

public class SignInView {
}
18 changes: 18 additions & 0 deletions src/main/resources/loginpage/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,22 @@
-fx-background-position: left center;
-fx-background-repeat: no-repeat;
-fx-pref-width: 50%;
}
#login-btn {
-fx-background-color: #000000;
-fx-text-fill: white;
-fx-pref-height: 35px;
}

#register-btn {
-fx-background-color: #000000;
-fx-text-fill: white;
-fx-pref-height: 35px;
}
#login-box {
-fx-border-color: #ccc;
-fx-border-radius: 8px;
-fx-border-width: 1px;
-fx-padding: 24px;
-fx-max-width: 340px;
}

0 comments on commit c1ce598

Please sign in to comment.