-
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.
feat: created BrowsePage and a component for cards representing an or…
…ganization
- Loading branch information
Showing
2 changed files
with
92 additions
and
10 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
77 changes: 76 additions & 1 deletion
77
src/main/java/edu/group5/app/view/browsepage/BrowsePageView.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 |
|---|---|---|
| @@ -1,4 +1,79 @@ | ||
| package edu.group5.app.view.browsepage; | ||
|
|
||
| public class BrowsePageView { | ||
| import edu.group5.app.control.BrowseCardController; | ||
| import edu.group5.app.control.BrowsePageController; | ||
| import edu.group5.app.control.HeaderController; | ||
| import edu.group5.app.view.Header; | ||
| import javafx.scene.Scene; | ||
| import javafx.scene.control.ScrollPane; | ||
| import javafx.scene.control.TextField; | ||
| import javafx.scene.layout.*; | ||
|
|
||
| public class BrowsePageView extends BorderPane { | ||
| private final Scene scene; | ||
| private final BrowsePageController controller; | ||
| private final BrowseCardController orgController; | ||
|
|
||
| public BrowsePageView(Scene mainScene, BrowsePageController browsePageController, BrowseCardController browseCardController, HeaderController headerController) { | ||
| this.scene = mainScene; | ||
| this.controller = browsePageController; | ||
| this.orgController = browseCardController; | ||
| getStylesheets().add(getClass().getResource("/browsepage/browsepage.css").toExternalForm()); | ||
| Header headerView = new Header(headerController); | ||
| setTop(headerView); | ||
| setCenter(createBody()); | ||
| } | ||
|
|
||
| private ScrollPane createBody() { | ||
| ScrollPane body = new ScrollPane(); | ||
| body.setId("body"); | ||
| body.setFitToWidth(true); | ||
| VBox vBox = new VBox(); | ||
| vBox.setSpacing(10); | ||
| vBox.getChildren().addAll( | ||
| createSearchSection(), | ||
| createOrganizationSection() | ||
| ); | ||
| body.setContent(vBox); | ||
| return body; | ||
| } | ||
|
|
||
| private HBox createSearchSection() { | ||
| HBox searchSection = new HBox(); | ||
| TextField searchField = new TextField(); | ||
| searchField.setPromptText("Search.."); | ||
| searchSection.getChildren().add(searchField); | ||
| return searchSection; | ||
| } | ||
|
|
||
| private GridPane createOrganizationSection() { | ||
| GridPane grid = new GridPane(); | ||
| grid.setHgap(10); | ||
| grid.setVgap(10); | ||
|
|
||
| int column = 0; | ||
| int row = 0; | ||
| for (int i = 0; i < 8; i++) { | ||
| BrowseCard card = new BrowseCard(orgController, "/browsepage/images/children_of_shambala.png", "Shambala Foundation"); | ||
|
|
||
| card.setMaxWidth(Double.MAX_VALUE); | ||
| GridPane.setHgrow(card, Priority.ALWAYS); | ||
| GridPane.setFillWidth(card, true); | ||
| grid.add(card, column, row); | ||
|
|
||
| column++; | ||
|
|
||
| if (column == 4) { | ||
| column = 0; | ||
| row++; | ||
| } | ||
| } | ||
|
|
||
| for (int i = 0; i < 4; i++) { | ||
| ColumnConstraints col = new ColumnConstraints(); | ||
| col.setPercentWidth(25); | ||
| grid.getColumnConstraints().add(col); | ||
| } | ||
| return grid; | ||
| } | ||
| } |