Skip to content

Commit

Permalink
Add DeadlineCard and EventCard to separate display functionalities fr…
Browse files Browse the repository at this point in the history
…om TaskCard, and update isDone colour display style
  • Loading branch information
JJ-Rachel committed Oct 19, 2016
1 parent 989cb48 commit 0c4c8b4
Show file tree
Hide file tree
Showing 8 changed files with 351 additions and 3 deletions.
103 changes: 103 additions & 0 deletions src/main/java/seedu/taskitty/ui/DeadlineCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package seedu.taskitty.ui;

import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import seedu.taskitty.model.task.ReadOnlyTask;
import seedu.taskitty.model.task.TaskDate;
import seedu.taskitty.model.task.TaskTime;

public class DeadlineCard extends UiPart{

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

@FXML
private HBox cardPane;
@FXML
private Label name;
@FXML
private Label startDate;
@FXML
private Label startTime;
@FXML
private Label endDate;
@FXML
private Label endTime;
@FXML
private Label id;
@FXML
private Label tags;

private ReadOnlyTask task;
private int displayedIndex;

public DeadlineCard(){

}

public static DeadlineCard load(ReadOnlyTask task, int displayedIndex){
DeadlineCard card = new DeadlineCard();
card.task = task;
card.displayedIndex = displayedIndex;
return UiPartLoader.loadUiPart(card);
}

@FXML
public void initialize() {
name.setText(task.getName().fullName);
startDate.setText("");
startTime.setText("");
endDate.setText("");
endTime.setText("");

TaskDate startTaskDate = task.getStartDate();
if (startTaskDate != null) {
startDate.setText(startTaskDate.toString());
}

TaskTime taskStartTime = task.getStartTime();
if (taskStartTime != null) {
startTime.setText(taskStartTime.toString());
}

TaskDate endTaskDate = task.getEndDate();
if (endTaskDate != null) {
endDate.setText(endTaskDate.toString());
}

TaskTime taskEndTime = task.getEndTime();
if (taskEndTime != null) {
endTime.setText(taskEndTime.toString());
}

boolean isDone = task.getIsDone();
if (isDone) {
cardPane.setStyle("-fx-background-color: grey");
name.setStyle("-fx-text-fill: white");
id.setStyle("-fx-text-fill: white");
startDate.setStyle("-fx-text-fill: white");
endDate.setStyle("-fx-text-fill: white");
startTime.setStyle("-fx-text-fill: white");
endTime.setStyle("-fx-text-fill: white");

}

id.setText(displayedIndex + ". ");
tags.setText(task.tagsString());
}

public HBox getLayout() {
return cardPane;
}

@Override
public void setNode(Node node) {
cardPane = (HBox)node;
}

@Override
public String getFxmlPath() {
return FXML;
}
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/taskitty/ui/DeadlineListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected void updateItem(ReadOnlyTask deadline, boolean empty) {
setGraphic(null);
setText(null);
} else {
setGraphic(TaskCard.load(deadline, getIndex() + 1).getLayout());
setGraphic(DeadlineCard.load(deadline, getIndex() + 1).getLayout());
}
}
}
Expand Down
103 changes: 103 additions & 0 deletions src/main/java/seedu/taskitty/ui/EventCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package seedu.taskitty.ui;

import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import seedu.taskitty.model.task.ReadOnlyTask;
import seedu.taskitty.model.task.TaskDate;
import seedu.taskitty.model.task.TaskTime;

