Skip to content

Commit

Permalink
Merge pull request #96 from CFSY/ui
Browse files Browse the repository at this point in the history
Improve UI
  • Loading branch information
CFSY authored Oct 25, 2022
2 parents 08d9f6d + f135846 commit d21dc47
Show file tree
Hide file tree
Showing 19 changed files with 163 additions and 110 deletions.
11 changes: 8 additions & 3 deletions src/main/java/seedu/waddle/model/itinerary/Date.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static java.util.Objects.requireNonNull;
import static seedu.waddle.commons.util.AppUtil.checkArgument;

import java.time.LocalDate;

/**
* Represents an Itinerary's Date.
* Guarantees: immutable; is valid as declared in {@link #isValidDate(String)}
Expand All @@ -19,7 +21,7 @@ public class Date {
*/
public static final String VALIDATION_REGEX = "\\d{4}-\\d{2}-\\d{2}";

public final String date;
public final LocalDate date;

/**
* Constructs a {@code Name}.
Expand All @@ -29,7 +31,7 @@ public class Date {
public Date(String date) {
requireNonNull(date);
checkArgument(isValidDate(date), MESSAGE_CONSTRAINTS);
this.date = date;
this.date = LocalDate.parse(date);
}

/**
Expand All @@ -39,10 +41,13 @@ public static boolean isValidDate(String test) {
return test.matches(VALIDATION_REGEX);
}

public LocalDate getValue() {
return this.date;
}

@Override
public String toString() {
return date;
return date.toString();
}

@Override
Expand Down
39 changes: 27 additions & 12 deletions src/main/java/seedu/waddle/model/itinerary/Itinerary.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ public ItineraryDuration getDuration() {
return this.duration;
}

public String getTimeString() {
if (this.startDate != null) {
if (this.duration != null) {
return this.startDate + " - " + this.startDate.getValue().plusDays(this.duration.getValue());
} else {
return this.startDate.toString();
}
}
return "(Not planned)";
}

public People getPeople() {
return people;
}
Expand All @@ -90,6 +101,18 @@ public List<Day> getDays() {
return this.days;
}

public void setDays(List<Day> dayList) {
for (int i = 0; i < dayList.size(); i++) {
if (i < getDuration().getValue()) {
this.days.set(i, dayList.get(i));
} else {
for (Item item : dayList.get(i).deleteDay()) {
addItem(item);
}
}
}
}

/**
* Returns true if both itineraries have the same name.
* This defines a weaker notion of equality between two itineraries.
Expand All @@ -109,6 +132,7 @@ public boolean hasItem(Item item) {

/**
* Add item into itinerary.
*
* @param item Item to be added.
*/
public void addItem(Item item) {
Expand All @@ -118,6 +142,7 @@ public void addItem(Item item) {

/**
* Remove item from itinerary.
*
* @param index A MultiIndex specifying position of task.
* @return The item to be removed.
*/
Expand Down Expand Up @@ -160,6 +185,7 @@ private void sortUnscheduledItemList() {

/**
* Unplan an item.
*
* @param index A multiIndex to locate the day and index of task within the day
*/
public Item unplanItem(MultiIndex index) {
Expand All @@ -173,6 +199,7 @@ public Item unplanItem(MultiIndex index) {

/**
* Plan an item.
*
* @param itemIndex Index of item in unscheduled list.
* @param dayNumber Day to include this item.
* @param startTime startTime of the item.
Expand Down Expand Up @@ -257,18 +284,6 @@ public String toString() {
return builder.toString();
}

public void setDays(List<Day> dayList) {
for (int i = 0; i < dayList.size(); i++) {
if (i < getDuration().getValue()) {
this.days.set(i, dayList.get(i));;
} else {
for (Item item : dayList.get(i).deleteDay()) {
addItem(item);
}
}
}
}

public void setSpending(Budget budget) {
this.budget.setSpending(budget.getSpending());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public JsonAdaptedItinerary(@JsonProperty("name") String name, @JsonProperty("co
public JsonAdaptedItinerary(Itinerary source) {
name = source.getName().fullName;
country = source.getCountry().country;
startDate = source.getStartDate().date;
startDate = source.getStartDate().date.toString();
duration = source.getDuration().toString();
people = source.getPeople().numOfPeople;
budget = source.getBudget().toString();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/waddle/ui/ItemCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public ItemCard(Item item, int dayNumber, int displayedIndex) {
this.id.setText(displayedIndex + ". ");
}
this.description.setText(item.getDescription());
this.priority.setText("Stars: " + item.getPriority().getStars());
this.duration.setText("Duration: " + item.getDuration());
this.priority.setText("★".repeat(item.getPriority().getStars()));
this.duration.setText("Duration: " + item.getDuration() + " mins");
this.time.setText("Time: " + item.getTimeString());
this.cost.setText("Cost: " + item.getCost().getValue());
this.cost.setText("Cost: $" + item.getCost().getValue());
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/seedu/waddle/ui/ItemGroupCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ItemGroupCard extends UiPart<Region> {
public final ObservableList<Item> itemGroup;

@FXML
private Label id;
private Label dayNumber;
@FXML
private StackPane itemListPanelPlaceholder;

Expand All @@ -36,9 +36,9 @@ public ItemGroupCard(ObservableList<Item> itemGroup, int dayNumber) {
super(FXML);
this.itemGroup = itemGroup;
if (dayNumber == 0) {
this.id.setText("Wishlist");
this.dayNumber.setText("Wishlist");
} else {
this.id.setText("Day " + dayNumber);
this.dayNumber.setText("Day " + dayNumber);
}
this.itemListPanelPlaceholder.getChildren().add(new ItemListPanel(itemGroup, dayNumber).getRoot());
this.itemListPanelPlaceholder.setMinHeight(UiSizes.ITEM_LIST_MIN_HEIGHT);
Expand All @@ -58,7 +58,7 @@ public boolean equals(Object other) {

// state check
ItemGroupCard card = (ItemGroupCard) other;
return id.getText().equals(card.id.getText())
return dayNumber.getText().equals(card.dayNumber.getText())
&& itemGroup.equals(card.itemGroup);
}
}
12 changes: 6 additions & 6 deletions src/main/java/seedu/waddle/ui/ItineraryCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public class ItineraryCard extends UiPart<Region> {
@FXML
private Label country;
@FXML
private Label startDate;
@FXML
private Label duration;
@FXML
private Label time;
@FXML
private Label people;


Expand All @@ -47,10 +47,10 @@ public ItineraryCard(Itinerary itinerary, int displayedIndex) {
this.itinerary = itinerary;
id.setText(displayedIndex + ". ");
name.setText(itinerary.getName().fullName);
country.setText(itinerary.getCountry().country);
startDate.setText(itinerary.getStartDate().date);
duration.setText(itinerary.getDuration().toString());
people.setText(itinerary.getPeople().numOfPeople);
country.setText("Country: " + itinerary.getCountry().country);
time.setText("Dates: " + itinerary.getTimeString());
duration.setText("Duration: " + itinerary.getDuration().toString() + " Days");
people.setText("Waddlers: " + itinerary.getPeople().numOfPeople);
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/waddle/ui/ResultDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public ResultDisplay() {
public void setFeedbackToUser(String feedbackToUser) {
requireNonNull(feedbackToUser);
resultDisplay.setText(feedbackToUser);
resultDisplay.setWrapText(true);
}

}
2 changes: 1 addition & 1 deletion src/main/java/seedu/waddle/ui/UiSizes.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* Standard sizes for UI elements.
*/
public class UiSizes {
public static final double ITEM_CARD_HEIGHT = 120;
public static final double ITEM_CARD_HEIGHT = 130;
public static final double ITEM_LIST_MIN_HEIGHT = 20;
}
Loading

0 comments on commit d21dc47

Please sign in to comment.