From 2c5f9fa056cfc9597f3640120f451876ca6bcdec Mon Sep 17 00:00:00 2001 From: jiholim Date: Tue, 23 Oct 2018 17:12:57 +0800 Subject: [PATCH 1/4] Restore the updated wish detail panel --- .../seedu/address/ui/WishDetailPanel.java | 54 +++++++++++------- .../address/ui/WishDetailSavingAmount.java | 57 +++++++++++++++++++ .../address/ui/WishDetailSavingHistory.java | 39 +++++++++++++ src/main/resources/view/DarkTheme.css | 35 +++++++++--- src/main/resources/view/WishDetailPanel.fxml | 18 +++--- .../view/WishDetailSavingAmount.fxml | 29 ++++++++++ .../view/WishDetailSavingHistory.fxml | 25 ++++++++ 7 files changed, 222 insertions(+), 35 deletions(-) create mode 100644 src/main/java/seedu/address/ui/WishDetailSavingAmount.java create mode 100644 src/main/java/seedu/address/ui/WishDetailSavingHistory.java create mode 100644 src/main/resources/view/WishDetailSavingAmount.fxml create mode 100644 src/main/resources/view/WishDetailSavingHistory.fxml diff --git a/src/main/java/seedu/address/ui/WishDetailPanel.java b/src/main/java/seedu/address/ui/WishDetailPanel.java index 0a7e92205ed7..19b42da7ca37 100644 --- a/src/main/java/seedu/address/ui/WishDetailPanel.java +++ b/src/main/java/seedu/address/ui/WishDetailPanel.java @@ -9,6 +9,7 @@ import javafx.scene.control.Label; import javafx.scene.layout.FlowPane; import javafx.scene.layout.Region; +import javafx.scene.layout.StackPane; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.ui.WishPanelSelectionChangedEvent; import seedu.address.model.wish.Wish; @@ -19,26 +20,21 @@ public class WishDetailPanel extends UiPart { private static final String FXML = "WishDetailPanel.fxml"; + private static final String[] TAG_COLORS = { "red", "yel", "blue", "navy", "ora", "green", "pink", "hot", "pur" }; private final Logger logger = LogsCenter.getLogger(getClass()); - @FXML - private Label name; + private WishDetailSavingAmount wishDetailSavingAmount; + private WishDetailSavingHistory wishDetailSavingHistory; @FXML - private Label price; + private StackPane wishSavingAmountPlaceholder; @FXML - private Label savedAmount; + private StackPane wishSavingHistoryPlaceholder; @FXML - private Label url; - - @FXML - private Label email; - - @FXML - private Label remark; + private Label name; @FXML private FlowPane tags; @@ -49,6 +45,12 @@ public WishDetailPanel() { // To prevent triggering events for typing inside the loaded Web page. getRoot().setOnKeyPressed(Event::consume); + wishDetailSavingAmount = new WishDetailSavingAmount(); + wishSavingAmountPlaceholder.getChildren().add(wishDetailSavingAmount.getRoot()); + + wishDetailSavingHistory = new WishDetailSavingHistory(); + wishSavingHistoryPlaceholder.getChildren().add(wishDetailSavingHistory.getRoot()); + loadDefaultPage(); registerAsAnEventHandler(this); } @@ -58,11 +60,6 @@ public WishDetailPanel() { */ public void loadDefaultPage() { name.setText("Click on any wish for details"); - price.setText(""); - savedAmount.setText(""); - url.setText(""); - email.setText(""); - remark.setText(""); } /** @@ -70,11 +67,26 @@ public void loadDefaultPage() { */ private void loadWishPage(Wish wish) { name.setText(wish.getName().fullName); - savedAmount.setText("Saved: $" + wish.getSavedAmount().toString()); - price.setText("Price: $" + wish.getPrice().toString()); - url.setText("Product URL: " + wish.getUrl().value); - email.setText("Date(?): " + wish.getDate()); - remark.setText(wish.getRemark().value); + initTags(wish); + } + + /** + * Returns the color style for {@code tagName}'s label. + */ + private String getTagColorStyleFor(String tagName) { + return TAG_COLORS[Math.abs(tagName.hashCode()) % TAG_COLORS.length]; + } + + /** + * Creates the tag labels for {@code wish}. + */ + private void initTags(Wish wish) { + tags.getChildren().clear(); + wish.getTags().forEach(tag -> { + Label tagLabel = new Label(tag.tagName); + tagLabel.getStyleClass().add(getTagColorStyleFor(tag.tagName)); + tags.getChildren().add(tagLabel); + }); } @Subscribe diff --git a/src/main/java/seedu/address/ui/WishDetailSavingAmount.java b/src/main/java/seedu/address/ui/WishDetailSavingAmount.java new file mode 100644 index 000000000000..19fa075d4b1e --- /dev/null +++ b/src/main/java/seedu/address/ui/WishDetailSavingAmount.java @@ -0,0 +1,57 @@ +package seedu.address.ui; + +import java.util.logging.Logger; + +import com.google.common.eventbus.Subscribe; + +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.layout.Region; +import seedu.address.commons.core.LogsCenter; +import seedu.address.commons.events.ui.WishPanelSelectionChangedEvent; +import seedu.address.model.wish.Wish; + +/** + * Panel containing the detail of wish. + */ +public class WishDetailSavingAmount extends UiPart { + + private static final String FXML = "WishDetailSavingAmount.fxml"; + + private final Logger logger = LogsCenter.getLogger(getClass()); + + @FXML + private Label price; + + @FXML + private Label savedAmount; + + public WishDetailSavingAmount() { + super(FXML); + + loadDefaultDetails(); + registerAsAnEventHandler(this); + } + + /** + * Load the default page. + */ + public void loadDefaultDetails() { + price.setText(""); + savedAmount.setText(""); + } + + /** + * Load the page that shows the detail of wish. + */ + private void loadWishDetails(Wish wish) { + savedAmount.setText("$" + wish.getSavedAmount().toString()); + price.setText("/ $" + wish.getPrice().toString()); + } + + @Subscribe + private void handleWishPanelSelectionChangedEvent(WishPanelSelectionChangedEvent event) { + logger.info(LogsCenter.getEventHandlingLogMessage(event)); + loadWishDetails(event.getNewSelection()); + } +} diff --git a/src/main/java/seedu/address/ui/WishDetailSavingHistory.java b/src/main/java/seedu/address/ui/WishDetailSavingHistory.java new file mode 100644 index 000000000000..59adf7e3fd63 --- /dev/null +++ b/src/main/java/seedu/address/ui/WishDetailSavingHistory.java @@ -0,0 +1,39 @@ +package seedu.address.ui; + +import java.util.logging.Logger; + +import com.google.common.eventbus.Subscribe; + +import javafx.fxml.FXML; +import javafx.scene.layout.Region; +import seedu.address.commons.core.LogsCenter; +import seedu.address.commons.events.ui.WishPanelSelectionChangedEvent; +import seedu.address.model.wish.Wish; + +/** + * Panel containing the detail of wish. + */ +public class WishDetailSavingHistory extends UiPart { + + private static final String FXML = "WishDetailSavingHistory.fxml"; + + private final Logger logger = LogsCenter.getLogger(getClass()); + + public WishDetailSavingHistory() { + super(FXML); + + registerAsAnEventHandler(this); + } + + /** + * Load the page that shows the detail of wish. + */ + private void loadWishDetails(Wish wish) { + } + + @Subscribe + private void handleWishPanelSelectionChangedEvent(WishPanelSelectionChangedEvent event) { + logger.info(LogsCenter.getEventHandlingLogMessage(event)); + loadWishDetails(event.getNewSelection()); + } +} diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css index faeb277be80f..80752eab0044 100644 --- a/src/main/resources/view/DarkTheme.css +++ b/src/main/resources/view/DarkTheme.css @@ -31,6 +31,13 @@ -fx-padding: 0 0 30 0; } +.detail_sub_title_label { + -fx-font-family: "Segoe UI Semibold"; + -fx-font-size: 22px; + -fx-text-fill: #ffffff; + -fx-padding: 15 0 15 0; +} + .detail_label { -fx-font-family: "Segoe UI Semibold"; -fx-font-size: 16px; @@ -38,6 +45,20 @@ -fx-padding: 15 0 15 0; } +.saving_amount_label { + -fx-font-family: "Segoe UI Bold"; + -fx-font-size: 50px; + -fx-text-fill: #2EE298; + -fx-padding: 15 0 15 0; +} + +.price_label { + -fx-font-family: "Segoe UI Semibold"; + -fx-font-size: 20px; + -fx-text-fill: #ffffff; + -fx-padding: 33 0 15 0; +} + .text-field { -fx-font-size: 12pt; -fx-font-family: "Segoe UI Semibold"; @@ -145,12 +166,6 @@ -fx-text-fill: #ffffff; } -.cell_big_label_expired { - -fx-font-family: "Segoe UI Bold"; - -fx-font-size: 16px; - -fx-text-fill: #ff0000; -} - .cell_big_green_label { -fx-font-family: "Segoe UI Bold"; -fx-font-size: 16px; @@ -163,6 +178,12 @@ -fx-text-fill: #010504; } +.cell_big_label_expired { + -fx-font-family: "Segoe UI Bold"; + -fx-font-size: 16px; + -fx-text-fill: #ff0000; +} + .cell_small_white_label { -fx-font-family: "Segoe UI"; -fx-font-size: 13px; @@ -448,4 +469,4 @@ #tags .black { -fx-background-color: black; -} +} \ No newline at end of file diff --git a/src/main/resources/view/WishDetailPanel.fxml b/src/main/resources/view/WishDetailPanel.fxml index cf8753136437..12429c9bd2d6 100644 --- a/src/main/resources/view/WishDetailPanel.fxml +++ b/src/main/resources/view/WishDetailPanel.fxml @@ -6,6 +6,7 @@ + @@ -14,19 +15,22 @@ - + - - diff --git a/src/main/resources/view/WishDetailSavingAmount.fxml b/src/main/resources/view/WishDetailSavingAmount.fxml new file mode 100644 index 000000000000..e7380b98bed2 --- /dev/null +++ b/src/main/resources/view/WishDetailSavingAmount.fxml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/view/WishDetailSavingHistory.fxml b/src/main/resources/view/WishDetailSavingHistory.fxml new file mode 100644 index 000000000000..2eddeb6f4376 --- /dev/null +++ b/src/main/resources/view/WishDetailSavingHistory.fxml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + From 36a2d1a553379d1a06e0ff529d0a1bf93005725b Mon Sep 17 00:00:00 2001 From: jiholim Date: Tue, 23 Oct 2018 17:16:36 +0800 Subject: [PATCH 2/4] Edit WishCard --- src/main/java/seedu/address/ui/WishCard.java | 4 ---- src/main/resources/view/WishCard.fxml | 1 - 2 files changed, 5 deletions(-) diff --git a/src/main/java/seedu/address/ui/WishCard.java b/src/main/java/seedu/address/ui/WishCard.java index 7c43e7b31f64..63b7e0cba0a0 100644 --- a/src/main/java/seedu/address/ui/WishCard.java +++ b/src/main/java/seedu/address/ui/WishCard.java @@ -37,9 +37,6 @@ public class WishCard extends UiPart { @FXML private Label progress; - @FXML - private Label date; - @FXML private ProgressBar progressBar; @@ -55,7 +52,6 @@ public WishCard(Wish wish, int displayedIndex) { this.id = displayedIndex + ". "; name.setText(wish.getName().fullName); - date.setText(wish.getDate().date); progress.setText(getProgressInString(wish)); progressBar.setProgress(wish.getProgress()); diff --git a/src/main/resources/view/WishCard.fxml b/src/main/resources/view/WishCard.fxml index e9ab730e70a7..f8fdfeeba204 100644 --- a/src/main/resources/view/WishCard.fxml +++ b/src/main/resources/view/WishCard.fxml @@ -24,7 +24,6 @@