Added name displaying of groupMessages in groupChats
This commit is contained in:
parent
01f81fadac
commit
79a121b6b5
@ -15,10 +15,12 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
import envoy.client.ui.AudioControl;
|
||||
import envoy.client.ui.IconUtil;
|
||||
import envoy.data.GroupMessage;
|
||||
import envoy.data.Message;
|
||||
import envoy.data.Message.MessageStatus;
|
||||
import envoy.data.User;
|
||||
@ -51,7 +53,28 @@ public class MessageControl extends Label {
|
||||
*/
|
||||
public MessageControl(Message message) {
|
||||
// Creating the underlying VBox and the dateLabel
|
||||
final var vbox = new VBox(new Label(dateFormat.format(message.getCreationDate())));
|
||||
final var hbox = new HBox();
|
||||
if (message.getSenderID() != client.getID() && message instanceof GroupMessage) {
|
||||
client.getContacts()
|
||||
.stream()
|
||||
.filter(c -> c instanceof User)
|
||||
.filter(c -> c.getID() == message.getSenderID())
|
||||
.findFirst()
|
||||
.ifPresentOrElse(c -> {
|
||||
Label label = new Label(c.getName() + " ");
|
||||
label.getStyleClass().add("groupMemberNames");
|
||||
hbox.getChildren().add(label);
|
||||
}, () -> {
|
||||
Label label = new Label("Unknown User ");
|
||||
label.getStyleClass().add("groupMemberNames");
|
||||
hbox.getChildren().add(label);
|
||||
});
|
||||
// TODO improve offline login (contacts list is empty when logging in offline)
|
||||
// TODO when contact is added, unknown user has to change immediately to the
|
||||
// name, not only after relogging
|
||||
}
|
||||
hbox.getChildren().add(new Label(dateFormat.format(message.getCreationDate())));
|
||||
final var vbox = new VBox(hbox);
|
||||
|
||||
// Creating the actions for the MenuItems
|
||||
final ContextMenu contextMenu = new ContextMenu();
|
||||
|
@ -53,3 +53,8 @@
|
||||
#messageEnterContainer {
|
||||
-fx-background-color: #363636;
|
||||
}
|
||||
|
||||
.groupMemberNames {
|
||||
-fx-text-fill: rgb(105.0,0.0,153.0);
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user