public class EventCard extends UiPart{

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

@FXML
private HBox cardPane;
@FXML
private Label name;
@FXML
private Label startDate;
@FXML
private Label startTime;
@FXML
private Label endDate;
@FXML
private Label endTime;
@FXML
private Label id;
@FXML
private Label tags;

private ReadOnlyTask task;
private int displayedIndex;

public EventCard(){

}

public static EventCard load(ReadOnlyTask task, int displayedIndex){
EventCard card = new EventCard();
card.task = task;
card.displayedIndex = displayedIndex;
return UiPartLoader.loadUiPart(card);
}

@FXML
public void initialize() {
name.setText(task.getName().fullName);
startDate.setText("");
startTime.setText("");
endDate.setText("");
endTime.setText("");

TaskDate startTaskDate = task.getStartDate();
if (startTaskDate != null) {
startDate.setText(startTaskDate.toString());
}

TaskTime taskStartTime = task.getStartTime();
if (taskStartTime != null) {
startTime.setText(taskStartTime.toString());
}

TaskDate endTaskDate = task.getEndDate();
if (endTaskDate != null) {
endDate.setText(endTaskDate.toString());
}

TaskTime taskEndTime = task.getEndTime();
if (taskEndTime != null) {
endTime.setText(taskEndTime.toString());
}

boolean isDone = task.getIsDone();
if (isDone) {
cardPane.setStyle("-fx-background-color: grey");
name.setStyle("-fx-text-fill: white");
id.setStyle("-fx-text-fill: white");
startDate.setStyle("-fx-text-fill: white");
endDate.setStyle("-fx-text-fill: white");
startTime.setStyle("-fx-text-fill: white");
endTime.setStyle("-fx-text-fill: white");

}

id.setText(displayedIndex + ". ");
tags.setText(task.tagsString());
}

public HBox getLayout() {
return cardPane;
}

@Override
public void setNode(Node node) {
cardPane = (HBox)node;
}

@Override
public String getFxmlPath() {
return FXML;
}
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/taskitty/ui/EventListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected void updateItem(ReadOnlyTask task, boolean empty) {
setGraphic(null);
setText(null);
} else {
setGraphic(TaskCard.load(task, getIndex() + 1).getLayout());
setGraphic(EventCard.load(task, getIndex() + 1).getLayout());
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/seedu/taskitty/ui/TaskCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ public void initialize() {

boolean isDone = task.getIsDone();
if (isDone) {
cardPane.setStyle("-fx-background-color: #ff0000");
cardPane.setStyle("-fx-background-color: grey");
name.setStyle("-fx-text-fill: white");
id.setStyle("-fx-text-fill: white");
startDate.setStyle("-fx-text-fill: white");
endDate.setStyle("-fx-text-fill: white");
startTime.setStyle("-fx-text-fill: white");
endTime.setStyle("-fx-text-fill: white");

}

Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-fx-padding: 0 0 0 1;
}


.label-bright {
-fx-font-size: 11pt;
-fx-font-family: "Segoe UI Semibold";
Expand Down Expand Up @@ -113,6 +114,15 @@
-fx-text-fill: #ff0000;
}

#done-event {
-fx-text-fill: #FFFFFF;
-fx-background-color: grey;
}

#done-deadline {
-fx-background-color: grey;
-fx-text-fill: #FFFFFF;
}
.cell_big_label {
-fx-font-size: 16px;
-fx-text-fill: #010504;
Expand Down
63 changes: 63 additions & 0 deletions src/main/resources/view/DeadlineListCard.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>

<HBox id="cardPane" fx:id="cardPane" stylesheets="@DarkTheme.css" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
<children>
<GridPane HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="150.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="100.0" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<children>
<VBox alignment="CENTER_LEFT" maxHeight="150.0" minHeight="105.0" prefHeight="115.0" GridPane.columnIndex="0">
<stylesheets>
<URL value="@DarkTheme.css" />
<URL value="@Extensions.css" />
</stylesheets>
<padding>
<Insets bottom="5" left="15" right="5" top="5" />
</padding>

<children>
<HBox alignment="CENTER_LEFT" spacing="5">
<children>
<HBox>
<Label fx:id="id" styleClass="cell_big_label" />
<Label fx:id="name" styleClass="cell_big_label" text="\$name" />
</HBox>
</children>
</HBox>
<HBox alignment="CENTER_LEFT" spacing="5">
<children>
<HBox>
<children>
<Label fx:id="startDate" styleClass="cell_small_label" text="\$startDate" />
<Label fx:id="startTime" styleClass="cell_small_label" text="\$startTime" />
</children>
</HBox>
</children>
</HBox>
<HBox alignment="CENTER_LEFT">
<children>
<Label fx:id="endDate" styleClass="cell_small_label" text="\$endDate" />
<Label fx:id="endTime" styleClass="cell_small_label" text="\$endTime" />
</children>
</HBox>
<Label fx:id="tags" styleClass="cell_small_label" text="\$tags" />
</children>
</VBox>
</children>
<rowConstraints>
<RowConstraints />
</rowConstraints>
</GridPane>
</children>
</HBox>
63 changes: 63 additions & 0 deletions src/main/resources/view/EventListCard.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>

<HBox id="cardPane" fx:id="cardPane" stylesheets="@DarkTheme.css" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
<children>
<GridPane HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="150.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="100.0" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<children>
<VBox alignment="CENTER_LEFT" maxHeight="150.0" minHeight="105.0" prefHeight="115.0" GridPane.columnIndex="0">
<stylesheets>
<URL value="@DarkTheme.css" />
<URL value="@Extensions.css" />
</stylesheets>
<padding>
<Insets bottom="5" left="15" right="5" top="5" />
</padding>

<children>
<HBox alignment="CENTER_LEFT" spacing="5">
<children>
<HBox>
<Label fx:id="id" styleClass="cell_big_label" />
<Label fx:id="name" styleClass="cell_big_label" text="\$name" />
</HBox>
</children>
</HBox>
<HBox alignment="CENTER_LEFT" spacing="5">
<children>
<HBox>
<children>
<Label fx:id="startDate" styleClass="cell_small_label" text="\$startDate" />
<Label fx:id="startTime" styleClass="cell_small_label" text="\$startTime" />
</children>
</HBox>
</children>
</HBox>
<HBox alignment="CENTER_LEFT">
<children>
<Label fx:id="endDate" styleClass="cell_small_label" text="\$endDate" />
<Label fx:id="endTime" styleClass="cell_small_label" text="\$endTime" />
</children>
</HBox>
<Label fx:id="tags" styleClass="cell_small_label" text="\$tags" />
</children>
</VBox>
</children>
<rowConstraints>
<RowConstraints />
</rowConstraints>
</GridPane>
</children>
</HBox>

0 comments on commit 0c4c8b4

Please sign in to comment.