Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY1819S1#68 from jiholim/master
Browse files Browse the repository at this point in the history
Restore UI for V1.2
  • Loading branch information
jiholim authored Oct 24, 2018
2 parents d50c323 + a28ce33 commit 70c453c
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 40 deletions.
4 changes: 0 additions & 4 deletions src/main/java/seedu/address/ui/WishCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public class WishCard extends UiPart<Region> {
@FXML
private Label progress;

@FXML
private Label date;

@FXML
private ProgressBar progressBar;

Expand All @@ -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());

Expand Down
54 changes: 33 additions & 21 deletions src/main/java/seedu/address/ui/WishDetailPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.WishTransaction;
Expand All @@ -20,26 +21,21 @@
public class WishDetailPanel extends UiPart<Region> {

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;
Expand All @@ -50,6 +46,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);

Expand All @@ -72,23 +74,33 @@ public WishDetailPanel(WishTransaction wishTransaction) {
*/
public void loadDefaultPage() {
name.setText("Click on any wish for details");
price.setText("");
savedAmount.setText("");
url.setText("");
email.setText("");
remark.setText("");
}

/**
* Load the page that shows the detail of wish.
*/
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
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/seedu/address/ui/WishDetailSavingAmount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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.NewResultAvailableEvent;
import seedu.address.commons.events.ui.WishPanelSelectionChangedEvent;
import seedu.address.model.wish.Wish;

/**
* Panel containing the detail of wish.
*/
public class WishDetailSavingAmount extends UiPart<Region> {

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

private final Logger logger = LogsCenter.getLogger(WishDetailSavingAmount.class);

@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());
}

@Subscribe
private void handleNewResultAvailableEvent(NewResultAvailableEvent event) {
logger.info("test" + event.message);
}
}
39 changes: 39 additions & 0 deletions src/main/java/seedu/address/ui/WishDetailSavingHistory.java
Original file line number Diff line number Diff line change
@@ -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<Region> {

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());
}
}
33 changes: 27 additions & 6 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,34 @@
-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;
-fx-text-fill: #ffffff;
-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";
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/view/WishCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
<GridPane>
<children>
<Label fx:id="name" text="\$first" styleClass="cell_big_label" GridPane.columnIndex="0" GridPane.rowIndex="0" />
<Label fx:id="date" text="\$first" styleClass="cell_small_white_label" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<Label fx:id="progress" text="\$progress" styleClass="cell_big_green_label" GridPane.halignment="RIGHT" GridPane.columnIndex="1" GridPane.rowIndex="2">
<Label fx:id="progress" text="\$progress" styleClass="cell_big_green_label" GridPane.halignment="RIGHT" GridPane.columnIndex="1" GridPane.rowIndex="0">
<minWidth>
<!-- Ensures that the label text is never truncated -->
<Region fx:constant="USE_PREF_SIZE" />
Expand Down
18 changes: 11 additions & 7 deletions src/main/resources/view/WishDetailPanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

Expand All @@ -14,19 +15,22 @@
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" />
</columnConstraints>
<VBox alignment="CENTER_LEFT" minHeight="105" GridPane.columnIndex="0">
<VBox minHeight="105" GridPane.columnIndex="0">
<padding>
<Insets top="20" right="10" bottom="10" left="15" />
</padding>
<HBox spacing="5" alignment="CENTER_LEFT">
<Label fx:id="name" text="\$first" styleClass="detail_title_label" />
</HBox>
<FlowPane fx:id="tags" />
<Label fx:id="savedAmount" styleClass="detail_label" text="\$savedAmount" />
<Label fx:id="price" styleClass="detail_label" text="\$price" />
<Label fx:id="url" styleClass="detail_label" text="\$url" />
<Label fx:id="email" styleClass="detail_label" text="\$email" />
<Label fx:id="remark" styleClass="detail_label" text="\$remark"/>
<FlowPane fx:id="tags">
<padding>
<Insets bottom="20" />
</padding>
</FlowPane>
<SplitPane id="wishDetailSplitPane" fx:id="splitPane" VBox.vgrow="ALWAYS">
<StackPane fx:id="wishSavingAmountPlaceholder" minWidth="300" prefWidth="300" SplitPane.resizableWithParent="false" />
<StackPane fx:id="wishSavingHistoryPlaceholder" minWidth="300" prefWidth="300" SplitPane.resizableWithParent="false" />
</SplitPane>
</VBox>
</GridPane>
</StackPane>
29 changes: 29 additions & 0 deletions src/main/resources/view/WishDetailSavingAmount.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.StackPane?>
<?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.VBox?>

<StackPane xmlns:fx="http://javafx.com/fxml/1">
<GridPane HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" />
</columnConstraints>
<VBox minHeight="300" GridPane.columnIndex="0">
<padding>
<Insets top="5" bottom="5" />
</padding>
<Label styleClass="detail_sub_title_label">
Amount Saved
</Label>
<HBox spacing="15" alignment="CENTER_LEFT">
<Label fx:id="savedAmount" styleClass="saving_amount_label" text="\$savedAmount" />
<Label fx:id="price" styleClass="price_label" text="\$price" />
</HBox>
</VBox>
</GridPane>
</StackPane>
25 changes: 25 additions & 0 deletions src/main/resources/view/WishDetailSavingHistory.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.StackPane?>
<?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.VBox?>

<StackPane xmlns:fx="http://javafx.com/fxml/1">
<GridPane HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" />
</columnConstraints>
<VBox minHeight="300" GridPane.columnIndex="0">
<padding>
<Insets top="5" bottom="5" />
</padding>
<Label styleClass="detail_sub_title_label">
Saving History
</Label>
</VBox>
</GridPane>
</StackPane>

0 comments on commit 70c453c

Please sign in to comment.