Skip to content

Commit

Permalink
feat: merged feat/loginpage into feat/homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
MatheaGjerde committed Mar 10, 2026
2 parents 16ce552 + f2c74cc commit 7802896
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/main/java/edu/group5/app/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import edu.group5.app.view.MainView;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import tools.jackson.core.type.TypeReference;
import tools.jackson.databind.ObjectMapper;
Expand All @@ -24,6 +25,7 @@ public void start(Stage stage) {
controller.setMainView(view);
Scene scene = view.createView();

stage.getIcons().add(new Image(getClass().getResource("/header/images/hmh-logo.png").toExternalForm()));
stage.setTitle("Help-Me-Help");
stage.setScene(scene);
stage.show();
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/edu/group5/app/control/HomePageController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package edu.group5.app.control;

public class HomePageController {
private final MainController controller;

public HomePageController(MainController controller) {
this.controller = controller;
}

public void handleDonateToACauseBtn() {
System.out.println("Donate to a cause button pressed");
controller.showBrowsePage();
}

public void handleAboutUsBtn() {
System.out.println("About us button pressed");
controller.showAboutUsPage();
}
}
6 changes: 6 additions & 0 deletions src/main/java/edu/group5/app/control/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ public void showHomePage() {
public void showLoginPage() {
view.showLoginPage();
}

public void showBrowsePage() {
view.showBrowsePage();
}

public void showAboutUsPage() {}
}
8 changes: 4 additions & 4 deletions src/main/java/edu/group5/app/view/Header.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Header extends BorderPane {

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

setLeft(getLogoSection());
Expand All @@ -24,11 +24,11 @@ private StackPane getLogoSection() {
StackPane logoSection = new StackPane();
logoSection.setId("logo-section");
logoSection.setAlignment(Pos.CENTER);
logoSection.setOnMouseClicked(e -> System.out.println("logoSection"));
logoSection.setOnMouseClicked(e -> controller.handleHomeBtn());
logoSection.setStyle("-fx-cursor: hand;");

ImageView logo = new ImageView(
new Image(getClass().getResource("/homepage/hmh-logo.png").toExternalForm())
new Image(getClass().getResource("/header/images/hmh-logo.png").toExternalForm())
);
logo.setFitHeight(60);
logo.setPreserveRatio(true);
Expand Down Expand Up @@ -67,7 +67,7 @@ private StackPane getProfileSection() {
profileSection.setStyle("-fx-cursor: hand;");

ImageView avatar = new ImageView(
new Image(getClass().getResource("/homepage/avatar.png").toExternalForm())
new Image(getClass().getResource("/header/images/avatar.png").toExternalForm())
);
avatar.setFitHeight(60);
avatar.setPreserveRatio(true);
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/edu/group5/app/view/MainView.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package edu.group5.app.view;

import edu.group5.app.control.HeaderController;
import edu.group5.app.control.HomePageController;
import edu.group5.app.control.MainController;
import edu.group5.app.view.homepage.HomePageView;
import edu.group5.app.view.loginpage.LoginPageView;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;

public class MainView {
private final MainController mainController;
private final HeaderController headerController;
private final HomePageController homePageController;
private final BorderPane root;

public MainView(MainController mainController) {
this.mainController = mainController;
this.headerController = new HeaderController(mainController);
this.homePageController = new HomePageController(mainController);
this.root = new BorderPane();
}

Expand All @@ -24,10 +25,14 @@ public Scene createView() {
}

public void showHomePage() {
root.setCenter(new HomePageView(headerController));
root.setCenter(new HomePageView(homePageController, headerController));
}

public void showLoginPage() {

}

public void showBrowsePage() {}

public void showAboutUsPage() {}
}
58 changes: 57 additions & 1 deletion src/main/java/edu/group5/app/view/homepage/HomePageView.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,68 @@
package edu.group5.app.view.homepage;

import edu.group5.app.control.HeaderController;
import edu.group5.app.control.HomePageController;
import edu.group5.app.view.Header;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;

public class HomePageView extends BorderPane {
public HomePageView(HeaderController headerController) {
private final HomePageController controller;

public HomePageView(HomePageController homePageController, HeaderController headerController) {
this.controller = homePageController;
getStylesheets().add(getClass().getResource("/homepage/homepage.css").toExternalForm());
Header headerView = new Header(headerController);
setTop(headerView);
setCenter(createBody());
}

private ScrollPane createBody() {
ScrollPane body = new ScrollPane();
body.setFitToWidth(true);
VBox vBox = new VBox();
vBox.getChildren().addAll(
createIntroductionSection(),
createCharityImageSection(),
createCharityImageSection()
);
body.setContent(vBox);
return body;
}

private VBox createIntroductionSection() {
VBox introductionSection = new VBox();
introductionSection.setId("introduction-section");
introductionSection.setAlignment(Pos.CENTER);
introductionSection.setSpacing(10);

Text h1 = new Text("MAKE A DIFFERENCE TODAY");
h1.setId("h1");
Text h2 = new Text("SUPPORT THOSE IN NEED AROUND THE WORLD");
h2.setId("h2");

Button donateToACauseBtn = new Button("Donate to a cause");
donateToACauseBtn.setOnAction(e -> controller.handleDonateToACauseBtn());

Button aboutUsBtn = new Button("About us");
aboutUsBtn.setOnAction(e -> controller.handleAboutUsBtn());

introductionSection.getChildren().addAll(h1, h2, donateToACauseBtn, aboutUsBtn);
return introductionSection;
}

private StackPane createCharityImageSection() {
StackPane charityImageSection = new StackPane();
charityImageSection.setId("charity-image-section");
charityImageSection.setPrefHeight(300);
StackPane image = new StackPane();
image.setId("charity-image");
charityImageSection.getChildren().add(image);
return charityImageSection;
}
}
File renamed without changes.
File renamed without changes
File renamed without changes
27 changes: 27 additions & 0 deletions src/main/resources/homepage/homepage.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#introduction-section {
-fx-border-color: black;
-fx-border-width: 2px;
-fx-padding: 20px 0;
}

#h1 {
-fx-text-fill: black;
-fx-font-size: 50pt;
-fx-font-weight: bold;
}

#h2 {
-fx-fill: #757575;
-fx-font-size: 25pt;
}

#charity-image-section {
-fx-border-color: black;
}

#charity-image {
-fx-background-image: url("/homepage/images/charityimage.jpg");
-fx-background-position: center 55%;
-fx-background-size: 100% auto;
-fx-background-repeat: no-repeat;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7802896

Please sign in to comment.