Skip to content

Commit 054451f

Browse files
committed
Tweak the GUI
* Both sides of the conversation are displayed in the same format. * There is no background image. * As the conversation is between the user and the app, it is asymmetric in nature. So, different format for both sides of the conversation would help the user quickly differentiate the bot's replies and the user's inputs. * A background image would make the app more visually appealing. Let's * display the user's inputs against a white background and the bot's replies against a purple background. * add a translucent background image. * A purple background was chosen because it matches the color of the bot's profile picture. * A translucent background image was chosen because it aids in the visibility of the text.
1 parent b112c3b commit 054451f

File tree

8 files changed

+30
-15
lines changed

8 files changed

+30
-15
lines changed

src/main/java/drake/Ui.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public List<String> replyWelcome() {
5050
ArrayList<String> reply = new ArrayList<>();
5151
reply.add("You used to call me on my cellphone");
5252
reply.add("!@#$%^&*()-+!@#$%^&*()`~`!@#$");
53-
reply.add("Drake's (me) the kind of guy to help you out uwu");
54-
reply.add("Go ahead, make that hotline bling");
53+
reply.add("Drake's the kind of guy to help you out uwu");
54+
reply.add("Go ahead, make that hotline bling");
5555
return reply;
5656
}
5757

@@ -78,7 +78,7 @@ public void printLine(Object line) {
7878
*
7979
*/
8080
public String replyBye() {
81-
return "I'm down for you always. See you " + ANSI_RED + "<3" + ANSI_RESET;
81+
return "I'm down for you always. See you ❤";
8282
}
8383

8484
/**

src/main/java/drake/gui/ChatMessage.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class ChatMessage extends AnchorPane {
3131
@FXML
3232
private HBox header;
3333

34-
private ChatMessage(String name, String text, Image img) {
34+
private ChatMessage(String name, String text, Image img, boolean isWhiteBackground) {
3535
try {
3636
FXMLLoader fxmlLoader = new FXMLLoader(Window.class.getResource("/view/ChatMessage.fxml"));
3737
fxmlLoader.setController(this);
@@ -44,6 +44,9 @@ private ChatMessage(String name, String text, Image img) {
4444
this.name.setText(name);
4545
message.setText(text);
4646
profilePicture.setImage(img);
47+
if (isWhiteBackground) {
48+
message.setStyle("-fx-text-fill : #000000; -fx-background-color: white;");
49+
}
4750
}
4851

4952
/**
@@ -58,11 +61,11 @@ private void flip() {
5861
}
5962

6063
public static ChatMessage getUserDialog(String text, Image img) {
61-
return new ChatMessage("Lost Soul", text, img);
64+
return new ChatMessage("Lost Soul", text, img, true);
6265
}
6366

6467
public static ChatMessage getDrakeDialog(String text, Image img) {
65-
var db = new ChatMessage("Drake", text, img);
68+
var db = new ChatMessage("Drake", text, img, false);
6669
db.flip();
6770
return db;
6871
}

src/main/java/drake/gui/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public void start(Stage stage) {
2020
FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/view/Window.fxml"));
2121
AnchorPane anchorPane = fxmlLoader.load();
2222
Scene scene = new Scene(anchorPane);
23+
scene.getStylesheets().add("/view/styles.css");
2324
stage.setScene(scene);
2425
stage.show();
2526
stage.setTitle("Drake");
2.99 MB
Binary file not shown.
317 KB
Loading

src/main/resources/view/ChatMessage.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
<opaqueInsets>
3434
<Insets />
3535
</opaqueInsets>
36-
</fx:root>
36+
</fx:root>

src/main/resources/view/Window.fxml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
<children>
1212
<ScrollPane fx:id="scrollPane" hbarPolicy="NEVER" hvalue="1.0" prefHeight="557.0" prefWidth="400.0" vvalue="1.0" AnchorPane.bottomAnchor="44.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
1313
<content>
14-
<VBox fx:id="dialogContainer" alignment="TOP_CENTER" prefHeight="552.0" prefWidth="375.0" spacing="8.0" />
14+
<VBox fx:id="dialogContainer" style="-fx-background-image: url(/media/background.png); -fx-background-size: 100%;" alignment="TOP_CENTER" prefHeight="552.0" prefWidth="375.0" spacing="8.0" />
1515
</content>
1616
</ScrollPane>
17-
<HBox layoutY="500.0" prefHeight="40.0" spacing="4.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
18-
<children>
19-
<TextField fx:id="userInput" onAction="#handleUserInput" prefHeight="40.0" HBox.hgrow="ALWAYS" />
20-
<Button fx:id="sendButton" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="40.0" text="Send" />
21-
</children>
22-
</HBox>
17+
<HBox layoutY="500.0" prefHeight="40.0" spacing="4.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
18+
<children>
19+
<TextField fx:id="userInput" onAction="#handleUserInput" prefHeight="40.0" HBox.hgrow="ALWAYS" />
20+
<Button fx:id="sendButton" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="40.0" text="Send" />
21+
</children>
22+
</HBox>
2323
</children>
24-
</AnchorPane>
24+
</AnchorPane>

src/main/resources/view/styles.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@font-face {
2+
src: url(../fonts/YuseiMagic-Regular.ttf);
3+
}
4+
5+
.root {
6+
-fx-font-size: 14;
7+
-fx-font-family: 'Yusei Magic', sans-serif;
8+
-fx-font-weight: 700;
9+
10+
}
11+

0 commit comments

Comments
 (0)