-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Trung Dat Luu dashluu9121997@gmail.com Co-authored-by: Timothy Nguyen timothyhnguyen234@gmail.com
- Loading branch information
Showing
2 changed files
with
102 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package code.client.View; | ||
|
||
import java.util.ArrayList; | ||
|
||
import code.client.Model.Recipe; | ||
import javafx.geometry.Pos; | ||
import javafx.scene.Scene; | ||
import javafx.scene.control.TextField; | ||
import javafx.scene.layout.VBox; | ||
import javafx.stage.Stage; | ||
|
||
public class DetailsAppFrame { | ||
private ArrayList<Scene> scenes; | ||
private Stage primaryStage; | ||
|
||
public Scene getScene() { | ||
VBox root = new VBox(); | ||
root.setSpacing(20); | ||
root.setAlignment(Pos.CENTER); | ||
root.setStyle("-fx-background-color: #F0F8FF;"); | ||
|
||
VBox setupContainer = new VBox(); | ||
setupContainer.setSpacing(10); | ||
|
||
// Hardcoded value for now, recipe value for it should be changing | ||
Recipe temp = new Recipe("1", "Fried Chicken and Egg Fried Rice"); | ||
temp.addIngredient("2 chicken breasts, diced"); | ||
temp.addIngredient("2 large eggs"); | ||
temp.addIngredient("2 cups cooked rice"); | ||
temp.addIngredient("2 tablespoons vegetable oil"); | ||
temp.addInstruction("1. Heat the vegetable oil in a large pan over medium-high heat."); | ||
|
||
RecipeDetailsUI details = new RecipeDetailsUI(temp); | ||
|
||
TextField title = details.getTitleField(); | ||
title.setAlignment(Pos.CENTER); | ||
title.setStyle("-fx-font-weight: bold; -fx-font-size: 20;"); | ||
root.getChildren().add(title); | ||
|
||
setupContainer.getChildren().add(details); | ||
root.getChildren().add(setupContainer); | ||
|
||
return new Scene(root, 700, 600); | ||
} | ||
|
||
/** | ||
* This method provides the UI holder with the different scenes that can be | ||
* switched between. | ||
* | ||
* @param primaryStage - Main stage that has the window | ||
* @param scenes - list of different scenes to switch between. | ||
*/ | ||
public void setScenes(Stage primaryStage, ArrayList<Scene> scenes) { | ||
this.scenes = scenes; | ||
this.primaryStage = primaryStage; | ||
} | ||
} |
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,45 @@ | ||
package code.client.View; | ||
|
||
import javafx.scene.control.TextArea; | ||
import javafx.scene.control.TextField; | ||
import javafx.scene.layout.HBox; | ||
|
||
import java.util.Iterator; | ||
|
||
import code.client.Model.Recipe; | ||
|
||
public class RecipeDetailsUI extends HBox { | ||
private final TextField titleTextField; | ||
private final TextArea ingredientTextArea; | ||
private final TextArea instructionTextArea; | ||
|
||
public RecipeDetailsUI(Recipe recipe) { | ||
titleTextField = new TextField(); | ||
ingredientTextArea = new TextArea(); | ||
instructionTextArea = new TextArea(); | ||
|
||
titleTextField.setText(recipe.getTitle()); | ||
|
||
StringBuilder ingredientBuilder = new StringBuilder(); | ||
Iterator<String> ingredientIterator = recipe.getIngredientIterator(); | ||
while (ingredientIterator.hasNext()) { | ||
ingredientBuilder.append(ingredientIterator.next() + "\n"); | ||
} | ||
ingredientTextArea.setText(ingredientBuilder.toString()); | ||
|
||
StringBuilder instructionBuilder = new StringBuilder(); | ||
Iterator<String> instructionIterator = recipe.getInstructionIterator(); | ||
while (instructionIterator.hasNext()) { | ||
instructionBuilder.append(instructionIterator.next() + "\n"); | ||
} | ||
instructionTextArea.setText(instructionBuilder.toString()); | ||
|
||
// getChildren().add(titleTextField); | ||
getChildren().add(ingredientTextArea); | ||
getChildren().add(instructionTextArea); | ||
} | ||
|
||
public TextField getTitleField() { | ||
return titleTextField; | ||
} | ||
} |