package seedu.todo.ui.components;

import java.util.List;

import javafx.fxml.FXML;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import seedu.todo.ui.UiPartLoader;

public class TagList extends Component {

    private static final String FXML_PATH = "components/TagList.fxml";

    // Links
    private static final String TASKS_LABEL = "Tasks";
    private static final String TASKS_ICON_PATH = "/images/icon-pin.png";
    private static final String OVERDUE_LABEL = "Overdue Tasks";
    private static final String OVERDUE_ICON_PATH = "/images/icon-siren.png";
    private static final String EVENTS_LABEL = "Events";
    private static final String EVENTS_ICON_PATH = "/images/icon-calendar.png";
    private static final String COMPLETED_LABEL = "Completed Tasks";
    private static final String COMPLETED_ICON_PATH = "/images/icon-tick.png";
    private static final String TAG_LABEL = "Tags";
    
    // Props
    public List<String> tags; // stub

    // FXML
    @FXML
    private Text titleText;
    @FXML
    private VBox tagListLinksPlaceholder;
    @FXML
    private VBox tagListTagsPlaceholder;

    public static TagList load(Stage primaryStage, Pane placeholderPane) {
        return UiPartLoader.loadUiPart(primaryStage, placeholderPane, new TagList());
    }

    @Override
    public String getFxmlPath() {
        return FXML_PATH;
    }

    @Override
    public void componentDidMount() {
        titleText.setText(formatTagSize(tags.size()));

        // Load TagListLinks
        loadLinks();

        // Load TagListItems
        loadTags();
    }
    
    private String formatTagSize(int size) {
        return String.format("%s (%s)",TAG_LABEL, size);
    }
    
    private void loadLinks() {
        TagListLink.reset(tagListLinksPlaceholder);

        String[] linkLabels = { TASKS_LABEL, OVERDUE_LABEL, EVENTS_LABEL, COMPLETED_LABEL };
        String[] linkIconPaths = { TASKS_ICON_PATH, OVERDUE_ICON_PATH, EVENTS_ICON_PATH, COMPLETED_ICON_PATH };

        for (int i = 0; i < linkLabels.length; i++) {
            TagListLink link = TagListLink.load(primaryStage, tagListLinksPlaceholder);
            link.linkLabel = linkLabels[i];
            link.iconPath = linkIconPaths[i];
            link.render();
        }
    }

    private void loadTags() {
        TagListItem.reset(tagListTagsPlaceholder);

        for (String tag : tags) {
            TagListItem item = TagListItem.load(primaryStage, tagListTagsPlaceholder);
            item.tag = tag;
            item.render();
        }
    }

}

@@ -201,16 +201,53 @@
 .Stage;%0A
+import seedu.todo.models.TodoListDB;%0A
 import s
@@ -814,155 +814,8 @@
 g%22;%0A
-    private static final String COMPLETED_LABEL = %22Completed Tasks%22;%0A    private static final String COMPLETED_ICON_PATH = %22/images/icon-tick.png%22;
 %0A   
@@ -1682,24 +1682,83 @@
 adLinks() %7B%0A
+        TodoListDB db = TodoListDB.getInstance();%0A        %0A
         TagL
@@ -1826,24 +1826,35 @@
 kLabels = %7B 
+formatLink(
 TASKS_LABEL,
@@ -1858,23 +1858,164 @@
 EL, 
-OVERDUE_LABEL, 
+db.countIncompleteTasks()), %0A                                formatLink(OVERDUE_LABEL, db.countOverdueTasks()), %0A                                formatLink(
 EVEN
@@ -2026,25 +2026,34 @@
 ABEL
+ 
 , 
-COMPLETED_LABEL
+db.countFutureEvents())
  %7D;%0A
@@ -2143,29 +2143,8 @@
 PATH
-, COMPLETED_ICON_PATH
  %7D;%0A
@@ -2693,12 +2693,135 @@
  %7D%0A    %7D
+%0A    %0A    private String formatLink(String label, int total) %7B%0A        return String.format(%22%25s (%25d)%22, label, total);%0A    %7D
 %0A%0A%7D%0A

Add total numbers in sidebar