Skip to content

Commit

Permalink
Feat: Attempt to implement components to other pages
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Apr 16, 2026
1 parent 88f32a7 commit 4b1cb07
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 231 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
package ntnu.systemutvikling.team6.controller;

import com.google.errorprone.annotations.FormatMethod;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import ntnu.systemutvikling.team6.controller.components.BaseController;
import ntnu.systemutvikling.team6.controller.components.FooterController;
import ntnu.systemutvikling.team6.controller.components.LoaderScene;
import ntnu.systemutvikling.team6.controller.components.NavbarController;
import ntnu.systemutvikling.team6.models.Charity;

/**
* This controller represents the charity page, where the user can read about the charity and choose
* to donate to it. It also has a button to return to the front page.
*/
public class CharityPageController {
public class CharityPageController extends BaseController {
@FXML private TextField charitySearchField;

@FXML private Label CharityDescription;

@FXML private Label CharityName;

@FXML private NavbarController navbarController;
@FXML private FooterController footerController;

@FXML
public void initialize() {}

@Override
protected void authTokenisSet(){
navbarController.setAuthToken(authToken);
footerController.setAuthToken(authToken);
}


private Charity charity;

/**
Expand Down Expand Up @@ -50,22 +64,7 @@ public void setCharity(Charity charity) {
@FXML
public void switchToDonationPage(ActionEvent event) {
System.out.println("Click");
LoaderScene.LoadScene("donationPage", event, charity, null);
LoaderScene.LoadScene("donationPage", event, charity, null, authToken);
}

/**
* This method is used to search for charities based on the input in the search field.
*
* @param event is the event that triggered the search.
*/
@FXML
public void handleSearch(ActionEvent event) {
String query = charitySearchField.getText().trim();

if (query.isEmpty()) {
return;
}

LoaderScene.LoadScene("availableOrganization", event, null, query);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class FrontpageController extends BaseController{
@FXML private CheckBox childrenFilter;
@FXML private CheckBox healthFilter;
@FXML private CheckBox emergencyAidFilter;

@FXML private NavbarController navbarController;
@FXML private FooterController footerController;

Expand All @@ -52,6 +53,7 @@ public class FrontpageController extends BaseController{
@Override
protected void authTokenisSet(){
navbarController.setAuthToken(authToken);
footerController.setAuthToken(authToken);
}

/**
Expand Down Expand Up @@ -106,7 +108,7 @@ public void initialize() {
* @param event
*/
public void switchToCharityPage(ActionEvent event) {
LoaderScene.LoadScene("CharityPage", event, featuredCharity, null);
LoaderScene.LoadScene("CharityPage", event, featuredCharity, null, authToken);
}

/**
Expand All @@ -115,7 +117,7 @@ public void switchToCharityPage(ActionEvent event) {
* @param event
*/
public void switchToDonationPage(ActionEvent event) {
LoaderScene.LoadScene("DonationPage", event, featuredCharity, null);
LoaderScene.LoadScene("DonationPage", event, featuredCharity, null, authToken);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@
* looped upon in FronpageController. It is used to display the name and description of a charity,
* and to switch to the charity page or donation page when the user clicks on the card.
*/
public class OrganizationCardController {
public class OrganizationCardController extends BaseController{

@FXML private Label organizationName;

@FXML private Label organizationDescription;

private Charity charity;

@Override
protected void authTokenisSet() {

}

public void setOrganization(Charity charity) {
this.charity = charity;

Expand All @@ -27,10 +32,12 @@ public void setOrganization(Charity charity) {

/* EVENTS */
public void switchToCharityPage(ActionEvent event) {
LoaderScene.LoadScene("CharityPage", event, charity, null);
LoaderScene.LoadScene("CharityPage", event, charity, null, authToken);
}

public void switchToDonationPage(ActionEvent event) {
LoaderScene.LoadScene("DonationPage", event, charity, null);
LoaderScene.LoadScene("DonationPage", event, charity, null, authToken);
}


}
183 changes: 4 additions & 179 deletions helpmehelpapplication/src/main/resources/fxml/charityPage.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
<?import javafx.scene.control.Hyperlink?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
Expand All @@ -36,77 +34,9 @@
</rowConstraints>

<!-- NAVBAR -->
<GridPane prefHeight="92.0" prefWidth="1200.0" style="-fx-background-color: #5F9895;" GridPane.columnIndex="0" GridPane.rowIndex="0">
<!-- This pulls in the navbar with its own controller -->
<fx:include fx:id="navbar" source="components/navbar.fxml" />

<padding>
<Insets bottom="10.0" left="20.0" right="20.0" top="10.0" />
</padding>

<columnConstraints>
<ColumnConstraints percentWidth="8.0" />
<ColumnConstraints percentWidth="24.0" />
<ColumnConstraints percentWidth="43.0" />
<ColumnConstraints percentWidth="25.0" />
</columnConstraints>

<rowConstraints>
<RowConstraints prefHeight="72.0" />
</rowConstraints>

<children>
<Button mnemonicParsing="false" onAction="#switchToFrontPage" prefHeight="0.0" prefWidth="0.0" style="-fx-background-color: #2f8f8b">
<graphic>
<ImageView fitHeight="54.0" fitWidth="67.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/Logo.png" />
</image>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</ImageView>
</graphic>
</Button>

<HBox alignment="CENTER_LEFT" spacing="0.0" GridPane.columnIndex="1" GridPane.rowIndex="0">
<children>
<Label text="Help" textFill="WHITE">
<font>
<Font name="System Bold" size="28.0" />
</font>
</Label>

<Label text="Me" textFill="#C8E6C9">
<font>
<Font name="System Bold" size="28.0" />
</font>
</Label>

<Label text="Help" textFill="WHITE">
<font>
<Font name="System Bold" size="28.0" />
</font>
</Label>
</children>
</HBox>

<HBox alignment="CENTER" GridPane.columnIndex="2" GridPane.rowIndex="0">
<children>
<TextField fx:id="charitySearchField" maxWidth="430.0" onAction="#handleSearch" prefHeight="48.0" prefWidth="430.0" promptText="Search" style="-fx-background-radius: 24; -fx-border-radius: 24; -fx-font-size: 16px; -fx-padding: 0 0 0 16;" />
</children>
</HBox>

<HBox alignment="CENTER_RIGHT" GridPane.columnIndex="3" GridPane.rowIndex="0">
<children>
<Button prefHeight="48.0" prefWidth="180.0" style="-fx-background-color: #4453D9; -fx-background-radius: 24; -fx-text-fill: white; -fx-font-size: 16px; -fx-font-weight: bold;" text="Login">
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
</children>
</HBox>

</children>
</GridPane>
<ScrollPane GridPane.rowIndex="1">
<content>

Expand Down Expand Up @@ -408,112 +338,7 @@
</ScrollPane>

<!-- FOOTER -->
<HBox alignment="BOTTOM_CENTER" prefHeight="180.0" prefWidth="1200.0" style="-fx-background-color: #5F9895;" GridPane.columnIndex="0" GridPane.rowIndex="2">

<children>
<GridPane prefHeight="180.0" prefWidth="1200.0" HBox.hgrow="ALWAYS">

<columnConstraints>
<ColumnConstraints percentWidth="60.0" />
<ColumnConstraints percentWidth="40.0" />
</columnConstraints>

<rowConstraints>
<RowConstraints prefHeight="180.0" />
</rowConstraints>

<children>

<!-- LEFT FOOTER SIDE -->
<StackPane prefHeight="180.0" prefWidth="720.0" GridPane.columnIndex="0" GridPane.rowIndex="0">

<children>

<HBox alignment="CENTER_LEFT" spacing="0.0" translateX="60.0">
<children>
<Label text="Help" textFill="WHITE">
<font>
<Font name="System Bold" size="36.0" />
</font>
</Label>

<Label text="Me" textFill="#C8E6C9">
<font>
<Font name="System Bold" size="36.0" />
</font>
</Label>

<Label text="Help" textFill="WHITE">
<font>
<Font name="System Bold" size="36.0" />
</font>
</Label>
</children>
</HBox>

<Rectangle fill="WHITE" height="90.0" translateX="-20.0" width="2.0" />

<VBox alignment="CENTER" spacing="5.0" translateX="120.0">
<children>
<Label text="About us" textFill="WHITE">
<font>
<Font name="System Bold" size="18.0" />
</font>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Label>

<Label text="Something else" textFill="WHITE">
<font>
<Font name="System Bold" size="18.0" />
</font>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Label>

<Label text="Third Link" textFill="WHITE">
<font>
<Font name="System Bold" size="18.0" />
</font>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Label>
</children>
</VBox>

</children>
</StackPane>

<!-- RIGHT FOOTER SIDE -->
<StackPane alignment="CENTER" prefHeight="180.0" prefWidth="480.0" GridPane.columnIndex="1" GridPane.rowIndex="0">

<children>

<VBox alignment="CENTER" spacing="10.0">
<children>
<ImageView fitHeight="80.0" fitWidth="150.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/img.png" />
</image>
</ImageView>

<Label maxWidth="250.0" text="All data is consistently updated and reverified" textAlignment="CENTER" textFill="WHITE" wrapText="true">
<font>
<Font name="System Bold" size="17.0" />
</font>
</Label>
</children>
</VBox>

</children>
</StackPane>

</children>
</GridPane>
</children>
</HBox>
<!-- This pulls in the navbar with its own controller -->
<fx:include fx:id="footer" source="components/footer.fxml" />

</GridPane>
Loading

0 comments on commit 4b1cb07

Please sign in to comment.