Skip to content

Commit

Permalink
Merge pull request #28 from bachletuankhai/branch-UI-update
Browse files Browse the repository at this point in the history
Branch UI update
  • Loading branch information
dhlee03 authored Mar 21, 2024
2 parents dcba189 + 438db10 commit f8baace
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 223 deletions.
12 changes: 6 additions & 6 deletions src/main/java/seedu/address/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ public class SampleDataUtil {
public static Person[] getSamplePersons() {
return new Person[] {
new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("[email protected]"),
new Address("Blk 30 Geylang Street 29, #06-40"), new Category("participant"),
new Address("Blk 30 Geylang Street 29, #06-40"), new Category("PARTICIPANT"),
getTagSet("friends")),
new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("[email protected]"),
new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), new Category("participant"),
new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), new Category("PARTICIPANT"),
getTagSet("colleagues", "friends")),
new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("[email protected]"),
new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), new Category("participant"),
new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), new Category("PARTICIPANT"),
getTagSet("neighbours")),
new Person(new Name("David Li"), new Phone("91031282"), new Email("[email protected]"),
new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), new Category("participant"),
new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), new Category("PARTICIPANT"),
getTagSet("family")),
new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("[email protected]"),
new Address("Blk 47 Tampines Street 20, #17-35"), new Category("participant"),
new Address("Blk 47 Tampines Street 20, #17-35"), new Category("PARTICIPANT"),
getTagSet("classmates")),
new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("[email protected]"),
new Address("Blk 45 Aljunied Street 85, #11-31"), new Category("participant"),
new Address("Blk 45 Aljunied Street 85, #11-31"), new Category("PARTICIPANT"),
getTagSet("colleagues"))
};
}
Expand Down
28 changes: 13 additions & 15 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package seedu.address.ui;

import java.util.Comparator;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.address.model.person.Category;
import seedu.address.model.person.Person;

/**
Expand All @@ -17,11 +15,13 @@ public class PersonCard extends UiPart<Region> {
private static final String FXML = "PersonListCard.fxml";

/**
* Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX.
* Note: Certain keywords such as "location" and "resources" are reserved
* keywords in JavaFX.
* As a consequence, UI elements' variable names cannot be set to such keywords
* or an exception will be thrown by JavaFX during runtime.
*
* @see <a href="https://github.com/se-edu/addressbook-level4/issues/336">The issue on AddressBook level 4</a>
* @see <a href="https://github.com/se-edu/addressbook-level4/issues/336">The
* issue on AddressBook level 4</a>
*/

public final Person person;
Expand All @@ -35,28 +35,26 @@ public class PersonCard extends UiPart<Region> {
@FXML
private Label phone;
@FXML
private Label address;
@FXML
private Label email;
@FXML
private Label category;
@FXML
private FlowPane tags;

/**
* Creates a {@code PersonCode} with the given {@code Person} and index to display.
* Creates a {@code PersonCode} with the given {@code Person} and index to
* display.
*/
public PersonCard(Person person, int displayedIndex) {
super(FXML);
this.person = person;
id.setText(displayedIndex + ". ");
id.setText(displayedIndex + "");
name.setText(person.getName().fullName);
phone.setText(person.getPhone().value);
address.setText(person.getAddress().value);
email.setText(person.getEmail().value);
category.setText(person.getCategory().value);
person.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
category.getStyleClass().add(getCategoryStyleClass(person.getCategory()));
}

private String getCategoryStyleClass(Category category) {
return "category-label-" + category.value.toLowerCase();
}
}
6 changes: 5 additions & 1 deletion src/main/resources/view/CommandBox.fxml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.StackPane?>

<StackPane styleClass="stack-pane" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<StackPane styleClass="round-container" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<padding>
<Insets top="1" right="3" bottom="1" left="3" />
</padding>
<TextField fx:id="commandTextField" onAction="#handleCommandEntered" promptText="Enter command here..."/>
</StackPane>

Loading

0 comments on commit f8baace

Please sign in to comment.