Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions data/lars.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
D | 0 | return library book | Feb 15 2026
T | 0 | borrow book
T | 1 | borrow book
E | 0 | project meeting | 2026-02-10 | 2026-02-20
D | 0 | return library book | Feb 15 2026 18:00
D | 0 | return book | Sunday
Expand All @@ -11,3 +10,9 @@ D | 0 | return book | Sunday
T | 0 | 2103
D | 0 | return li book | 2026-02-19
T | 0 | miss mjr
T | 0 | 11
T | 0 | 11
T | 0 | 111
E | 0 | project meeting | 2026-02-10 | 2026-02-20
T | 0 | 11
E | 0 | project meeting | 2026-02-10 | 2026-02-20
18 changes: 16 additions & 2 deletions src/main/java/DialogBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ private DialogBox(String text, Image img) {
dialog.setText(text);
dialog.setWrapText(true);
dialog.setMaxWidth(400);

displayPicture.setImage(img);

dialog.getStyleClass().add("label");
}

/**
Expand All @@ -46,15 +49,21 @@ private void flip() {
Collections.reverse(tmp);
getChildren().setAll(tmp);
setAlignment(Pos.TOP_LEFT);
dialog.getStyleClass().add("reply-label");
dialog.getStyleClass().add("lars-label");
}

public static DialogBox getUserDialog(String text, Image img) {
return new DialogBox(text, img);
var db = new DialogBox(text, img);
db.setAlignment(Pos.TOP_RIGHT);
db.dialog.getStyleClass().add("user-bubble");
return db;
}

private void changeDialogStyle(String commandType) {
switch (commandType) {
case "Error":
dialog.getStyleClass().add("error-bubble");
break;
case "AddCommand":
dialog.getStyleClass().add("add-label");
break;
Expand All @@ -78,10 +87,15 @@ private void changeDialogStyle(String commandType) {
public static DialogBox getLarsDialog(String text, Image img, String commandType) {
var db = new DialogBox(text, img);
db.flip();
db.dialog.getStyleClass().add("lars-bubble");

if (commandType != null) {
db.changeDialogStyle(commandType);
}
return db;
}

public void flipToErrorStyle() {
dialog.getStyleClass().add("error-bubble");
}
}
6 changes: 6 additions & 0 deletions src/main/java/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ private void handleUserInput() throws LarsException {
String input = userInput.getText();
String response = lars.getResponse(input);
String commandType = lars.getCommandType();
DialogBox larsDialog = DialogBox.getLarsDialog(response, larsImage, commandType);

if ("Error".equals(commandType)) {
larsDialog.flipToErrorStyle();
}

dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, userImage),
DialogBox.getLarsDialog(response, larsImage, commandType)
Expand Down
26 changes: 19 additions & 7 deletions src/main/resources/css/dialog-box.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
.label {
-fx-background-color: linear-gradient(to bottom right, #00ffbf, #00ddff);
-fx-border-color: #d55e00 #009e73 #cc79a7 #0072b2;
-fx-border-width: 2px;
-fx-background-color: #FAFF72;
-fx-border-color: rgba(0,0,0,0.08);;
-fx-border-width: 1px;
-fx-padding: 8 12 8 12;
-fx-text-fill: black;
}

.user-bubble {
-fx-background-color: #A7E6FF;
-fx-background-radius: 1em 1em 0 1em;
-fx-border-radius: 1em 1em 0 1em;
}

.lars-bubble {
-fx-background-color: #FAFF72;
-fx-background-radius: 1em 1em 1em 0;
-fx-border-radius: 1em 1em 1em 0;
}

.add-label {
-fx-background-color: yellow;
-fx-background-color: #FAFF72;
}

.marked-label {
Expand All @@ -18,9 +30,9 @@
-fx-background-color: lightpink;
}

.reply-label {
-fx-background-radius: 1em 1em 1em 0;
-fx-border-radius: 1em 1em 1em 0;
.error-bubble {
-fx-background-color: #FFEBEE !important;
-fx-border-color: #FFCDD2 !important;
}

#displayPicture {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}

.scroll-bar .thumb {
-fx-background-color: #ff9cb4;
-fx-background-color: #F4C902;
-fx-background-radius: 1em;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/view/DialogBox.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<children>
<Label fx:id="dialog" minHeight="-Infinity" text="Label" wrapText="true">
<HBox.margin>
<Insets left="7.0" right="7.0" />
<Insets left="9.0" right="9.0" />
</HBox.margin>
<padding>
<Insets bottom="6.0" left="6.0" right="6.0" top="6.0" />
</padding></Label>
<ImageView fx:id="displayPicture" fitHeight="99.0" fitWidth="99.0" pickOnBounds="true" preserveRatio="true" />
<ImageView fx:id="displayPicture" fitHeight="75.0" fitWidth="75.0" pickOnBounds="true" preserveRatio="true" />
</children>
<padding>
<Insets bottom="15.0" left="5.0" right="5.0" top="15.0" />
Expand Down