Skip to content

Commit

Permalink
Use box to set visibility of copy button
Browse files Browse the repository at this point in the history
  • Loading branch information
axpoems committed Jun 18, 2024
1 parent 1f65a2f commit ac1edd9
Showing 1 changed file with 18 additions and 17 deletions.
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 @@ -262,17 +262,17 @@ private View(Model model, Controller controller) {

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

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

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

Expand Down Expand Up @@ -364,15 +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 @@ -409,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 @@ -430,9 +429,11 @@ 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");

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

0 comments on commit ac1edd9

Please sign in to comment.