-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from cathrkri/feature/javafx-frontpage
Feature/javafx frontpage
- Loading branch information
Showing
5 changed files
with
183 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...papplication/src/main/java/ntnu/systemutvikling/team6/controller/FrontpageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package ntnu.systemutvikling.team6.controller; | ||
|
|
||
| import java.util.List; | ||
| import javafx.fxml.FXML; | ||
| import javafx.fxml.FXMLLoader; | ||
| import javafx.scene.Parent; | ||
| import javafx.scene.layout.FlowPane; | ||
| import ntnu.systemutvikling.team6.models.Charity; | ||
|
|
||
| public class FrontpageController { | ||
|
|
||
| @FXML private FlowPane cardsContainer; | ||
|
|
||
| @FXML | ||
| public void initialize() { | ||
| try { | ||
|
|
||
| List<Charity> charities = | ||
| List.of( | ||
| new Charity("Redd Barna", | ||
| "Protecting children's rights worldwide.", | ||
| "Children"), | ||
| new Charity("Leger Uten Grenser", | ||
| "Emergency medical aid in crisis areas.", | ||
| "Health"), | ||
| new Charity( | ||
| "Kirkens Nødhjelp", | ||
| "Humanitarian aid and long-term development work.", | ||
| "Emergency Aid")); | ||
|
|
||
| for (Charity ch : charities) { | ||
|
|
||
| FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/organizationCard.fxml")); | ||
|
|
||
| Parent card = loader.load(); | ||
|
|
||
| OrganizationCardController cardController = loader.getController(); | ||
|
|
||
| cardController.setOrganization(ch.getName(), ch.getDescription()); | ||
|
|
||
| cardsContainer.getChildren().add(card); | ||
| } | ||
|
|
||
| } catch (Exception e) { | ||
| e.printStackTrace(); | ||
| } | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
...ation/src/main/java/ntnu/systemutvikling/team6/controller/OrganizationCardController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package ntnu.systemutvikling.team6.controller; | ||
|
|
||
| import javafx.fxml.FXML; | ||
| import javafx.scene.control.Label; | ||
|
|
||
| public class OrganizationCardController { | ||
|
|
||
| @FXML private Label organizationName; | ||
|
|
||
| @FXML private Label organizationDescription; | ||
|
|
||
| public void setOrganization(String name, String description) { | ||
| organizationName.setText(name); | ||
| organizationDescription.setText(description); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
helpmehelpapplication/src/main/resources/fxml/organizationCard.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <?import javafx.geometry.Insets?> | ||
| <?import javafx.scene.control.Button?> | ||
| <?import javafx.scene.control.Label?> | ||
| <?import javafx.scene.image.ImageView?> | ||
| <?import javafx.scene.layout.HBox?> | ||
| <?import javafx.scene.layout.Region?> | ||
| <?import javafx.scene.layout.VBox?> | ||
| <?import javafx.scene.text.Font?> | ||
|
|
||
| <VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="240.0" prefWidth="380.0" spacing="12.0" style="-fx-background-color: white; -fx-background-radius: 20; -fx-border-radius: 20; -fx-border-color: #3b82f6; -fx-border-width: 2;" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ntnu.systemutvikling.team6.controller.OrganizationCardController"> | ||
| <padding> | ||
| <Insets bottom="12.0" left="12.0" right="12.0" top="12.0" /> | ||
| </padding> | ||
| <children> | ||
| <HBox prefHeight="100.0" prefWidth="200.0" spacing="10.0"> | ||
| <children> | ||
| <ImageView fitHeight="60.0" fitWidth="60.0" pickOnBounds="true" preserveRatio="true" /> | ||
| <Region prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" /> | ||
| <Label style="-fx-background-color: #cdedcf; -fx-background-radius: 12; -fx-padding: 4 10 4 10; -fx-text-fill: #2e7d32; -fx-font-size: 12;" text="Verified" /> | ||
| </children> | ||
| </HBox> | ||
| <Label fx:id="organizationName" text="Organization name"> | ||
| <font> | ||
| <Font name="System Bold" size="26.0" /> | ||
| </font> | ||
| </Label> | ||
| <Label fx:id="organizationDescription" prefWidth="300.0" text="Some interesting information about the organization" wrapText="true" /> | ||
| <Region prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" /> | ||
| <HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" spacing="12.0"> | ||
| <children> | ||
| <Button mnemonicParsing="false" prefWidth="110.0" style="-fx-background-color: #2e7d32; -fx-background-radius: 16; -fx-text-fill: white; -fx-font-weight: bold;" text="Donate" /> | ||
| <Button mnemonicParsing="false" prefWidth="110.0" style="-fx-background-color: #2563eb; -fx-background-radius: 16; -fx-text-fill: white; -fx-font-weight: bold;" text="View details" /> | ||
| </children> | ||
| </HBox> | ||
| </children> | ||
| </VBox> |