Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nihirraa committed Sep 20, 2024
1 parent f1debb3 commit e5335ce
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/java/espresso/Espresso.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//Solution below inspired by https://github.com/nus-cs2103-AY2425S1/ip/pull/557 with permission
package espresso;

import espresso.task.TaskList;
Expand Down
23 changes: 16 additions & 7 deletions src/main/java/espresso/gui/DialogBox.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//Solution below inspired by https://github.com/nus-cs2103-AY2425S1/ip/pull/557 with permission
package espresso.gui;

import javafx.geometry.Insets;
Expand All @@ -22,7 +23,8 @@ public class DialogBox extends HBox {
* @param message The message text to be displayed.
* @param avatar The ImageView containing the avatar to be displayed.
*/
private DialogBox(String message, ImageView avatar) {
//Solution below inspired by https://github.com/nus-cs2103-AY2425S1/ip/pull/557 with permission
private DialogBox(String message, ImageView avatar, Boolean bot) {
this.message = new Label(message);
this.avatar = avatar;

Expand All @@ -41,7 +43,11 @@ private DialogBox(String message, ImageView avatar) {
VBox.setVgrow(messageContainer, Priority.ALWAYS);

this.setAlignment(Pos.TOP_RIGHT);
getChildren().addAll(messageContainer, avatar);
if (bot) {
getChildren().addAll(avatar, messageContainer);
} else {
getChildren().addAll(messageContainer, avatar);
}
}

/**
Expand All @@ -51,15 +57,16 @@ private DialogBox(String message, ImageView avatar) {
* @param message The message text to be displayed in the user dialog.
* @return A DialogBox containing the user message and avatar.
*/
//Solution below inspired by https://github.com/nus-cs2103-AY2425S1/ip/pull/557 with permission
public static DialogBox createUserDialog(String message) {
ImageView userAvatar = new ImageView(new Image(DialogBox.class.getResourceAsStream("/images/EspressoUser.png")));
DialogBox userDialog = new DialogBox(message, userAvatar);
userDialog.setAlignment(Pos.TOP_RIGHT); // Align user dialog to the right

DialogBox userDialog = new DialogBox(message, userAvatar, false);
// Set margin
HBox.setMargin(userDialog.avatar, new Insets(0, 0, 0, 3));
HBox.setMargin(userDialog.message, new Insets(0, 3, 0, 0));
userDialog.setMinHeight(Region.USE_PREF_SIZE);

userDialog.setAlignment(Pos.CENTER_RIGHT); // Align user dialog to the CENTER RIGHT
return userDialog;
}

Expand All @@ -69,15 +76,17 @@ public static DialogBox createUserDialog(String message) {
* @param message The message text to be displayed in the bot dialog.
* @return A DialogBox containing the bot message and avatar.
*/
//Solution below inspired by https://github.com/nus-cs2103-AY2425S1/ip/pull/557 with permission
public static DialogBox createBotDialog(String message) {
ImageView botAvatar = new ImageView(new Image(DialogBox.class.getResourceAsStream("/images/Espresso.png")));
DialogBox botDialog = new DialogBox(message, botAvatar);
botDialog.setAlignment(Pos.TOP_LEFT); // Align bot dialog to the left
DialogBox botDialog = new DialogBox(message, botAvatar, true);

// Set margin
HBox.setMargin(botDialog.avatar, new Insets(0, 0, 0, 4));
HBox.setMargin(botDialog.message, new Insets(0, 0, 0, 4));
botDialog.setMinHeight(Region.USE_PREF_SIZE);

botDialog.setAlignment(Pos.TOP_LEFT); // Align bot dialog to the center left
return botDialog;
}
}
1 change: 0 additions & 1 deletion src/main/java/espresso/gui/Main.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// USED AI generate some code and also referenced @rituliP for some code
package espresso.gui;

import javafx.application.Application;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/espresso/gui/MainWindow.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package espresso.gui;
//Reference from @RitulKumarSingh for MainWindow.fxml

import espresso.command.InvalidCommandException;
import espresso.Espresso;
import javafx.animation.PauseTransition;
Expand Down Expand Up @@ -46,6 +46,7 @@ public void initialize() throws InvalidCommandException, ParseException {
dialogBoxContainer.setPrefWidth(newVal.doubleValue());
});
}
//Solution below inspired by https://github.com/nus-cs2103-AY2425S1/ip/pull/557 with permission

@FXML
private void handleUserInput() throws ParseException {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/espresso/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Parser {
* @throws InvalidCommandException If the command format is invalid.
* @throws ParseException If there is an error in parsing task data.
*/
//Solution below inspired by https://github.com/nus-cs2103-AY2425S1/ip/pull/557 with permission
public static String parse(String input, TaskList taskList, Ui ui) throws InvalidCommandException, ParseException {
if (input.equals("list")) {
return ui.printTasks(taskList);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/espresso/storage/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public Storage(String filePath) {
* @throws ParseException If the file content is in an invalid format.
* @throws InvalidCommandException If an invalid task type is encountered in the file.
*/
//Solution below inspired by https://github.com/nus-cs2103-AY2425S1/ip/pull/557 with permission
public ArrayList<Task> load() throws IOException, ParseException, InvalidCommandException {
ArrayList<Task> tasks = new ArrayList<>();

Expand Down
1 change: 1 addition & 0 deletions src/main/java/espresso/task/DeadlineTask.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//Solution below inspired by https://github.com/nus-cs2103-AY2425S1/ip/pull/557 with permission
package espresso.task;

import java.text.ParseException;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/espresso/task/EventTask.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//Solution below inspired by https://github.com/nus-cs2103-AY2425S1/ip/pull/557 with permission
package espresso.task;

import java.text.ParseException;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Solution below inspired by https://github.com/nus-cs2103-AY2425S1/ip/pull/557 with permission -->
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ScrollPane?>
Expand Down

0 comments on commit e5335ce

Please sign in to comment.