forked from nus-cs2103-AY1920S2/addressbook-level3
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from tharshita/master
Goals tab
- Loading branch information
Showing
10 changed files
with
196 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package seedu.recipe.ui; | ||
|
||
import java.io.IOException; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.Region; | ||
import seedu.recipe.model.cooked.Record; | ||
|
||
/** | ||
* An UI component that displays information of a {@code Recipe}. | ||
*/ | ||
public class CookedCard extends UiPart<Region> { | ||
|
||
private static final String FXML = "CookedListCard.fxml"; | ||
|
||
/** | ||
* Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. | ||
* As a consequence, UI elements' variable names cannot be set to such keywords | ||
* or an exception will be thrown by JavaFX during runtime. | ||
* | ||
* @see <a href="https://github.com/se-edu/addressbook-level4/issues/336">The issue on AddressBook level 4</a> | ||
*/ | ||
|
||
public final Record record; | ||
private final String styleIngredientsAndSteps = "-fx-font-size: 11pt;\n" | ||
+ "-fx-font-family: \"Segoe UI\";\n" | ||
+ "-fx-text-fill: #FFFFFF;\n"; | ||
|
||
@FXML | ||
private HBox cardPane; | ||
@FXML | ||
private Label name; | ||
@FXML | ||
private Label id; | ||
|
||
public CookedCard(Record record, int displayedIndex) throws IOException { | ||
super(FXML); | ||
this.record = record; | ||
id.setText(displayedIndex + ". "); | ||
name.setText(record.getName().fullName); | ||
name.setWrapText(true); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
// short circuit if same object | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof CookedCard)) { | ||
return false; | ||
} | ||
|
||
// state check | ||
CookedCard card = (CookedCard) other; | ||
return id.getText().equals(card.id.getText()) | ||
&& record.equals(card.record); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package seedu.recipe.ui; | ||
|
||
import java.io.IOException; | ||
import java.util.logging.Logger; | ||
|
||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.ListCell; | ||
import javafx.scene.control.ListView; | ||
import javafx.scene.layout.Region; | ||
import seedu.recipe.commons.core.LogsCenter; | ||
import seedu.recipe.commons.util.StringUtil; | ||
import seedu.recipe.model.cooked.Record; | ||
|
||
/** | ||
* Panel containing the list of recipes. | ||
*/ | ||
public class CookedListPanel extends UiPart<Region> { | ||
private static final String FXML = "CookedListPanel.fxml"; | ||
private final Logger logger = LogsCenter.getLogger(CookedListPanel.class); | ||
|
||
@FXML | ||
private ListView<Record> cookedListView; | ||
|
||
public CookedListPanel(ObservableList<Record> recordList) { | ||
super(FXML); | ||
cookedListView.setItems(recordList); | ||
cookedListView.setCellFactory(listView -> new RecordListViewCell()); | ||
} | ||
|
||
/** | ||
* Custom {@code ListCell} that displays the graphics of a {@code Recipe} using a {@code RecipeCard}. | ||
*/ | ||
class RecordListViewCell extends ListCell<Record> { | ||
@Override | ||
protected void updateItem(Record record, boolean empty) { | ||
super.updateItem(record, empty); | ||
if (empty || record == null) { | ||
setGraphic(null); | ||
setText(null); | ||
} else { | ||
try { | ||
setGraphic(new CookedCard(record, getIndex() + 1).getRoot()); | ||
} catch (IOException e) { | ||
logger.warning("Failed to load : " + StringUtil.getDetails(e)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ public enum Tab { | |
RECIPES, | ||
PLANNING, | ||
GOALS, | ||
ACHIEVEMENT | ||
ACHIEVEMENTS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.image.ImageView?> | ||
<?import javafx.scene.layout.ColumnConstraints?> | ||
<?import javafx.scene.layout.FlowPane?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import javafx.scene.layout.Region?> | ||
<?import javafx.scene.layout.VBox?> | ||
|
||
<HBox id="cardPane" fx:id="cardPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> | ||
<GridPane HBox.hgrow="ALWAYS"> | ||
<columnConstraints> | ||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" /> | ||
</columnConstraints> | ||
<VBox alignment="CENTER_LEFT" minHeight="105" GridPane.columnIndex="0"> | ||
<padding> | ||
<Insets top="5" right="5" bottom="5" left="15" /> | ||
</padding> | ||
<HBox spacing="5" alignment="CENTER_LEFT"> | ||
<Label fx:id="id" styleClass="cell_big_label"> | ||
<minWidth> | ||
<!-- Ensures that the label text is never truncated --> | ||
<Region fx:constant="USE_PREF_SIZE" /> | ||
</minWidth> | ||
</Label> | ||
<Label fx:id="name" text="\$first" styleClass="cell_big_label" /> | ||
</HBox> | ||
</VBox> | ||
</GridPane> | ||
</HBox> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.layout.VBox?> | ||
<?import javafx.scene.layout.BorderPane?> | ||
<?import javafx.scene.control.Label?> | ||
|
||
<?import javafx.scene.control.ListView?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import javafx.scene.chart.PieChart?> | ||
<HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> | ||
<BorderPane fx:id="borderPane"> | ||
<top> | ||
<VBox spacing = "5"> | ||
<Label fx:id="cooked" text="Cooked Meals" styleClass="cell_big_label"/> | ||
</VBox> | ||
</top> | ||
<center> | ||
<ListView fx:id="cookedListView" /> | ||
</center> | ||
</BorderPane> | ||
<BorderPane fx:id="borderPane2"> | ||
<top> | ||
<VBox spacing = "5"> | ||
<Label fx:id="graph" text="Goals" styleClass="cell_big_label"/> | ||
</VBox> | ||
</top> | ||
<center> | ||
<PieChart fx:id="graphView" /> | ||
</center> | ||
</BorderPane> | ||
</HBox> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,4 @@ | |
|
||
</BorderPane> | ||
|
||
|
||
</VBox> |