Skip to content

Commit

Permalink
Merge pull request #2312 from axpoems/misc-improvements
Browse files Browse the repository at this point in the history
Peer message and user porfile siderbar improvements
  • Loading branch information
djing-chan authored Jun 19, 2024
2 parents 8ba00e0 + 73fa57f commit 959634f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ protected void setUpReactions() {
copyIcon = getIconWithToolTip(AwesomeIcon.COPY, Res.get("action.copyToClipboard"));

// More options dropdown menu
ignoreUserMenuItem = new DropdownMenuItem(Res.get("chat.message.contextMenu.ignoreUser"));
reportUserMenuItem = new DropdownMenuItem(Res.get("chat.message.contextMenu.reportUser"));
ignoreUserMenuItem = new DropdownMenuItem("ignore-grey", "ignore-white",
Res.get("chat.message.contextMenu.ignoreUser"));
reportUserMenuItem = new DropdownMenuItem("report-grey", "report-white",
Res.get("chat.message.contextMenu.reportUser"));
moreOptionsMenu = new DropdownMenu("ellipsis-h-grey", "ellipsis-h-white", true);
moreOptionsMenu.setTooltip(Res.get("chat.message.moreOptions"));
moreOptionsMenu.addMenuItems(ignoreUserMenuItem, reportUserMenuItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public static class View extends bisq.desktop.common.view.View<VBox, Model, Cont
private final Label nickName, botId, userId, addressByTransport, statement, totalReputationScore,
profileAge, lastSeen, terms;
private final MenuItem privateMsg, mention, ignore, undoIgnore, report;
private final VBox statementBox, termsBox, optionsVBox;
private final VBox botIdBox, userIdBox, addressByTransportBox, statementBox, termsBox, optionsVBox;
private final ReputationScoreDisplay reputationScoreDisplay;
private final BisqIconButton botIdCopyButton, userIdCopyButton, addressByTransportCopyButton;
private final Button closeButton;
Expand Down Expand Up @@ -261,23 +261,20 @@ private View(Model model, Controller controller) {
VBox.setMargin(reputationScoreDisplay, new Insets(0, 0, 5, 0));

// User details
Triple<Label, Label, VBox> botIdTriple = getInfoBox(Res.get("chat.sideBar.userProfile.nym"));
VBox botIdBox = botIdTriple.getThird();
botIdCopyButton = createAndGetCopyButton();
botId = botIdTriple.getSecond();
botId.setGraphic(botIdCopyButton);

Triple<Label, Label, VBox> userIdTriple = getInfoBox(Res.get("chat.sideBar.userProfile.id"));
VBox userIdBox = userIdTriple.getThird();
userIdCopyButton = createAndGetCopyButton();
userId = userIdTriple.getSecond();
userId.setGraphic(userIdCopyButton);

Triple<Label, Label, VBox> addressByTransportTriple = getInfoBox(Res.get("chat.sideBar.userProfile.transportAddress"));
VBox addressByTransportBox = addressByTransportTriple.getThird();
addressByTransportCopyButton = createAndGetCopyButton();
addressByTransport = addressByTransportTriple.getSecond();
addressByTransport.setGraphic(addressByTransportCopyButton);
Triple<Label, BisqIconButton, VBox> botIdTriple = getInfoBoxWithCopyButton(Res.get("chat.sideBar.userProfile.nym"));
botIdBox = botIdTriple.getThird();
botIdCopyButton = botIdTriple.getSecond();
botId = botIdTriple.getFirst();

Triple<Label, BisqIconButton, VBox> userIdTriple = getInfoBoxWithCopyButton(Res.get("chat.sideBar.userProfile.id"));
userIdBox = userIdTriple.getThird();
userIdCopyButton = userIdTriple.getSecond();
userId = userIdTriple.getFirst();

Triple<Label, BisqIconButton, VBox> addressByTransportTriple = getInfoBoxWithCopyButton(Res.get("chat.sideBar.userProfile.transportAddress"));
addressByTransportBox = addressByTransportTriple.getThird();
addressByTransportCopyButton = addressByTransportTriple.getSecond();
addressByTransport = addressByTransportTriple.getFirst();

Triple<Label, Label, VBox> totalReputationScoreTriple = getInfoBox(Res.get("chat.sideBar.userProfile.totalReputationScore"));
VBox totalReputationScoreBox = totalReputationScoreTriple.getThird();
Expand Down Expand Up @@ -367,14 +364,14 @@ protected void onViewAttached() {
}
});

botId.setOnMouseEntered(e -> botIdCopyButton.setVisible(true));
botId.setOnMouseExited(e -> botIdCopyButton.setVisible(false));
botIdBox.setOnMouseEntered(e -> botIdCopyButton.setVisible(true));
botIdBox.setOnMouseExited(e -> botIdCopyButton.setVisible(false));
botIdCopyButton.setOnMouseClicked(e -> ClipboardUtil.copyToClipboard(model.getUserProfile().getNym()));
userId.setOnMouseEntered(e -> userIdCopyButton.setVisible(true));
userId.setOnMouseExited(e -> userIdCopyButton.setVisible(false));
userIdBox.setOnMouseEntered(e -> userIdCopyButton.setVisible(true));
userIdBox.setOnMouseExited(e -> userIdCopyButton.setVisible(false));
userIdCopyButton.setOnMouseClicked(e -> ClipboardUtil.copyToClipboard(model.getUserProfile().getId()));
addressByTransport.setOnMouseEntered(e -> addressByTransportCopyButton.setVisible(true));
addressByTransport.setOnMouseExited(e -> addressByTransportCopyButton.setVisible(false));
addressByTransportBox.setOnMouseEntered(e -> addressByTransportCopyButton.setVisible(true));
addressByTransportBox.setOnMouseExited(e -> addressByTransportCopyButton.setVisible(false));
addressByTransportCopyButton.setOnMouseClicked(e ->
ClipboardUtil.copyToClipboard(model.getUserProfile().getAddressByTransportDisplayString()));

Expand Down Expand Up @@ -411,14 +408,14 @@ protected void onViewDetached() {

catHashNodeSubscription.unsubscribe();

botId.setOnMouseEntered(null);
botId.setOnMouseExited(null);
botIdBox.setOnMouseEntered(null);
botIdBox.setOnMouseExited(null);
botIdCopyButton.setOnMouseClicked(null);
userId.setOnMouseEntered(null);
userId.setOnMouseExited(null);
userIdBox.setOnMouseEntered(null);
userIdBox.setOnMouseExited(null);
userIdCopyButton.setOnMouseClicked(null);
addressByTransport.setOnMouseEntered(null);
addressByTransport.setOnMouseExited(null);
addressByTransportBox.setOnMouseEntered(null);
addressByTransportBox.setOnMouseExited(null);
addressByTransportCopyButton.setOnMouseClicked(null);

privateMsg.setOnAction(null);
Expand All @@ -432,19 +429,35 @@ protected void onViewDetached() {
private static Triple<Label, Label, VBox> getInfoBox(String title) {
Label headline = new Label(title.toUpperCase());
headline.getStyleClass().add("chat-side-bar-user-profile-small-headline");

Label value = new Label();
value.setWrapText(true);
value.getStyleClass().add("chat-side-bar-user-profile-small-value");
value.setContentDisplay(ContentDisplay.RIGHT);

VBox vBox = new VBox(2.5, headline, value);
return new Triple<>(headline, value, vBox);
}

private static BisqIconButton createAndGetCopyButton() {
private static Triple<Label, BisqIconButton, VBox> getInfoBoxWithCopyButton(String title) {
Label headline = new Label(title.toUpperCase());
headline.getStyleClass().add("chat-side-bar-user-profile-small-headline");

Label value = new Label();
value.setWrapText(true);
value.getStyleClass().add("chat-side-bar-user-profile-small-value");
value.setContentDisplay(ContentDisplay.RIGHT);

BisqIconButton copyButton = new BisqIconButton();
copyButton.setIcon(AwesomeIcon.COPY);
copyButton.setVisible(false);
return copyButton;
copyButton.setMinWidth(30);
copyButton.setAlignment(Pos.BOTTOM_RIGHT);
HBox.setMargin(copyButton, new Insets(0, 0, 5, 0));

HBox hBox = new HBox(value, Spacer.fillHBox(), copyButton);
hBox.setAlignment(Pos.BOTTOM_LEFT);
VBox vBox = new VBox(2.5, headline, hBox);
return new Triple<>(value, copyButton, vBox);
}
}
}

0 comments on commit 959634f

Please sign in to comment.