package seedu.task.ui;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.task.commons.exceptions.IllegalValueException;
import seedu.task.model.tag.Tag;
import seedu.task.model.task.Group;
import seedu.task.model.task.ReadOnlyTask;

//@@author A0164032U
public class TaskCard extends UiPart<Region> {

    private static final String FXML = "PersonListCard.fxml";

    @FXML
    private HBox cardPane;
    @FXML
    private Label name;
    @FXML
    private Label id;
    @FXML
    private Label end;
    @FXML
    private Label start;
    @FXML
    private Label group;

    public TaskCard(ReadOnlyTask person, int displayedIndex) {
        super(FXML);

        name.setText(person.getName().fullName);
        id.setText(displayedIndex + ". ");

        if (person.getEndDate() == null || person.getEndDate().getInputValue() == null) {
            end.setVisible(false);
        } else {
            end.setText("Ends:   " + person.getEndDate());
        }

        if (person.getStartDate() == null || person.getStartDate().getInputValue() == null) {
            start.setVisible(false);
        } else {
            start.setText("Starts: " + person.getStartDate());
        }

        if (!person.getGroup().value.equals(Group.GROUP_ID_HIDDEN)) {
            group.setText(person.getGroup().value);
        } else {
            group.setVisible(false);
        }

        if (person.hasPassed()) {
            setStyleToIndicateEndDatePassed();
        }

        try {
            if (person.getTags().contains(new Tag(Tag.TAG_COMPLETE))) {
                setStyleToIndicateComplete();
            } else {
                setStyleToIndicateIncomplete();
            }
        } catch (IllegalValueException e) {
        }

        cardPane.autosize();
    }

    /**
     * Sets the command box style to indicate a failed command.
     */
    private void setStyleToIndicateEndDatePassed() {
        cardPane.getStyleClass().add(Ui.ERROR_STYLE_CLASS);
    }

    private void setStyleToIndicateComplete() {
        cardPane.getStyleClass().add(Ui.COMPLETE_STYLE_CLASS);
    }

    private void setStyleToIndicateIncomplete() {
        cardPane.getStyleClass().add(Ui.INCOMPLETE_STYLE_CLASS);
    }
}

@@ -690,22 +690,20 @@
 nlyTask 
-person
+task
 , int di
@@ -757,30 +757,28 @@
 ame.setText(
-person
+task
 .getName().f
@@ -839,30 +839,28 @@
         if (
-person
+task
 .getEndDate(
@@ -868,30 +868,28 @@
  == null %7C%7C 
-person
+task
 .getEndDate(
@@ -1002,30 +1002,28 @@
 Ends:   %22 + 
-person
+task
 .getEndDate(
@@ -1045,30 +1045,28 @@
         if (
-person
+task
 .getStartDat
@@ -1080,22 +1080,20 @@
 null %7C%7C 
-person
+task
 .getStar
@@ -1220,22 +1220,20 @@
 ts: %22 + 
-person
+task
 .getStar
@@ -1266,22 +1266,20 @@
    if (!
-person
+task
 .getGrou
@@ -1347,22 +1347,20 @@
 setText(
-person
+task
 .getGrou
@@ -1448,22 +1448,20 @@
     if (
-person
+task
 .hasPass
@@ -1560,14 +1560,12 @@
 if (
-person
+task
 .get

Refactor TaskCard.java