Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify chat window headers for public channels #1539

Merged
merged 8 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import javafx.scene.layout.StackPane;
import lombok.extern.slf4j.Slf4j;
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.Subscription;

import java.util.Comparator;
import java.util.List;
Expand All @@ -59,7 +58,6 @@ public final class BisqEasyOfferbookController extends BaseChatController<BisqEa
private final BisqEasyOfferbookChannelService bisqEasyOfferbookChannelService;
private final BisqEasyOfferbookModel bisqEasyOfferbookModel;
private Pin selectedChannelPin, offerOnlySettingsPin, bisqEasyPrivateTradeChatChannelsPin;
private Subscription searchTextPin;

public BisqEasyOfferbookController(ServiceProvider serviceProvider) {
super(serviceProvider, ChatChannelDomain.BISQ_EASY_OFFERBOOK, NavigationTarget.BISQ_EASY_OFFERBOOK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import bisq.desktop.main.content.chat.BaseChatModel;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
Expand All @@ -40,7 +38,6 @@ public final class BisqEasyOfferbookModel extends BaseChatModel {
private final ObservableList<MarketChannelItem> marketChannelItems = FXCollections.observableArrayList();
private final FilteredList<MarketChannelItem> filteredMarketChannelItems = new FilteredList<>(marketChannelItems);
private final SortedList<MarketChannelItem> sortedMarketChannelItems = new SortedList<>(filteredMarketChannelItems);
private final StringProperty searchText = new SimpleStringProperty();
public BisqEasyOfferbookModel(ChatChannelDomain chatChannelDomain) {
super(chatChannelDomain);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
import bisq.desktop.components.controls.BisqIconButton;
import bisq.desktop.components.controls.BisqTooltip;
import bisq.desktop.components.controls.ComboBoxWithSearch;
import bisq.desktop.components.controls.SearchBox;
import bisq.desktop.main.content.chat.BaseChatView;
import bisq.i18n.Res;
import de.jensd.fx.fontawesome.AwesomeIcon;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.Tooltip;
Expand All @@ -47,9 +45,8 @@ public final class BisqEasyOfferbookView extends BaseChatView {
private final BisqEasyOfferbookController bisqEasyOfferbookController;
//private Switch offersOnlySwitch;
//private Button closeFilterButton, filterButton;
private Button createOfferButton;

private Label marketSelectorIcon;
private SearchBox searchBox;

//private Pane filterPane;
/* private Subscription showFilterOverlayPin;
Expand All @@ -73,14 +70,31 @@ protected void configTitleHBox() {
titleHBox.setAlignment(Pos.CENTER);
titleHBox.setPadding(new Insets(12.5, 25, 12.5, 25));
titleHBox.getStyleClass().add("bisq-easy-container-header");
titleHBox.setMinHeight(HEADER_HEIGHT);
titleHBox.setMaxHeight(HEADER_HEIGHT);

channelTitle.getStyleClass().add("chat-header-title");
channelTitle.setCursor(Cursor.HAND);
channelTitle.setMinWidth(81);

marketSelectorIcon = Icons.getIcon(AwesomeIcon.CHEVRON_DOWN, "12");
marketSelectorIcon.getStyleClass().add("market-selector-icon");
marketSelectorIcon.setCursor(Cursor.HAND);
marketSelectorIcon.setPadding(new Insets(7, 10, 7, 10));
marketSelectorIcon.setPadding(new Insets(0, 15, 0, 7));
marketSelectorIcon.setTooltip(new BisqTooltip(Res.get("bisqEasy.offerbook.selectMarket"), true));

channelTitle.setId("chat-messages-headline");
channelTitle.setCursor(Cursor.HAND);
channelDescription.getStyleClass().addAll("chat-header-description");

HBox headerTitle = new HBox(channelTitle, marketSelectorIcon, channelDescription);
headerTitle.setAlignment(Pos.BASELINE_LEFT);
headerTitle.setPadding(new Insets(7, 0, 0, 0));
HBox.setHgrow(headerTitle, Priority.ALWAYS);

searchBox.setMaxWidth(200);
searchBox.setMaxHeight(searchBox.getMinHeight());
searchBox.setDefaultStyle("bisq-easy-offerbook-search-box");
searchBox.setActiveStyle("bisq-easy-offerbook-search-box-active");
searchBox.setActiveIconId("search-green");

double scale = 1.15;
helpButton = BisqIconButton.createIconButton("icon-help");
Expand All @@ -93,11 +107,7 @@ protected void configTitleHBox() {
HBox.setMargin(channelTitle, new Insets(0, -10, 0, 4));
HBox.setMargin(helpButton, new Insets(-2, 0, 0, 0));
HBox.setMargin(infoButton, new Insets(-2, 0, 0, 0));
titleHBox.getChildren().addAll(
channelTitle, marketSelectorIcon,
Spacer.fillHBox(),
helpButton, infoButton
);
titleHBox.getChildren().addAll(headerTitle, searchBox, helpButton, infoButton);
}

@Override
Expand All @@ -106,13 +116,6 @@ protected void configCenterVBox() {
centerVBox.setFillWidth(true);
centerVBox.setMaxWidth(CHAT_BOX_MAX_WIDTH);

searchBox = new SearchBox();
searchBox.setMaxWidth(200);
searchBox.setMaxHeight(searchBox.getMinHeight());
searchBox.setDefaultStyle("bisq-easy-offerbook-search-box");
searchBox.setActiveStyle("bisq-easy-offerbook-search-box-active");
searchBox.setActiveIconId("search-green");

/* filterButton = new Button(Res.get("bisqEasy.topPane.filter"));
ImageView filterIcon = ImageUtil.getImageViewById("filter");
filterIcon.setOpacity(0.3);
Expand All @@ -126,9 +129,6 @@ protected void configCenterVBox() {

// offersOnlySwitch = new Switch(Res.get("bisqEasy.topPane.filter.offersOnly"));

createOfferButton = new Button(Res.get("offer.createOffer"));
createOfferButton.getStyleClass().add("outlined-button");

/* Label filterLabel = new Label(Res.get("bisqEasy.topPane.filter"));
filterLabel.getStyleClass().add("bisq-easy-chat-filter-headline");
closeFilterButton = BisqIconButton.createIconButton("close");*/
Expand All @@ -141,18 +141,10 @@ protected void configCenterVBox() {
filterPane.getStyleClass().add("bisq-easy-chat-filter-panel-bg");
filterPane.setPadding(new Insets(10));*/

HBox.setMargin(searchBox, new Insets(0.5, 0, 0, 0));
HBox toolsHBox = new HBox(15, searchBox, Spacer.fillHBox(), createOfferButton);
toolsHBox.setAlignment(Pos.CENTER);
toolsHBox.setPadding(new Insets(12.5, 25, 12.5, 25));

VBox toolBar = new VBox(titleHBox, toolsHBox/*, filterPane*/);
toolBar.setMaxHeight(50);

chatMessagesComponent.setMinWidth(700);

VBox.setVgrow(chatMessagesComponent, Priority.ALWAYS);
centerVBox.getChildren().addAll(toolBar, Layout.hLine(), chatMessagesComponent);
centerVBox.getChildren().addAll(titleHBox, Layout.hLine(), chatMessagesComponent);
centerVBox.getStyleClass().add("bisq-easy-container");
}

Expand Down Expand Up @@ -186,7 +178,6 @@ protected void configContainerHBox() {
protected void onViewAttached() {
super.onViewAttached();

searchBox.textProperty().bindBidirectional(bisqEasyOfferbookModel.getSearchText());
// offersOnlySwitch.selectedProperty().bindBidirectional(bisqEasyOfferbookModel.getOfferOnly());

/* if (filterPaneHeight == 0) {
Expand Down Expand Up @@ -223,7 +214,6 @@ protected void onViewAttached() {
}
});*/

createOfferButton.setOnAction(e -> bisqEasyOfferbookController.onCreateOffer());
// filterButton.setOnAction(e -> bisqEasyOfferbookController.onToggleFilter());
// closeFilterButton.setOnAction(e -> bisqEasyOfferbookController.onCloseFilter());
marketSelectorIcon.setOnMouseClicked(e -> {
Expand All @@ -243,12 +233,10 @@ protected void onViewAttached() {
protected void onViewDetached() {
super.onViewDetached();

searchBox.textProperty().unbindBidirectional(bisqEasyOfferbookModel.getSearchText());
// offersOnlySwitch.selectedProperty().unbindBidirectional(bisqEasyOfferbookModel.getOfferOnly());

// showFilterOverlayPin.unsubscribe();

createOfferButton.setOnAction(null);
// filterButton.setOnAction(null);
// closeFilterButton.setOnAction(null);
marketSelectorIcon.setOnMouseClicked(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@
import bisq.desktop.main.content.chat.priv.PrivateChatsController;
import lombok.extern.slf4j.Slf4j;

import java.util.Optional;

@Slf4j
public final class BisqEasyPrivateChatsController extends PrivateChatsController {

public BisqEasyPrivateChatsController(ServiceProvider serviceProvider) {
super(serviceProvider, ChatChannelDomain.BISQ_EASY_PRIVATE_CHAT, NavigationTarget.BISQ_EASY_PRIVATE_CHAT, Optional.empty());
super(serviceProvider, ChatChannelDomain.BISQ_EASY_PRIVATE_CHAT, NavigationTarget.BISQ_EASY_PRIVATE_CHAT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import bisq.chat.ChatChannelDomain;
import bisq.chat.ChatMessage;
import bisq.chat.ChatService;
import bisq.chat.bisqeasy.offerbook.BisqEasyOfferbookChannel;
import bisq.chat.bisqeasy.open_trades.BisqEasyOpenTradeChannel;
import bisq.chat.common.CommonPublicChatChannel;
import bisq.chat.priv.PrivateChatChannel;
import bisq.chat.two_party.TwoPartyPrivateChatChannel;
import bisq.desktop.ServiceProvider;
Expand All @@ -45,6 +47,7 @@
import javafx.scene.layout.HBox;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.fxmisc.easybind.Subscription;

import javax.annotation.Nullable;
import java.util.ArrayList;
Expand All @@ -66,6 +69,7 @@ public abstract class BaseChatController<V extends BaseChatView, M extends BaseC
protected final UserProfileService userProfileService;
protected final ChannelSidebar channelSidebar;
protected final ChatMessagesComponent chatMessagesComponent;
protected Subscription searchTextPin;

public BaseChatController(ServiceProvider serviceProvider, ChatChannelDomain chatChannelDomain, NavigationTarget host) {
super(host);
Expand Down Expand Up @@ -131,6 +135,16 @@ protected void selectedChannelChanged(@Nullable ChatChannel<? extends ChatMessag
cleanupChannelInfo();
showChannelInfo();
}

if (chatChannel instanceof CommonPublicChatChannel) {
model.getChannelDescription().set(((CommonPublicChatChannel) chatChannel).getDescription());
}

if (chatChannel instanceof BisqEasyOfferbookChannel) {
String description = ((BisqEasyOfferbookChannel) chatChannel).getDescription();
String oneLineDescription = description.replace("\n", " ");
model.getChannelDescription().set(oneLineDescription);
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public abstract class BaseChatModel extends NavigationModel {
private final Map<String, StringProperty> chatMessagesByChannelId = new HashMap<>();
private final StringProperty selectedChatMessages = new SimpleStringProperty("");
private final StringProperty channelTitle = new SimpleStringProperty("");
private final StringProperty channelDescription = new SimpleStringProperty("");
private final ObjectProperty<ChatChannel<? extends ChatMessage>> selectedChannel = new SimpleObjectProperty<>();
private final ObjectProperty<Pane> chatUserDetailsRoot = new SimpleObjectProperty<>();
private final BooleanProperty sideBarVisible = new SimpleBooleanProperty();
Expand All @@ -52,6 +53,7 @@ public abstract class BaseChatModel extends NavigationModel {
private final String helpTitle;
@Setter
private Optional<UserProfileSidebar> chatUserDetails = Optional.empty();
private final StringProperty searchText = new SimpleStringProperty();

public BaseChatModel(ChatChannelDomain chatChannelDomain) {
this.chatChannelDomain = chatChannelDomain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package bisq.desktop.main.content.chat;

import bisq.desktop.common.view.NavigationView;
import bisq.desktop.components.controls.SearchBox;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
Expand All @@ -33,14 +34,16 @@ public abstract class BaseChatView extends NavigationView<ScrollPane, BaseChatMo
protected final static double HEADER_HEIGHT = 61;

protected final Label channelTitle = new Label();
protected final Label channelDescription = new Label();
protected Button helpButton, infoButton;
protected final VBox sideBar = new VBox();
protected final VBox centerVBox = new VBox();
protected final HBox titleHBox = new HBox(10);
protected final HBox containerHBox = new HBox();
protected final Pane channelSidebar, chatMessagesComponent;
protected Pane chatUserOverviewRoot;
protected Subscription channelIconPin, chatUserOverviewRootSubscription;
protected Subscription /*channelIconPin, */chatUserOverviewRootSubscription;
protected final SearchBox searchBox = new SearchBox();

public BaseChatView(BaseChatModel model,
BaseChatController<?, ?> controller,
Expand Down Expand Up @@ -71,10 +74,12 @@ public BaseChatView(BaseChatModel model,
@Override
protected void onViewAttached() {
channelTitle.textProperty().bind(model.getChannelTitle());
channelDescription.textProperty().bind(model.getChannelDescription());
channelSidebar.visibleProperty().bind(model.getChannelSidebarVisible());
channelSidebar.managedProperty().bind(model.getChannelSidebarVisible());
sideBar.visibleProperty().bind(model.getSideBarVisible());
sideBar.managedProperty().bind(model.getSideBarVisible());
searchBox.textProperty().bindBidirectional(model.getSearchText());

if (helpButton != null) {
helpButton.setOnAction(e -> controller.onOpenHelp());
Expand All @@ -96,25 +101,27 @@ protected void onViewAttached() {
}
});

channelIconPin = EasyBind.subscribe(model.getChannelIconNode(), node -> {
if (node != null) {
channelTitle.setGraphic(node);
channelTitle.setGraphicTextGap(10);
node.setStyle("-fx-cursor: hand;");
node.setOnMouseClicked(e -> controller.onToggleChannelInfo());
} else {
channelTitle.setGraphic(null);
}
});
// channelIconPin = EasyBind.subscribe(model.getChannelIconNode(), node -> {
// if (node != null) {
// channelTitle.setGraphic(node);
// channelTitle.setGraphicTextGap(10);
// node.setStyle("-fx-cursor: hand;");
// node.setOnMouseClicked(e -> controller.onToggleChannelInfo());
// } else {
// channelTitle.setGraphic(null);
// }
// });
}

@Override
protected void onViewDetached() {
channelTitle.textProperty().unbind();
channelDescription.textProperty().unbind();
channelSidebar.visibleProperty().unbind();
channelSidebar.managedProperty().unbind();
sideBar.visibleProperty().unbind();
sideBar.managedProperty().unbind();
searchBox.textProperty().unbindBidirectional(model.getSearchText());

if (helpButton != null) {
helpButton.setOnAction(null);
Expand All @@ -124,6 +131,6 @@ protected void onViewDetached() {
}

chatUserOverviewRootSubscription.unsubscribe();
channelIconPin.unsubscribe();
// channelIconPin.unsubscribe();
}
}
Loading