From 13f265122b764123cac29130d3727fa034b98f67 Mon Sep 17 00:00:00 2001 From: sqrrm Date: Thu, 6 Jun 2019 00:33:32 +0200 Subject: [PATCH] Add basic chat UI Very basic switch between chat and overview per trade, improvements needed on the UI. --- .../java/bisq/desktop/main/Chat/Chat.java | 20 +++++---- .../pendingtrades/PendingTradesView.java | 6 +-- .../portfolio/pendingtrades/TradeSubView.java | 44 ++++++++++++++----- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/Chat/Chat.java b/desktop/src/main/java/bisq/desktop/main/Chat/Chat.java index 918205cbe8b..373c829f22a 100644 --- a/desktop/src/main/java/bisq/desktop/main/Chat/Chat.java +++ b/desktop/src/main/java/bisq/desktop/main/Chat/Chat.java @@ -117,12 +117,15 @@ public class Chat extends AnchorPane { private TableGroupHeadline tableGroupHeadline; private VBox messagesInputBox; + // Options @Getter Button extraButton; @Getter private ReadOnlyDoubleProperty widthProperty; @Setter boolean allowAttachments; + @Setter + boolean displayHeader; // Communication stuff, to be renamed to something more generic private final P2PService p2PService; @@ -143,6 +146,7 @@ public Chat(ChatManager chatManager, BSFormatter formatter) { this.formatter = formatter; this.p2PService = chatManager.getP2PService(); allowAttachments = true; + displayHeader = true; } public void initialize() { @@ -215,6 +219,9 @@ public void display(ChatSession chatSession, @Nullable Button extraButton, sendMsgBusyAnimation = new BusyAnimation(false); + if (displayHeader) + this.getChildren().add(tableGroupHeadline); + if (chatSession.chatIsOpen()) { HBox buttonBox = new HBox(); buttonBox.setSpacing(10); @@ -241,17 +248,13 @@ public void display(ChatSession chatSession, @Nullable Button extraButton, AnchorPane.setBottomAnchor(messageListView, 120d); - this.getChildren().addAll(tableGroupHeadline, messageListView, messagesInputBox); - } else - - { + this.getChildren().addAll(messageListView, messagesInputBox); + } else { AnchorPane.setBottomAnchor(messageListView, 0d); - this.getChildren().addAll(tableGroupHeadline, messageListView); + this.getChildren().add(messageListView); } - messageListView.setCellFactory(new Callback<>() - - { + messageListView.setCellFactory(new Callback<>() { @Override public ListCell call(ListView list) { return new ListCell<>() { @@ -720,6 +723,7 @@ public void setInputBoxVisible(boolean visible) { public void removeInputBox() { this.getChildren().remove(messagesInputBox); } + /////////////////////////////////////////////////////////////////////////////////////////// // Bindings /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java index a512a154636..12afcd67468 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java @@ -35,7 +35,6 @@ import bisq.core.util.BSFormatter; import bisq.network.p2p.NodeAddress; -import bisq.network.p2p.P2PService; import bisq.common.UserThread; import bisq.common.util.Utilities; @@ -78,7 +77,6 @@ public class PendingTradesView extends ActivatableViewAndModel tableView; @@ -105,14 +103,12 @@ public PendingTradesView(PendingTradesViewModel model, BSFormatter formatter, PrivateNotificationManager privateNotificationManager, Preferences preferences, - P2PService p2PService, @Named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) { super(model); this.tradeDetailsWindow = tradeDetailsWindow; this.formatter = formatter; this.privateNotificationManager = privateNotificationManager; this.preferences = preferences; - this.p2PService = p2PService; this.useDevPrivilegeKeys = useDevPrivilegeKeys; } @@ -192,6 +188,7 @@ public void initialize() { tradeChat = new Chat(model.dataModel.tradeManager.getChatManager(), formatter); tradeChat.setAllowAttachments(false); + tradeChat.setDisplayHeader(false); tradeChat.initialize(); } @@ -243,7 +240,6 @@ else if (root.getChildren().size() > 1) model.dataModel.tradeManager.getChatManager()), null, selectedSubView.getLeftVBox().widthProperty()); -// root.widthProperty()); selectedSubView.setChat(tradeChat); } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeSubView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeSubView.java index 8bad0fdcf83..4ba85ae7c0b 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeSubView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeSubView.java @@ -29,6 +29,7 @@ import javafx.scene.control.Label; import javafx.scene.control.Separator; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; @@ -55,14 +56,15 @@ public abstract class TradeSubView extends HBox { protected final PendingTradesViewModel model; @Getter protected VBox leftVBox; - protected AnchorPane contentPane; - protected TradeStepView tradeStepView; + private AnchorPane contentPane; + private TradeStepView tradeStepView; private AutoTooltipButton openDisputeButton; private NotificationGroup notificationGroup; - protected GridPane leftGridPane; - protected TitledGroupBg tradeProcessTitledGroupBg; - protected int leftGridPaneRowIndex = 0; - protected Subscription viewStateSubscription; + private GridPane leftGridPane; + private TitledGroupBg tradeProcessTitledGroupBg; + private int leftGridPaneRowIndex = 0; + Subscription viewStateSubscription; + private Chat chat; /////////////////////////////////////////////////////////////////////////////////////////// // Constructor, Initialisation @@ -96,6 +98,15 @@ private void buildViews() { addLeftBox(); addContentPane(); + GridPane titleGridPane = new GridPane(); + leftVBox.getChildren().add(titleGridPane); + leftVBox.setPrefWidth(340); + ColumnConstraints cc1 = new ColumnConstraints(); + cc1.setPrefWidth(150); + ColumnConstraints cc2 = new ColumnConstraints(); + cc2.setPrefWidth(150); + titleGridPane.getColumnConstraints().addAll(cc1, cc2); + leftGridPane = new GridPane(); leftGridPane.setPrefWidth(340); leftGridPane.setHgap(Layout.GRID_GAP); @@ -103,10 +114,23 @@ private void buildViews() { VBox.setMargin(leftGridPane, new Insets(0, 10, 10, 10)); leftVBox.getChildren().add(leftGridPane); - leftGridPaneRowIndex = 0; - tradeProcessTitledGroupBg = addTitledGroupBg(leftGridPane, leftGridPaneRowIndex, 1, Res.get("portfolio.pending.tradeProcess")); - tradeProcessTitledGroupBg.getStyleClass().add("last"); + tradeProcessTitledGroupBg = addTitledGroupBg(titleGridPane, 0, 0, 1, Res.get("portfolio.pending.tradeProcess")); + tradeProcessTitledGroupBg.getStyleClass().addAll("last", "show-hand"); + tradeProcessTitledGroupBg.setOnMouseClicked(e -> { + leftVBox.setPrefWidth(340); + leftVBox.getChildren().set(1, leftGridPane); + }); + TitledGroupBg chatTitleGroupBg = addTitledGroupBg(titleGridPane, 0, 1, 1, "Chat"); + chatTitleGroupBg.getStyleClass().addAll("last", "show-hand"); + chatTitleGroupBg.setOnMouseClicked(e -> { + if (chat == null) + return; + VBox.setMargin(chat, new Insets(11, 10, 10, 10)); + leftVBox.setPrefWidth(640); + leftVBox.getChildren().set(1, chat); + }); + leftGridPaneRowIndex = 0; addWizards(); TitledGroupBg noticeTitledGroupBg = addTitledGroupBg(leftGridPane, leftGridPaneRowIndex, 1, "", @@ -196,7 +220,7 @@ private void createAndAddTradeStepView(Class viewClass) } public void setChat(Chat chat) { - leftVBox.getChildren().setAll(chat); + this.chat = chat; } private void addLeftBox() {