Skip to content

Commit

Permalink
Merge pull request AY2324S2-CS2103T-T08-1#51 from NatLeong/update-sta…
Browse files Browse the repository at this point in the history
…tuscircle-colour

Update nric, sex and status circle
  • Loading branch information
jovantanyk authored Mar 19, 2024
2 parents cbb7cc5 + 9341aea commit 03498c4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/main/java/seedu/address/model/person/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ public Status(String status) {
this.status = StatusType.valueOf(status);
}

/**
* Gets status type
*
* @return Status type of this status
*/
public StatusType getStatusType() {
return this.status;
}

/**
* Checks if a String matches the Enum
* @param testString String of input
Expand Down
31 changes: 30 additions & 1 deletion src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import seedu.address.model.person.Person;
import seedu.address.model.person.Status;

/**
* An UI component that displays information of a {@code Person}.
Expand All @@ -31,6 +34,8 @@ public class PersonCard extends UiPart<Region> {
private Label id;
@FXML
private Label nric;
@FXML
private Circle statusCircle;

/**
* Creates a {@code PersonCode} with the given {@code Person} and index to display.
Expand All @@ -39,6 +44,30 @@ public PersonCard(Person person, int displayedIndex) {
super(FXML);
this.person = person;
id.setText(displayedIndex + ". ");
name.setText(person.getName().toString());
name.setText(person.getName().toString() + " (" + person.getSex().toString() + ")");
nric.setText(person.getNric().toString());
updateStatusCircle(person.getStatus());
}

/**
* Set colour of status circle to represent status
*
* @param status Status of the person
*/
public void updateStatusCircle(Status status) {
switch (status.getStatusType()) {
case HEALTHY:
statusCircle.setFill(Color.GREEN);
break;
case UNWELL:
statusCircle.setFill(Color.RED);
break;
case PENDING:
statusCircle.setFill(Color.YELLOW);
break;
default:
statusCircle.setFill(Color.GREY);
break;
}
}
}
10 changes: 5 additions & 5 deletions src/main/resources/view/PersonListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
</padding>
</Label>
</VBox>
<Circle fill="#3ea435" radius="17.0" stroke="#3ea435" strokeType="INSIDE" strokeWidth="4.0" GridPane.columnIndex="1" GridPane.halignment="RIGHT">
<GridPane.margin>
<Insets right="20.0" />
</GridPane.margin>
</Circle>
<Circle fx:id="statusCircle" fill="#3ea435" radius="17.0" stroke="#3ea435" strokeType="INSIDE" strokeWidth="4.0" GridPane.columnIndex="1" GridPane.halignment="RIGHT">
<GridPane.margin>
<Insets right="20.0" />
</GridPane.margin>
</Circle>
<rowConstraints>
<RowConstraints />
</rowConstraints>
Expand Down

0 comments on commit 03498c4

Please sign in to comment.