Skip to content

Commit

Permalink
Merge pull request AY2324S2-CS2103-F15-2#79 from gowthaman-01/gui
Browse files Browse the repository at this point in the history
[gowthaman-01] GUI enhancements
  • Loading branch information
zoebelle-pang authored Apr 3, 2024
2 parents de4a9e1 + 3704d2c commit 4779f3e
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 52 deletions.
1 change: 1 addition & 0 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public void handleView() {
}

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

Expand Down
75 changes: 53 additions & 22 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@
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 seedu.address.model.person.Person;

/**
* 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 @@ -35,19 +43,23 @@ public class PersonCard extends UiPart<Region> {
@FXML
private Label id;
@FXML
private Label phone;
private HBox phone;
@FXML
private HBox address;
@FXML
private Label address;
private HBox email;
@FXML
private Label email;
private HBox subject;
@FXML
private FlowPane subjectWithGrade;
private HBox grade;
@FXML
private Label attendance;
private HBox attendance;
@FXML
private Label payment;
private HBox payment;
@FXML
private FlowPane dateTimes;
private HBox dateTimes;
@FXML
private Label dateTimeDescription;
@FXML
private FlowPane tags;

Expand All @@ -59,22 +71,41 @@ public PersonCard(Person person, int displayedIndex) {
this.person = 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);
}
}
23 changes: 0 additions & 23 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -350,26 +350,3 @@
-fx-background-radius: 2;
-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;
}
21 changes: 14 additions & 7 deletions src/main/resources/view/PersonListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<Insets top="5" right="5" bottom="5" left="15" />
</padding>
<HBox spacing="5" alignment="CENTER_LEFT">
<padding>
<Insets bottom="5" />
</padding>
<Label fx:id="id" styleClass="cell_big_label">
<minWidth>
<!-- Ensures that the label text is never truncated -->
Expand All @@ -28,13 +31,17 @@
<Label fx:id="name" text="\$first" styleClass="cell_big_label" />
</HBox>
<FlowPane fx:id="tags" />
<Label fx:id="phone" styleClass="cell_small_label" text="\$phone" />
<Label fx:id="address" styleClass="cell_small_label" text="\$address" />
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
<FlowPane fx:id="subjectWithGrade" />
<Label fx:id="attendance" styleClass="cell_small_label" text="\$attendance" />
<Label fx:id="payment" styleClass="cell_small_label" text="\$payment" />
<FlowPane fx:id="dateTimes" />
<HBox fx:id="phone" spacing="10" alignment="CENTER_LEFT" maxWidth="400" />
<HBox fx:id="address" spacing="10" alignment="CENTER_LEFT" maxWidth="400" />
<HBox fx:id="email" spacing="10" alignment="CENTER_LEFT" maxWidth="400" />
<HBox fx:id="attendance" spacing="10" alignment="CENTER_LEFT" maxWidth="400" />
<HBox fx:id="payment" spacing="10" alignment="CENTER_LEFT" maxWidth="400" />
<HBox fx:id="subject" spacing="10" alignment="CENTER_LEFT" maxWidth="400" />
<HBox fx:id="grade" spacing="10" alignment="CENTER_LEFT" maxWidth="400" />
<HBox fx:id="dateTimes" spacing="10" alignment="CENTER_LEFT" maxWidth="400">
<Label fx:id="dateTimeDescription" styleClass="cell_small_label" text="Upcoming lesson: " HBox.hgrow="NEVER" />
<Region HBox.hgrow="ALWAYS" />
</HBox>
</VBox>
</GridPane>
</HBox>

0 comments on commit 4779f3e

Please sign in to comment.