Skip to content

Commit

Permalink
feat: searchbar update on the controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
cathrkri committed Mar 30, 2026
1 parent b3fdd47 commit 940fcaa
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
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 {
@FXML private TextField charitySearchField;

@FXML private Label CharityDescription;

Expand Down Expand Up @@ -59,4 +61,15 @@ public void switchToDonationPage(ActionEvent event) {
System.out.println("Click");
LoaderScene.LoadScene("donationPage", event, charity, null);
}

@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 @@ -21,6 +21,8 @@ public class DonationPageController {

@FXML private Label CharityName;

@FXML private TextField donationSearchField;

/**
* Initialize method for the donation page. Sets the charity name label to the name of the charity
* that is being donated to. The charity is set from the original page it was called from when the
Expand Down Expand Up @@ -130,4 +132,15 @@ private void showAlert(Alert.AlertType type, String title, String message) {
alert.setContentText(message);
alert.showAndWait();
}

@FXML
public void handleSearch(ActionEvent event) {
String query = donationSearchField.getText().trim();

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

LoaderScene.LoadScene("availableOrganization", event, null, query);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

<HBox alignment="CENTER" GridPane.columnIndex="2" GridPane.rowIndex="0">
<children>
<TextField maxWidth="430.0" 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;" />
<TextField fx:id="charitySearchField" onAction="#handleSearch" maxWidth="430.0" 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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</Label>
<StackPane prefHeight="150.0" prefWidth="200.0" GridPane.columnIndex="1">
<children>
<TextField minHeight="-Infinity" prefWidth="200.0" promptText="Search" style="-fx-background-radius: 15;" />
<TextField fx:id="donationSearchField" onAction="#handleSearch" minHeight="-Infinity" prefWidth="200.0" promptText="Search" style="-fx-background-radius: 15;" />
<Rectangle arcHeight="40.0" arcWidth="40.0" fill="#1f4fd8" height="34.0" stroke="TRANSPARENT" strokeType="INSIDE" translateX="132.0" width="120.0" StackPane.alignment="CENTER_RIGHT">
<cursor>
<Cursor fx:constant="HAND" />
Expand Down

0 comments on commit 940fcaa

Please sign in to comment.