Skip to content

Commit

Permalink
Add basic chat UI
Browse files Browse the repository at this point in the history
Very basic switch between chat and overview per trade, improvements
needed on the UI.
  • Loading branch information
sqrrm committed Jun 5, 2019
1 parent 2375880 commit 13f2651
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
20 changes: 12 additions & 8 deletions desktop/src/main/java/bisq/desktop/main/Chat/Chat.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -143,6 +146,7 @@ public Chat(ChatManager chatManager, BSFormatter formatter) {
this.formatter = formatter;
this.p2PService = chatManager.getP2PService();
allowAttachments = true;
displayHeader = true;
}

public void initialize() {
Expand Down Expand Up @@ -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);
Expand All @@ -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<DisputeCommunicationMessage> call(ListView<DisputeCommunicationMessage> list) {
return new ListCell<>() {
Expand Down Expand Up @@ -720,6 +723,7 @@ public void setInputBoxVisible(boolean visible) {
public void removeInputBox() {
this.getChildren().remove(messagesInputBox);
}

///////////////////////////////////////////////////////////////////////////////////////////
// Bindings
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -78,7 +77,6 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
private final TradeDetailsWindow tradeDetailsWindow;
private final BSFormatter formatter;
private final PrivateNotificationManager privateNotificationManager;
private final P2PService p2PService;
private final boolean useDevPrivilegeKeys;
@FXML
TableView<PendingTradesListItem> tableView;
Expand All @@ -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;
}

Expand Down Expand Up @@ -192,6 +188,7 @@ public void initialize() {

tradeChat = new Chat(model.dataModel.tradeManager.getChatManager(), formatter);
tradeChat.setAllowAttachments(false);
tradeChat.setDisplayHeader(false);
tradeChat.initialize();
}

Expand Down Expand Up @@ -243,7 +240,6 @@ else if (root.getChildren().size() > 1)
model.dataModel.tradeManager.getChatManager()),
null,
selectedSubView.getLeftVBox().widthProperty());
// root.widthProperty());

selectedSubView.setChat(tradeChat);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -96,17 +98,39 @@ 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);
leftGridPane.setVgap(Layout.GRID_GAP);
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, "",
Expand Down Expand Up @@ -196,7 +220,7 @@ private void createAndAddTradeStepView(Class<? extends TradeStepView> viewClass)
}

public void setChat(Chat chat) {
leftVBox.getChildren().setAll(chat);
this.chat = chat;
}

private void addLeftBox() {
Expand Down

0 comments on commit 13f2651

Please sign in to comment.