Skip to content

Commit

Permalink
Feat: Featured charity has working button
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Mar 13, 2026
1 parent ab5bacd commit 255e786
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ntnu.systemutvikling.team6.controller;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
Expand All @@ -15,9 +16,7 @@
import java.util.stream.Collectors;

public class FrontpageController {



@FXML private Charity featuredCharity;
@FXML
private FlowPane cardsContainer;
@FXML
Expand Down Expand Up @@ -55,9 +54,12 @@ public void initialize() {
Random random = new Random();
int randomIndex = random.nextInt(Charities_size);
Charity randomCharity = Charities.getAllCharities().get(randomIndex);
this.featuredCharity = randomCharity;
Carosel_Organisasjon.setText(randomCharity.getName());
Carosel_Beskrivelse.setText(randomCharity.getDescription());

Total_Orgnisasjon.setText(Integer.toString(Charities_size));

Total_Donations.setText(Double.toString(Donations.getAllDonations().stream().mapToDouble(Donation::getAmount).sum()));
PreApproved_Percentage.setText(
String.format("%.2f", Charities.getAllCharities().stream().filter(Charity::getPreApproved).count() * 100.0 / Charities_size)
Expand All @@ -67,4 +69,12 @@ public void initialize() {
e.printStackTrace();
}
}

/* EVENTS */
public void switchToCharityPage(ActionEvent event){
LoaderScene.LoadScene("CharityPage", event, featuredCharity);
}
public void switchToDonationPage(ActionEvent event){
LoaderScene.LoadScene("DonationPage", event, featuredCharity);
}
}
34 changes: 11 additions & 23 deletions helpmehelpapplication/src/main/resources/fxml/frontPage.fxml
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.effect.Blend?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>
<?import javafx.geometry.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>

<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="900.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ntnu.systemutvikling.team6.controller.FrontpageController">
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="900.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/17.0.12" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ntnu.systemutvikling.team6.controller.FrontpageController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
Expand Down Expand Up @@ -207,8 +195,8 @@
<Region prefHeight="171.0" prefWidth="16.0" HBox.hgrow="ALWAYS" />
<VBox alignment="CENTER" prefHeight="152.0" prefWidth="301.0" spacing="18.0">
<children>
<Button mnemonicParsing="false" style="-fx-background-color: #2E7D32; -fx-text-fill: white; -fx-font-size: 16; -fx-font-weight: bold; -fx-background-radius: 30; -fx-padding: 15 35 15 35; -fx-effect: dropshadow(gaussian, rgba(0,0,0,0.2), 8, 0.2, 0, 3);" text="Donate Now" />
<Button mnemonicParsing="false" style="-fx-background-color: #163AA8; -fx-text-fill: white; -fx-font-size: 16; -fx-font-weight: bold; -fx-background-radius: 30; -fx-padding: 15 35 15 35; -fx-effect: dropshadow(gaussian, rgba(0,0,0,0.2), 8, 0.2, 0, 3);" text="View details" />
<Button mnemonicParsing="false" onAction="#switchToDonationPage" style="-fx-background-color: #2E7D32; -fx-text-fill: white; -fx-font-size: 16; -fx-font-weight: bold; -fx-background-radius: 30; -fx-padding: 15 35 15 35; -fx-effect: dropshadow(gaussian, rgba(0,0,0,0.2), 8, 0.2, 0, 3);" text="Donate Now" />
<Button mnemonicParsing="false" onAction="#switchToCharityPage" style="-fx-background-color: #163AA8; -fx-text-fill: white; -fx-font-size: 16; -fx-font-weight: bold; -fx-background-radius: 30; -fx-padding: 15 35 15 35; -fx-effect: dropshadow(gaussian, rgba(0,0,0,0.2), 8, 0.2, 0, 3);" text="View details" />
</children>
</VBox>
<Button alignment="CENTER_RIGHT" contentDisplay="RIGHT" mnemonicParsing="false" prefHeight="58.0" prefWidth="82.0" style="-fx-background-color: transparent; -fx-font-size: 42; -fx-text-fill: black;" text="&gt;">
Expand Down

0 comments on commit 255e786

Please sign in to comment.