Skip to content

Commit

Permalink
feat: made UserPageView and added connection to controllers and testd…
Browse files Browse the repository at this point in the history
…ata in MainView
  • Loading branch information
MatheaGjerde committed Mar 15, 2026
1 parent e6a2d09 commit 06c135b
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/edu/group5/app/control/HeaderController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ public void handleCausesBtn() {
public void handleAboutBtn() {
System.out.println("About button pressed");
}

public void handleProfileBtn() {
System.out.println("profileSection");
controller.showUserPage();
}
}
4 changes: 4 additions & 0 deletions src/main/java/edu/group5/app/control/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public void showBrowsePage() {
}

public void showAboutUsPage() {}

public void showUserPage() {
view.showUserPage();
}
}
2 changes: 1 addition & 1 deletion src/main/java/edu/group5/app/view/Header.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private StackPane getProfileSection() {
StackPane profileSection = new StackPane();
profileSection.setId("profile-section");
profileSection.setAlignment(Pos.CENTER);
profileSection.setOnMouseClicked(e -> System.out.println("profileSection"));
profileSection.setOnMouseClicked(e -> controller.handleProfileBtn());
profileSection.setStyle("-fx-cursor: hand;");

ImageView avatar = new ImageView(
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/edu/group5/app/view/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import edu.group5.app.control.*;
import edu.group5.app.control.donationpage.DonationPageController;
import edu.group5.app.control.donationpage.PaymentCompleteController;
import edu.group5.app.model.user.Customer;
import edu.group5.app.view.donationpage.DonationPageView;
import edu.group5.app.view.donationpage.PaymentCompletePageView;
import edu.group5.app.view.homepage.HomePageView;
import edu.group5.app.view.loginpage.LoginPageView;
import edu.group5.app.view.loginpage.SignInPageView;
import edu.group5.app.view.userpage.UserPageView;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;

Expand Down Expand Up @@ -52,4 +54,15 @@ public void showPaymentCompletePage() {
}

public void showAboutUsPage() {}

public void showUserPage() {
Customer testCustomer = new Customer(
1,
"Jinwoo",
"Son",
"aurafarmer@gmail.com",
"hashedpassword"
);
root.setCenter(new UserPageView(headerController, testCustomer));
}
}
75 changes: 75 additions & 0 deletions src/main/java/edu/group5/app/view/userpage/UserPageView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package edu.group5.app.view.userpage;

import edu.group5.app.control.HeaderController;
import edu.group5.app.model.user.Customer;
import edu.group5.app.view.Header;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;


public class UserPageView extends BorderPane {
private final Customer customer;

public UserPageView(HeaderController headerController, Customer customer) {
this.customer = customer;
getStylesheets().add(getClass().getResource("/userpage/userpage.css").toExternalForm());

Header headerView = new Header(headerController);
setTop(headerView);

VBox content = new VBox(30);
content.setPadding(new Insets(40));
content.getChildren().addAll(createProfileSection(), createCausesSection(), createDonationsSection());
setCenter(content);
}
private HBox createProfileSection() {
ImageView avatar = new ImageView(new Image(getClass().getResourceAsStream("/userpage/account_circle.png")));
avatar.setFitWidth(150);
avatar.setFitHeight(150);
avatar.setPreserveRatio(true);
avatar.setId("avatar");

Text name = new Text(customer.getFirstName() + " " + customer.getLastName());
name.setId("profile-name");

Label email = new Label(customer.getEmail());
email.getStyleClass().add("profile-info");

Label location = new Label("Trondheim, Norway");
location.getStyleClass().add("profile-info");

VBox info = new VBox(10, name, email, location);
info.setAlignment(Pos.CENTER_LEFT);

HBox profile = new HBox(40, avatar, info);
profile.setAlignment(Pos.CENTER_LEFT);
return profile;
}
private VBox createCausesSection() {
Text title = new Text("YOUR SUPPORTED CAUSES");
title.getStyleClass().add("section-title");

Pane causesPlaceholder = new Pane();
causesPlaceholder.getStyleClass().add("section-box");

return new VBox(10, title, causesPlaceholder);
}
private VBox createDonationsSection() {
Text title = new Text("PREVIOUS DONATIONS");
title.getStyleClass().add("section-title");

Pane donationsPlaceholder = new Pane();
donationsPlaceholder.getStyleClass().add("section-box");

return new VBox(10, title, donationsPlaceholder);
}

}
Binary file added src/main/resources/userpage/account_circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/main/resources/userpage/userpage.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#profile-name {
-fx-font-size: 28px;
-fx-font-weight: bold;
}
.profile-info {
-fx-font-size: 16px;
-fx-text-fill: #444;
}
.section-title {
-fx-font-size: 14px;
-fx-font-weight: bold;
-fx-fill: #888;
}
.section-box {
-fx-background-color: #ddd;
-fx-pref-height: 120px;
-fx-pref-width: 700px;
-fx-background-radius: 6;
}

0 comments on commit 06c135b

Please sign in to comment.