package seedu.tasklist.ui;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.tasklist.model.task.DeadlineTask;
import seedu.tasklist.model.task.ReadOnlyDeadlineTask;
import seedu.tasklist.model.task.ReadOnlyTask;

public class TaskCard extends UiPart<Region> {

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

    @FXML
    private HBox cardPane;
    @FXML
    private Label name;
    @FXML
    private Label id;

    @FXML
    private Label comment;

    @FXML
    private Label priority;
    @FXML
    private Label startDate;
    @FXML
    private Label endDate;

    @FXML
    private FlowPane tags;

    public TaskCard(ReadOnlyTask task, int displayedIndex) {
        super(FXML);
        String taskType = task.getType();
        switch(taskType) {
        case DeadlineTask.TYPE:
            endDate.setText(((ReadOnlyDeadlineTask) task).getDeadlineString());
        }
        name.setText(task.getName().fullName);
        id.setText(displayedIndex + ". ");
        comment.setText(task.getComment().value);
        initTags(task);
    }

    private void initTags(ReadOnlyTask task) {
        task.getTags().forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
    }
}

@@ -266,32 +266,128 @@
 el.task.
-ReadOnlyDeadline
+EventTask;%0Aimport seedu.tasklist.model.task.ReadOnlyDeadlineTask;%0Aimport seedu.tasklist.model.task.ReadOnlyEvent
 Task;%0Aim
@@ -964,157 +964,8 @@
 ();%0A
-        switch(taskType) %7B%0A        case DeadlineTask.TYPE:%0A            endDate.setText(((ReadOnlyDeadlineTask) task).getDeadlineString());%0A        %7D%0A
     
@@ -1124,16 +1124,389 @@
 (task);%0A
+        switch(taskType) %7B%0A        case DeadlineTask.TYPE:%0A            endDate.setText(((ReadOnlyDeadlineTask) task).getDeadlineString());%0A            break;%0A        case EventTask.TYPE:%0A            startDate.setText(((ReadOnlyEventTask) task).getStartDateString());%0A            endDate.setText(((ReadOnlyEventTask) task).getEndDateString());%0A            break;%0A        %7D%0A%0A
     %7D%0A%0A 

add EventTask to task card