Skip to content

Commit

Permalink
fix UI
Browse files Browse the repository at this point in the history
  • Loading branch information
zoebelle-pang committed Apr 4, 2024
1 parent 974ae3a commit 427b7aa
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 130 deletions.
47 changes: 1 addition & 46 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import seedu.address.commons.core.GuiSettings;
import seedu.address.commons.core.LogsCenter;
Expand All @@ -37,10 +36,6 @@ public class MainWindow extends UiPart<Stage> {
private ResultDisplay resultDisplay;
private HelpWindow helpWindow;
private ViewWindow viewWindow;
private CommandListPanel commandListPanel;

@FXML
private VBox personList;

@FXML
private FlowPane calendar;
Expand All @@ -59,9 +54,6 @@ public class MainWindow extends UiPart<Stage> {
@FXML
private StackPane statusbarPlaceholder;

@FXML
private StackPane commandListPanelPlaceholder;

/**
* Creates a {@code MainWindow} with the given {@code Stage} and {@code Logic}.
*/
Expand Down Expand Up @@ -126,11 +118,6 @@ void fillInnerParts() {
personListPanel = new PersonListPanel(logic.getFilteredPersonList());
personListPanelPlaceholder.getChildren().add(personListPanel.getRoot());

commandListPanel = new CommandListPanel(logic.getCommandHistory());
commandListPanelPlaceholder.getChildren().add(commandListPanel.getRoot());

personList.getChildren().remove(commandListPanelPlaceholder);

resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());

Expand Down Expand Up @@ -171,35 +158,13 @@ public void handleHelp() {
@FXML
public void handleView() {
if (!viewWindow.isShowing()) {
viewWindow = new ViewWindow(logic);
viewWindow.show();
} else {
viewWindow.focus();
}
}

/**
* Hides the student list and shows the command history list.
*/
public void toggleHistoryList() {
if (personList.getChildren().contains(personListPanelPlaceholder)) {
personList.getChildren().remove(personListPanelPlaceholder);
personList.getChildren().add(commandListPanelPlaceholder);
}
}

/**
* Hides the command history list and shows the student list.
*/
public void toggleStudentList() {
if (personList.getChildren().contains(commandListPanelPlaceholder)) {
personList.getChildren().remove(commandListPanelPlaceholder);
personList.getChildren().add(personListPanelPlaceholder);
}
}

void show() {
primaryStage.setMaxWidth(400);
primaryStage.show();
}

Expand All @@ -220,10 +185,6 @@ public PersonListPanel getPersonListPanel() {
return personListPanel;
}

public CommandListPanel getCommandListPanel() {
return commandListPanel;
}

/**
* Executes the command and returns the result.
*
Expand All @@ -243,12 +204,6 @@ private CommandResult executeCommand(String commandText) throws CommandException
handleView();
}

if (commandResult.isShowHistory()) {
toggleHistoryList();
} else {
toggleStudentList();
}

if (commandResult.isExit()) {
handleExit();
}
Expand All @@ -260,4 +215,4 @@ private CommandResult executeCommand(String commandText) throws CommandException
throw e;
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/NoteWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ public void hide() {
public void focus() {
getRoot().requestFocus();
}
}
}
80 changes: 27 additions & 53 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.stage.Stage;
import seedu.address.model.person.Person;
Expand All @@ -18,15 +17,8 @@
* An UI component that displays information of a {@code Person}.
*/
public class PersonCard extends UiPart<Region> {

private static final String FXML = "PersonListCard.fxml";
private static final String PHONE_DESCRIPTION = "Phone: ";
private static final String ADDRESS_DESCRIPTION = "Address: ";
private static final String EMAIL_DESCRIPTION = "Email: ";
private static final String SUBJECT_DESCRIPTION = "Subject: ";
private static final String GRADE_DESCRIPTION = "Grade: ";
private static final String ATTENDANCE_DESCRIPTION = "Last class attendance: ";
private static final String PAYMENT_DESCRIPTION = "Current monthly fees status: ";
private static final String CELL_SMALL_LABEL_CLASS = "cell_small_label";

/**
* Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX.
Expand All @@ -38,32 +30,29 @@ public class PersonCard extends UiPart<Region> {

public final Person person;
private final NoteWindow noteWindow;

@FXML
private HBox cardPane;
@FXML
private Label name;
@FXML
private Label id;
@FXML
private HBox phone;
@FXML
private HBox address;
private Label phone;
@FXML
private HBox email;
private Label address;
@FXML
private HBox subject;
private Label email;
@FXML
private HBox grade;
private FlowPane subjectWithGrade;
@FXML
private HBox attendance;
private Label attendance;
@FXML
private HBox payment;
private Label payment;
@FXML
private Button noteButton;
@FXML
private HBox dateTimes;
@FXML
private Label dateTimeDescription;
private FlowPane dateTimes;
@FXML
private FlowPane tags;

Expand All @@ -73,48 +62,29 @@ public class PersonCard extends UiPart<Region> {
public PersonCard(Person person, int displayedIndex) {
super(FXML);
this.person = person;

Stage stage = new Stage();
stage.setMaxWidth(400);
this.noteWindow = new NoteWindow(stage, person);

id.setText(displayedIndex + ". ");
name.setText(person.getName().fullName);
phone.setText(person.getPhone().value);
address.setText(person.getAddress().value);
email.setText(person.getEmail().value);
subjectWithGrade.getChildren().add(new Label(person.getSubject().value));
subjectWithGrade.getChildren().add(new Label(person.getGrade().value));
attendance.setText(person.getAttendance().value);
payment.setText(person.getPayment().value);
dateTimes.setHgap(5);
person.getDateTimes().stream()
.sorted(Comparator.comparing(dateTime -> dateTime.value))
.forEach(dateTime -> dateTimes.getChildren()
.add(new Label(LocalDateTime.parse(dateTime.value,
DateTimeFormatter.ofPattern("uuuu-MM-dd HHmm"))
.format(DateTimeFormatter.ofPattern("MMM d uuuu h:mma")))));
person.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
setField(phone, PHONE_DESCRIPTION, person.getPhone().value);
setField(address, ADDRESS_DESCRIPTION, person.getAddress().value);
setField(email, EMAIL_DESCRIPTION, person.getEmail().value);
setField(attendance, ATTENDANCE_DESCRIPTION, person.getAttendance().value);
setField(payment, PAYMENT_DESCRIPTION, person.getPayment().value);
setField(subject, SUBJECT_DESCRIPTION, person.getSubject().value);
setField(grade, GRADE_DESCRIPTION, person.getGrade().value);
person.getDateTimes().stream()
.sorted(Comparator.comparing(dateTime -> dateTime.value))
.forEach(dateTime -> {
Label dateTimeLabel = new Label(LocalDateTime.parse(dateTime.value,
DateTimeFormatter.ofPattern("uuuu-MM-dd HHmm"))
.format(DateTimeFormatter.ofPattern("MMM d uuuu h:mma")));
dateTimeLabel.getStyleClass().add(CELL_SMALL_LABEL_CLASS);
dateTimes.getChildren()
.add(dateTimeLabel);
});
}

public void setField(HBox hbox, String description, String value) {
Label descriptionLabel = new Label(description);
descriptionLabel.getStyleClass().add(CELL_SMALL_LABEL_CLASS);
HBox.setHgrow(descriptionLabel, Priority.NEVER);

Region spacer = new Region();
HBox.setHgrow(spacer, Priority.ALWAYS);


Label valueLabel = new Label(value);
valueLabel.getStyleClass().add(CELL_SMALL_LABEL_CLASS);
HBox.setHgrow(valueLabel, Priority.NEVER);
hbox.getChildren().addAll(descriptionLabel, spacer, valueLabel);
}

/**
Expand All @@ -128,4 +98,8 @@ public void handleNote() {
noteWindow.focus();
}
}

}



90 changes: 81 additions & 9 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
-fx-border-width: 0 0 1 0;
-fx-background-color: transparent;
-fx-border-color:
transparent
transparent
derive(-fx-base, 80%)
transparent;
transparent
transparent
derive(-fx-base, 80%)
transparent;
-fx-border-insets: 0 10 1 0;
}

Expand Down Expand Up @@ -133,13 +133,13 @@
}

.stack-pane {
-fx-background-color: derive(#1d1d1d, 20%);
-fx-background-color: derive(#1d1d1d, 20%);
}

.pane-with-border {
-fx-background-color: derive(#1d1d1d, 20%);
-fx-border-color: derive(#1d1d1d, 10%);
-fx-border-top-width: 1px;
-fx-background-color: derive(#1d1d1d, 20%);
-fx-border-color: derive(#1d1d1d, 10%);
-fx-border-top-width: 1px;
}

.status-bar {
Expand Down Expand Up @@ -207,6 +207,55 @@
-fx-background-color: black;
}

/*
* Metro style Push Button
* Author: Pedro Duque Vieira
* http://pixelduke.wordpress.com/2012/10/23/jmetro-windows-8-controls-on-java/
*/
.button {
-fx-padding: 5 22 5 22;
-fx-border-color: #e2e2e2;
-fx-border-width: 2;
-fx-background-radius: 0;
-fx-background-color: #1d1d1d;
-fx-font-family: "Segoe UI", Helvetica, Arial, sans-serif;
-fx-font-size: 11pt;
-fx-text-fill: #d8d8d8;
-fx-background-insets: 0 0 0 0, 0, 1, 2;
}

.button:hover {
-fx-background-color: #3a3a3a;
}

.button:pressed, .button:default:hover:pressed {
-fx-background-color: white;
-fx-text-fill: #1d1d1d;
}

.button:focused {
-fx-border-color: white, white;
-fx-border-width: 1, 1;
-fx-border-style: solid, segments(1, 1);
-fx-border-radius: 0, 0;
-fx-border-insets: 1 1 1 1, 0;
}

.button:disabled, .button:default:disabled {
-fx-opacity: 0.4;
-fx-background-color: #1d1d1d;
-fx-text-fill: white;
}

.button:default {
-fx-background-color: -fx-focus-color;
-fx-text-fill: #ffffff;
}

.button:default:hover {
-fx-background-color: derive(-fx-focus-color, 30%);
}

.dialog-pane {
-fx-background-color: #1d1d1d;
}
Expand Down Expand Up @@ -302,6 +351,29 @@
-fx-font-size: 11;
}

#subjectWithGrade {
-fx-hgap: 7;
-fx-vgap: 3;
}

#subjectWithGrade .label {
-fx-text-fill: white;
-fx-background-color: #3e7b91;
-fx-padding: 1 3 1 3;
-fx-border-radius: 2;
-fx-background-radius: 2;
-fx-font-size: 11;
}

#dateTimes .label {
-fx-text-fill: white;
-fx-background-color: #3e7b91;
-fx-padding: 1 3 1 3;
-fx-border-radius: 2;
-fx-background-radius: 2;
-fx-font-size: 11;
}

#noteButton {
-fx-background-color: dimgray;
-fx-text-fill: white;
Expand All @@ -315,4 +387,4 @@

#noteButton:armed {
-fx-background-color: darkgray;
}
}
Loading

0 comments on commit 427b7aa

Please sign in to comment.