-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update PersonCardFields to use Icons #118
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,11 +54,11 @@ public PersonCard(Person person, int displayedIndex) { | |
} | ||
private void createFields() { | ||
name.setText(person.getName().fullName); | ||
phone.setText("Phone:", person.getPhone().value); | ||
address.setText("Address:", person.getAddress().value); | ||
email.setText("Email:", person.getEmail().value); | ||
job.setText("Job:", person.getJob().value); | ||
income.setText("Income:", person.getIncome().toString()); | ||
phone.setFields("fas-phone-alt", person.getPhone().value); | ||
address.setFields("fas-building", person.getAddress().value); | ||
email.setFields("fas-envelope", person.getEmail().value); | ||
job.setFields("fas-briefcase", person.getJob().value); | ||
income.setFields("fas-dollar-sign", person.getIncome().toString()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider standardizing icon variable names based on their semantic usage rather than the default names! For example, instead of: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @colinhia Could you open an issue for this? Seems like a useful change but not a priority! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That does sound like a great idea! Will open an issue for this, thanks for the suggestion! |
||
remark.setText(person.getRemark().value); | ||
cardFields.getChildren().addAll(phone, address, email, job, income); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,47 @@ | ||
package seedu.address.ui; | ||
|
||
import org.kordamp.ikonli.javafx.FontIcon; | ||
|
||
import javafx.geometry.Pos; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.Priority; | ||
import javafx.scene.paint.Paint; | ||
|
||
/** | ||
* Represents a labelled field in the PersonCard | ||
*/ | ||
public class PersonCardField extends HBox { | ||
private Label field; | ||
private FontIcon icon; | ||
private Label value; | ||
|
||
/** | ||
* Creates a template {@code PersonCardField} to display. | ||
*/ | ||
public PersonCardField() { | ||
super(5); | ||
field = new Label(); | ||
field.setStyle("-fx-font-weight: bold;"); | ||
icon = new FontIcon(); | ||
icon.setIconColor(Paint.valueOf("darkgray")); | ||
|
||
HBox iconWrapper = new HBox(); | ||
iconWrapper.setPrefWidth(20); | ||
iconWrapper.setAlignment(Pos.CENTER); | ||
iconWrapper.getChildren().add(icon); | ||
|
||
value = new Label(); | ||
HBox.setHgrow(value, Priority.ALWAYS); | ||
value.setWrapText(true); | ||
getChildren().addAll(field, value); | ||
getChildren().addAll(iconWrapper, value); | ||
} | ||
|
||
/** | ||
* Updates the {@code Label} {@code field} and {@code value} with the corresponding strings. | ||
* @param fieldText The String to be updated into field. | ||
* @param valueText The String to be updated in value. | ||
* Updates the {@code PersonCardField} {@code Icon} and {@code Value} with the corresponding strings. | ||
* | ||
* @param iconLiteral The IconLiteral to be set for the icon. | ||
* @param valueText The String to be updated in value. | ||
*/ | ||
public void setText(String fieldText, String valueText) { | ||
this.field.setText(fieldText); | ||
public void setFields(String iconLiteral, String valueText) { | ||
this.icon.setIconLiteral(iconLiteral); | ||
this.value.setText(valueText); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the use of icon pack package!!