forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from colinhia/A-UI-Field-Labels
Update PersonCardFields to use Icons
- Loading branch information
Showing
3 changed files
with
29 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |