Skip to content

Commit

Permalink
Merge pull request #50 from wfxronald/W6
Browse files Browse the repository at this point in the history
Small UI Improvement
  • Loading branch information
wfxronald authored Mar 5, 2019
2 parents fb9ad30 + ea64a3f commit 9cf2cda
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
28 changes: 27 additions & 1 deletion src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,33 @@ public PersonCard(Person person, int displayedIndex) {
phone.setText(person.getPhone().value);
address.setText(person.getAddress().value);
email.setText(person.getEmail().value);
person.getTags().forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
createTag(person);

}
/**
* Chooses a random colour for {@code tag}'s label
*/
private String chooseRandomColourFor(String tag) {
String[] listOfColours = { "blue", "red", "yellow", "green", "orange", "black", "white"};

// Generate a random colour that will be consistent for the same tag, based on the value of the string
int valueOfString = 0;
for (char character : tag.toCharArray()) {
valueOfString += (int) character;
}

return listOfColours[valueOfString % 7];
}

/**
* Creates a coloured tag label for {@code Person}
*/
private void createTag(Person person) {
person.getTags().forEach(tag -> {
Label newTag = new Label(tag.tagName);
newTag.getStyleClass().add(chooseRandomColourFor(tag.tagName));
tags.getChildren().add(newTag);
});
}

@Override
Expand Down
37 changes: 35 additions & 2 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,43 @@
}

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

#tags .blue {
-fx-text-fill: white;
-fx-background-color: #127a9c;
}

#tags .red {
-fx-text-fill: white;
-fx-background-color: #d60d0d;
}

#tags .yellow {
-fx-text-fill: black;
-fx-background-color: #eecc00;
}

#tags .green {
-fx-text-fill: white;
-fx-background-color: #0da507;
}

#tags .orange {
-fx-text-fill: black;
-fx-background-color: #ffa700;
}

#tags .black {
-fx-text-fill: white;
-fx-background-color: #000000;
}

#tags .white {
-fx-text-fill: black;
-fx-background-color: #ffffff;
}

0 comments on commit 9cf2cda

Please sign in to comment.