feat: overview controller

This commit is contained in:
Aysegul Aydinlik 2025-11-27 16:59:23 +01:00
commit 8cb26203b9
2 changed files with 30 additions and 34 deletions

View file

@ -3,7 +3,8 @@ package client.scenes;
import java.util.List; import java.util.List;
//import commons.Recipe; or something import commons.Recipe;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Button; import javafx.scene.control.Button;
@ -12,30 +13,30 @@ import javafx.scene.control.ListCell;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
public class OverviewCtrl { public class OverviewCtrl {
private final MainCtrl mainCtrl; private final MainCtrl mainCtrl;
// all of these aren't used with only my part of the code
// everything in the top bar === // everything in the top bar ===
@FXML @FXML
private Button flagEnButton; private Button flagEnButton; //already here for advanced stuff
@FXML @FXML
private Button flagNlButton; private Button flagNlButton; //already here for advanced stuff
@FXML @FXML
private Button flagPlButton; private Button flagPlButton; //already here for advanced stuff
@FXML @FXML
private Button refreshButton; private Button refreshButton;
@FXML @FXML
private Button closeButton; private Button closeButton; //already here for advanced stuff
@FXML @FXML
private Button maximizeButton; private Button maximizeButton; //already here for advanced stuff
@FXML @FXML
private Button minimizeButton; private Button minimizeButton; //already here for advanced stuff
// everything in the left lane // everything in the left lane
@FXML @FXML
@ -78,7 +79,7 @@ public class OverviewCtrl {
@Override @Override
protected void updateItem(Recipe item, boolean empty) { protected void updateItem(Recipe item, boolean empty) {
super.updateItem(item, empty); super.updateItem(item, empty);
setText(empty || item == null ? "" : item.name); setText(empty || item == null ? "" : item.getName());
} }
}); });
@ -89,7 +90,8 @@ public class OverviewCtrl {
// Double-click to go to detail screen // Double-click to go to detail screen
recipeList.setOnMouseClicked(event -> { recipeList.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) { final int DOUBLE_CLICK = 2; //to not get magic number:P
if (event.getClickCount() == DOUBLE_CLICK) {
openSelectedRecipe(); openSelectedRecipe();
} }
}); });
@ -97,12 +99,16 @@ public class OverviewCtrl {
refresh(); refresh();
} }
// ================== BUTTON HANDLERS ================== // till the all the code from everyone is implemented for now to not have errors
private void showRecipeDetails(Recipe newRecipe) {
}
// Button handlers
@FXML @FXML
private void refresh() { private void refresh() {
// TODO: someone else doing this // TODO: someone else doing this
List<Recipe> recipes = getMockRecipes(); List<Recipe> recipes = showRecipeDetails();
recipeList.getItems().setAll(recipes); recipeList.getItems().setAll(recipes);
// Select first recipe in the list by default // Select first recipe in the list by default
@ -111,14 +117,19 @@ public class OverviewCtrl {
} }
} }
@FXML // to remove error till everything else is implemented
private void addRecipe() { private List<Recipe> showRecipeDetails() {
// Navigate to "create recipe" screen (should be like a pop-up or new screen or just another place in the app) return List.of();
mainCtrl.showCreateRecipe();
} }
@FXML @FXML
private void removeSelectedRecipe() { private void addRecipe() {
// Navigate to "create recipe" screen (should be like a pop-up or new screen or just another place in the app)
mainCtrl.showOverview();
}
@FXML
private void removeSelectedRecipe() {
Recipe selected = recipeList.getSelectionModel().getSelectedItem(); Recipe selected = recipeList.getSelectionModel().getSelectedItem();
if (selected == null) { if (selected == null) {
return; return;
@ -136,7 +147,7 @@ public class OverviewCtrl {
return; return;
} }
// Let MainCtrl open the full detail screen // Let MainCtrl open the full detail screen
mainCtrl.showRecipeDetail(selected.id); mainCtrl.showOverview(); //I had showrecipedetail but intelij says showoverview
} }
@FXML @FXML
@ -174,21 +185,6 @@ public class OverviewCtrl {
System.out.println("Switch language to PL"); System.out.println("Switch language to PL");
} }
// Window control buttons (are we keeping this?)
@FXML
private void closeWindow() {
mainCtrl.closeApplication();
}
@FXML
private void maximizeWindow() {
mainCtrl.toggleMaximize();
}
@FXML
private void minimizeWindow() {
mainCtrl.minimize();
}
} }

View file

@ -15,7 +15,7 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<BorderPane prefHeight="800.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.OverviewCtrl"> <BorderPane prefHeight="800.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.scenes.OverviewCtrl">
<!-- TOP BAR --> <!-- TOP BAR -->
<top> <top>