Skip to content
Snippets Groups Projects
Commit 5cb47da5 authored by HSoreide's avatar HSoreide
Browse files

Refactor Scene Switch for SuggestRecipes view

parent 80abb2af
No related branches found
No related tags found
2 merge requests!42Hs frontend recipes,!41Hs frontend recipes
......@@ -81,9 +81,6 @@ public class SuggestRecipesController implements Initializable {
fridge = FXCollections.observableArrayList(ingredientsAtHand.getIngredientsAtHand().stream().map(foodItem -> foodItem.label).toList());
fridgeList.setItems(fridge.sorted());
setRecipeTiles();
}else if(clickedButton.get() == ButtonType.CANCEL) {
}
}
......@@ -157,28 +154,21 @@ public class SuggestRecipesController implements Initializable {
@FXML
private void goBack(ActionEvent event) throws IOException {
private void switchScene(ActionEvent event) throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/view/MainMenuNew.fxml"));
if (event.getSource() == showAllBtn) {
loader.setLocation(getClass().getResource("/view/AllRecipes.fxml"));
} else if (event.getSource() == goBackBtn) {
loader.setLocation(getClass().getResource("/view/MainMenuNew.fxml"));
}
Parent root = loader.load();
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setResizable(false);
stage.show();
}
@FXML
private void showAllRecipes(ActionEvent event) throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/view/AllRecipes.fxml"));
Parent root = loader.load();
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
......
......@@ -70,7 +70,7 @@
<left>
<Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<Button id="button-style" fx:id="goBackBtn" alignment="CENTER" contentDisplay="CENTER" layoutX="62.0" layoutY="24.0" mnemonicParsing="false" onAction="#goBack" styleClass="button-style" stylesheets="@../style.css" text="Go Back" textAlignment="CENTER">
<Button id="button-style" fx:id="goBackBtn" alignment="CENTER" contentDisplay="CENTER" layoutX="62.0" layoutY="24.0" mnemonicParsing="false" onAction="#switchScene" styleClass="button-style" stylesheets="@../style.css" text="Go Back" textAlignment="CENTER">
<font>
<Font size="14.0" />
</font>
......@@ -88,7 +88,7 @@
<right>
<VBox alignment="CENTER_LEFT" prefHeight="400.0" prefWidth="405.0" BorderPane.alignment="CENTER">
<children>
<Button fx:id="showAllBtn" mnemonicParsing="false" onAction="#showAllRecipes" styleClass="button-style" stylesheets="@../style.css" text="Or show all recipes" textAlignment="CENTER">
<Button fx:id="showAllBtn" mnemonicParsing="false" onAction="#switchScene" styleClass="button-style" stylesheets="@../style.css" text="Or show all recipes" textAlignment="CENTER">
<VBox.margin>
<Insets left="80.0" />
</VBox.margin>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment