Skip to content

Commit

Permalink
feat: modified controllers and fxml with buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
cathrkri committed Mar 27, 2026
1 parent 81a8e61 commit b3fdd47
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void initialize() {
CharityRegistry charities = db.getCharitiesFromDB();
allCharities = charities.getAllCharities();

// Start empty and show matching cards when the user types in the search field.
cardsContainer.getChildren().clear();

searchField
Expand All @@ -36,6 +35,10 @@ public void initialize() {
(observable, oldValue, newValue) -> displayCharities(filterCharities(newValue)));
}

/**
* @param query
* @return
*/
private List<Charity> filterCharities(String query) {
List<Charity> matches = new ArrayList<>();

Expand All @@ -56,6 +59,9 @@ private List<Charity> filterCharities(String query) {
return matches;
}

/**
* @param charities
*/
private void displayCharities(List<Charity> charities) {
cardsContainer.getChildren().clear();

Expand All @@ -76,6 +82,7 @@ private void displayCharities(List<Charity> charities) {

/**
* The method initialize the search in searchbar.
*
* @param query
*/
@FXML
Expand All @@ -94,7 +101,7 @@ public void setInitialSearch(String query) {
*/
@FXML
public void switchToFrontPage(ActionEvent event) {
LoaderScene.LoadScene("FrontPage", event, charity);
LoaderScene.LoadScene("FrontPage", event, charity, null);
}

/**
Expand All @@ -103,7 +110,7 @@ public void switchToFrontPage(ActionEvent event) {
* @param event action event from button click
*/
public void switchToCharityPage(ActionEvent event) {
LoaderScene.LoadScene("CharityPage", event, charity);
LoaderScene.LoadScene("CharityPage", event, charity, null);
}

/**
Expand All @@ -113,6 +120,6 @@ public void switchToCharityPage(ActionEvent event) {
*/
@FXML
public void switchToDonationPage(ActionEvent event) {
LoaderScene.LoadScene("DonationPage", event, charity);
LoaderScene.LoadScene("DonationPage", event, charity, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void setCharity(Charity charity) {
@FXML
public void switchToFrontPage(ActionEvent event) {
System.out.println("Click");
LoaderScene.LoadScene("FrontPage", event, charity);
LoaderScene.LoadScene("FrontPage", event, charity, null);
}

/**
Expand All @@ -57,6 +57,6 @@ public void switchToFrontPage(ActionEvent event) {
@FXML
public void switchToDonationPage(ActionEvent event) {
System.out.println("Click");
LoaderScene.LoadScene("donationPage", event, charity);
LoaderScene.LoadScene("donationPage", event, charity, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void setCharity(Charity charity) {
* @param event
*/
public void switchToFrontPage(ActionEvent event) {
LoaderScene.LoadScene("FrontPage", event, null);
LoaderScene.LoadScene("FrontPage", event, null, null);
}

/**
Expand All @@ -50,7 +50,7 @@ public void switchToFrontPage(ActionEvent event) {
* @param event
*/
public void switchToCharityPage(ActionEvent event) {
LoaderScene.LoadScene("charityPage", event, charity);
LoaderScene.LoadScene("charityPage", event, charity, null);
}

/**
Expand Down Expand Up @@ -101,7 +101,7 @@ public void Donate(ActionEvent event) {
"Thank you!",
"You have donated " + amount + " to " + charity.getName());
donatioAmount.clear();
LoaderScene.LoadScene("FrontPage", event, null);
LoaderScene.LoadScene("FrontPage", event, null, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class FrontpageController {

@FXML private TextField frontSearchField;


/**
* Initialize method for the front page. This method is called when the front page is loaded. It
* retrieves the list of charities and donations from the database. The list of charities is
Expand Down Expand Up @@ -122,4 +121,3 @@ public void handleFrontSearch(ActionEvent event) {
LoaderScene.LoadScene("availableOrganization", event, null, query);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public void setOrganization(Charity charity) {

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

public void switchToDonationPage(ActionEvent event) {
LoaderScene.LoadScene("DonationPage", event, charity);
LoaderScene.LoadScene("DonationPage", event, charity, null);
}
}
20 changes: 12 additions & 8 deletions helpmehelpapplication/src/main/resources/fxml/aboutPage.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,18 @@

<children>

<ImageView fitHeight="34.0" fitWidth="34.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="0">
<image>
<Image url="@../images/Logo.png" />
</image>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</ImageView>
<Button mnemonicParsing="false" onAction="#switchToFrontPage" prefHeight="0.0" prefWidth="0.0" style="-fx-background-color: #2f8f8b">
<graphic>
<ImageView fitHeight="34.0" fitWidth="57.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">
<children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
<Button mnemonicParsing="false"
prefHeight="0.0"
prefWidth="0.0"
style="-fx-background-color: #2f8f8b">
style="-fx-background-color: #2f8f8b"
onAction="#switchToFrontPage">
<graphic>
<ImageView fitHeight="54.0"
fitWidth="67.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</children>
</StackPane>
<!-- -->
<Button mnemonicParsing="false" onAction="#switchToFrontPage" prefHeight="0.0" prefWidth="0.0" style="-fx-background-color: #2f8f8b">
<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>
Expand Down

0 comments on commit b3fdd47

Please sign in to comment.