Skip to content

Commit

Permalink
Change add to the right pane
Browse files Browse the repository at this point in the history
  • Loading branch information
SHni99 committed Mar 24, 2023
1 parent 841cd7e commit 26f37b1
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 28 deletions.
8 changes: 8 additions & 0 deletions src/main/java/seedu/address/model/tag/CommitmentTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ public CommitmentTag(String tagName) {
super(tagName);
}

/**
* @return the corresponding color code for css
*/
@Override
public String tagColor() {
return "#f88379";
}

@Override
public boolean equals(Object other) {
return other == this
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/seedu/address/model/tag/ModuleTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ public boolean equals(Object other) {
&& tagName.equals(((ModuleTag) other).tagName));
}

/**
* @return the corresponding color code for css
*/
@Override
public String tagColor() {
return "#006400";
}

@Override
public String toString() {
return " [Module: " + tagName.split("XXXXX")[1] + "] ";
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/seedu/address/model/tag/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@ public static boolean isValidTagName(String test) {
return test.matches(VALIDATION_REGEX);
}

/**
* @return the corresponding color code for css
*/
public String tagColor() {
return "#3e7b91";
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof Tag // instanceof handles nulls
&& tagName.equals(((Tag) other).tagName)); // state check
|| (other instanceof Tag // instanceof handles nulls
&& tagName.equals(((Tag) other).tagName)); // state check
}

@Override
Expand Down
35 changes: 11 additions & 24 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,10 @@ public PersonCard(Person person, int displayedIndex, Logic logic, MainWindow mai
.forEach(this::createLabel);
}

private String setColorType(String tagType) {
String str = "";

switch (tagType.split("XXXXX")[0]) {
case "Module":
str = "#006400";
break;
case "Commitment":
str = "#f88379";
break;
default:
str = "#3e7b91";
}
return str;
}

/**
* @param tagLabel shows the tag name
* @return the input string with the front indicator removed
*/
private String setLabel(String tagLabel) {
String[] parts = tagLabel.split("XXXXX");
String str = "";
Expand All @@ -111,16 +99,15 @@ private String setLabel(String tagLabel) {
return str;
}


/**
* Creates labels based on the types to be displayed.
*
* @param tag takes in a tag type to extract information from within
*/
private void createLabel(Tag tag) {
Label label = new Label(setLabel(tag.tagName));
String colour = setColorType(tag.tagName);
label.setStyle("-fx-text-fill: white;\n"
+ "-fx-padding: 1 3 1 3;\n"
+ "-fx-border-radius: 2;\n"
+ "-fx-background-radius: 2;\n"
+ "-fx-font-size: 11;\n"
+ "-fx-background-color: " + colour + ";");
String colour = tag.tagColor();
label.setStyle("-fx-background-color: " + colour + ";");
tags.getChildren().add(label);
}

Expand Down
21 changes: 19 additions & 2 deletions src/main/java/seedu/address/ui/PersonalPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.address.model.person.Person;
import seedu.address.model.tag.Tag;
import seedu.address.model.util.ImageUtil;

/**
Expand Down Expand Up @@ -69,7 +70,23 @@ public PersonalPane(Person person) {
address.setText(person.getAddress().value);
email.setText(person.getEmail().value);
person.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
.sorted(Comparator.comparing(tag -> tag.tagName))
.forEach(this::createLabel);

}

/**
* Creates labels based on the types to be displayed.
*
* @param tag takes in a tag type to extract information from within
*/
private void createLabel(Tag tag) {
Label label = new Label(tag.tagName.contains("XXXXX")
? tag.tagName.split("XXXXX")[1]
: tag.tagName);
String colour = tag.tagColor();
label.setStyle("-fx-background-color: " + colour + ";");
tags.getChildren().add(label);
}

}
8 changes: 8 additions & 0 deletions src/main/resources/view/Style.css
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,14 @@
-fx-vgap: 3;
}

#tags .label {
-fx-text-fill: white;
-fx-padding: 1 3 1 3;
-fx-border-radius: 2;
-fx-background-radius: 2;
-fx-font-size: 11;
}

#tagPane {
-fx-background-color: #C5C5C5;
-fx-min-height: 50;
Expand Down

0 comments on commit 26f37b1

Please sign in to comment.