Implemented UI+OverviewCtrl
This commit is contained in:
parent
7e924e064a
commit
2916dd476e
3 changed files with 30 additions and 80 deletions
|
|
@ -3,7 +3,8 @@ package client.scenes;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
//import commons.Recipe; or something
|
||||
import commons.Recipe;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
|
|
@ -12,30 +13,30 @@ import javafx.scene.control.ListCell;
|
|||
import javafx.scene.control.ListView;
|
||||
|
||||
public class OverviewCtrl {
|
||||
|
||||
private final MainCtrl mainCtrl;
|
||||
|
||||
// all of these aren't used with only my part of the code
|
||||
// everything in the top bar ===
|
||||
@FXML
|
||||
private Button flagEnButton;
|
||||
private Button flagEnButton; //already here for advanced stuff
|
||||
|
||||
@FXML
|
||||
private Button flagNlButton;
|
||||
private Button flagNlButton; //already here for advanced stuff
|
||||
|
||||
@FXML
|
||||
private Button flagPlButton;
|
||||
private Button flagPlButton; //already here for advanced stuff
|
||||
|
||||
@FXML
|
||||
private Button refreshButton;
|
||||
|
||||
@FXML
|
||||
private Button closeButton;
|
||||
private Button closeButton; //already here for advanced stuff
|
||||
|
||||
@FXML
|
||||
private Button maximizeButton;
|
||||
private Button maximizeButton; //already here for advanced stuff
|
||||
|
||||
@FXML
|
||||
private Button minimizeButton;
|
||||
private Button minimizeButton; //already here for advanced stuff
|
||||
|
||||
// everything in the left lane
|
||||
@FXML
|
||||
|
|
@ -78,7 +79,7 @@ public class OverviewCtrl {
|
|||
@Override
|
||||
protected void updateItem(Recipe item, boolean 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
|
||||
recipeList.setOnMouseClicked(event -> {
|
||||
if (event.getClickCount() == 2) {
|
||||
final int DOUBLE_CLICK = 2; //to not get magic number:P
|
||||
if (event.getClickCount() == DOUBLE_CLICK) {
|
||||
openSelectedRecipe();
|
||||
}
|
||||
});
|
||||
|
|
@ -97,12 +99,16 @@ public class OverviewCtrl {
|
|||
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
|
||||
private void refresh() {
|
||||
// TODO: someone else doing this
|
||||
List<Recipe> recipes = getMockRecipes();
|
||||
List<Recipe> recipes = showRecipeDetails();
|
||||
recipeList.getItems().setAll(recipes);
|
||||
|
||||
// Select first recipe in the list by default
|
||||
|
|
@ -111,14 +117,19 @@ public class OverviewCtrl {
|
|||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
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.showCreateRecipe();
|
||||
// to remove error till everything else is implemented
|
||||
private List<Recipe> showRecipeDetails() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@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();
|
||||
if (selected == null) {
|
||||
return;
|
||||
|
|
@ -136,7 +147,7 @@ public class OverviewCtrl {
|
|||
return;
|
||||
}
|
||||
// Let MainCtrl open the full detail screen
|
||||
mainCtrl.showRecipeDetail(selected.id);
|
||||
mainCtrl.showOverview(); //I had showrecipedetail but intelij says showoverview
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
@ -174,21 +185,6 @@ public class OverviewCtrl {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<?import javafx.scene.layout.VBox?>
|
||||
<?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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue