Skip to content

Commit

Permalink
feat: made SignInPageView and removed HeaderController from SignIn an…
Browse files Browse the repository at this point in the history
…d Login
  • Loading branch information
MatheaGjerde committed Mar 11, 2026
1 parent de7e295 commit 37c7db7
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,12 @@ public class SignInPageController {
public SignInPageController(MainController controller) {
this.controller = controller;
}

public void handleSignInBtn() {
System.out.println("Sign in button pressed");
controller.showHomePage();
}
public void handleLoginBtn() {
System.out.println("Back to login button pressed");
controller.showLoginPage();
}
}
6 changes: 3 additions & 3 deletions src/main/java/edu/group5/app/view/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public MainView(MainController mainController) {
}

public Scene createView() {
root.setCenter(new LoginPageView(loginPageController, headerController));
root.setCenter(new LoginPageView(loginPageController));
return new Scene(root, 1280, 720);
}

Expand All @@ -32,10 +32,10 @@ public void showHomePage() {
}

public void showLoginPage() {
root.setCenter(new LoginPageView(loginPageController, headerController));
root.setCenter(new LoginPageView(loginPageController));
}
public void showSignInPage() {
root.setCenter(new SignInPageView(signInPageController, headerController));
root.setCenter(new SignInPageView(signInPageController));
}
public void showBrowsePage() {}

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/edu/group5/app/view/loginpage/LoginHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
import javafx.scene.layout.StackPane;

public class LoginHeader extends BorderPane {
private final HeaderController controller;

public LoginHeader(HeaderController controller) {
this.controller = controller;
public LoginHeader() {
getStylesheets().add(getClass().getResource("/header/header.css").toExternalForm());
setId("header");

Expand All @@ -21,7 +19,6 @@ private StackPane getLogoSection() {
StackPane logoSection = new StackPane();
logoSection.setId("logo-section");
logoSection.setAlignment(Pos.CENTER);
logoSection.setOnMouseClicked(e -> controller.handleHomeBtn());
logoSection.setStyle("-fx-cursor: hand;");

ImageView logo = new ImageView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
public class LoginPageView extends BorderPane {
private final LoginPageController controller;

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

HBox content = new HBox();
Expand Down
96 changes: 93 additions & 3 deletions src/main/java/edu/group5/app/view/loginpage/SignInPageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,106 @@

import edu.group5.app.control.HeaderController;
import edu.group5.app.control.SignInPageController;
import javafx.scene.layout.BorderPane;
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 SignInPageView extends BorderPane {
private final SignInPageController controller;

public SignInPageView(SignInPageController signInPageController, HeaderController headerController) {
public SignInPageView(SignInPageController signInPageController) {
this.controller = signInPageController;
setTop(new LoginHeader(headerController));
setTop(new LoginHeader());

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

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

String css = Objects.requireNonNull(
getClass().getResource("/loginpage/signin.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(getSignInBox(), getBackToLoginBtn());
return outerSection;
}
private VBox getSignInBox() {
VBox signInSection = new VBox(12);
signInSection.setAlignment(Pos.CENTER);
signInSection.setId("login-box");
signInSection.getChildren().addAll(getNameRow(), getEmailBox(), getPasswordBox(), getSignInBtn());
return signInSection;
}
private HBox getNameRow() {
HBox nameRow = new HBox(12);
nameRow.setMaxWidth(300);

VBox nameBox = new VBox();
TextField nameField = new TextField();
nameField.setPromptText("Jinwoo");
HBox.setHgrow(nameBox, Priority.ALWAYS);
nameBox.getChildren().addAll(new Label("First name"), nameField);

VBox surnameBox = new VBox();
TextField surnameField = new TextField();
surnameField.setPromptText("Son");
HBox.setHgrow(surnameBox, Priority.ALWAYS);
surnameBox.getChildren().addAll(new Label("Last Name"), surnameField);

nameRow.getChildren().addAll(nameBox, surnameBox);
return nameRow;

}
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 getSignInBtn() {
Button signInBtn = new Button("Sign In");
signInBtn.setMaxWidth(300);
signInBtn.setId("login-btn");
signInBtn.setOnMouseClicked(e -> controller.handleSignInBtn());
return signInBtn;
}
public Button getBackToLoginBtn() {
Button backBtn = new Button("Already have an account? Log in");
backBtn.setMaxWidth(300);
backBtn.setOnMouseClicked(e -> controller.handleLoginBtn());
backBtn.setId("register-btn");
return backBtn;
}
private StackPane getImageSection() {
StackPane imageSection = new StackPane();
imageSection.setId("image-section");
HBox.setHgrow(imageSection, Priority.ALWAYS);
return imageSection;
}

}
Binary file added src/main/resources/loginpage/signin-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/main/resources/loginpage/signin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#image-section {
-fx-background-image: url("/loginpage/signin-image.png");
-fx-background-size: auto;
-fx-background-position: right 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 37c7db7

Please sign in to comment.