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

Fine tune offers table in profile card #3040

Merged
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 @@ -40,12 +40,13 @@ void processNavigationTarget(NavigationTarget navigationTarget, Optional<Object>
Optional<NavigationTarget> optionalCandidateTarget = Optional.of(navigationTarget);
while (optionalCandidateTarget.isPresent()) {
NavigationTarget candidateTarget = optionalCandidateTarget.get();
// Make sure to run InitData even if already in target location.
Optional<Controller> optionalChildController = findController(candidateTarget, data);
if (model.getResolvedTarget().isPresent() && model.getResolvedTarget().get() == candidateTarget) {
// We as host controller have already selected the child target in question.
// We exit the loop here.
break;
}
Optional<Controller> optionalChildController = findController(candidateTarget, data);
if (optionalChildController.isPresent()) {
// We as host have found the controller and handle that target.
Controller childController = optionalChildController.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import bisq.chat.ChatMessage;
import bisq.chat.bisqeasy.offerbook.BisqEasyOfferbookChannel;
import bisq.chat.bisqeasy.offerbook.BisqEasyOfferbookChannelService;
import bisq.chat.bisqeasy.offerbook.BisqEasyOfferbookMessage;
import bisq.chat.bisqeasy.open_trades.BisqEasyOpenTradeChannel;
import bisq.chat.notifications.ChatNotification;
import bisq.chat.notifications.ChatNotificationService;
Expand All @@ -35,7 +36,9 @@
import bisq.common.proto.ProtobufUtils;
import bisq.desktop.ServiceProvider;
import bisq.desktop.common.observable.FxBindings;
import bisq.desktop.common.threading.UIScheduler;
import bisq.desktop.common.threading.UIThread;
import bisq.desktop.common.view.InitWithDataController;
import bisq.desktop.common.view.Navigation;
import bisq.desktop.main.content.bisq_easy.offerbook.offerbook_list.OfferbookListController;
import bisq.desktop.main.content.bisq_easy.trade_wizard.TradeWizardController;
Expand All @@ -48,6 +51,9 @@
import bisq.settings.SettingsService;
import javafx.beans.value.ChangeListener;
import javafx.collections.ListChangeListener;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.Subscription;
Expand All @@ -62,7 +68,19 @@
import static com.google.common.base.Preconditions.checkArgument;

@Slf4j
public final class BisqEasyOfferbookController extends ChatController<BisqEasyOfferbookView, BisqEasyOfferbookModel> {
public final class BisqEasyOfferbookController extends ChatController<BisqEasyOfferbookView, BisqEasyOfferbookModel>
implements InitWithDataController<BisqEasyOfferbookController.InitData> {
@Getter
@EqualsAndHashCode
@ToString
public static final class InitData {
private final BisqEasyOfferbookMessage chatMessage;

public InitData(BisqEasyOfferbookMessage chatMessage) {
this.chatMessage = chatMessage;
}
}

private final SettingsService settingsService;
private final MarketPriceService marketPriceService;
private final BisqEasyOfferbookChannelService bisqEasyOfferbookChannelService;
Expand Down Expand Up @@ -99,6 +117,15 @@ public BisqEasyOfferbookController(ServiceProvider serviceProvider) {
favouriteMarketChannelItemsPredicate = item -> item.getIsFavourite().get();
}

@Override
public void initWithData(InitData initData) {
BisqEasyOfferbookMessage chatMessage = initData.getChatMessage();
bisqEasyOfferbookChannelService.findChannel(chatMessage.getChannelId()).ifPresent(channel -> {
maybeUpdateSelectedChannel(channel);
UIScheduler.run(() -> chatMessageContainerController.highlightOfferChatMessage(initData.getChatMessage())).after(110);
});
}

@Override
public BisqEasyOfferbookModel createAndGetModel(ChatChannelDomain chatChannelDomain) {
BisqEasyOfferbookModel model = new BisqEasyOfferbookModel(chatChannelDomain);
Expand Down Expand Up @@ -304,9 +331,15 @@ void onSortMarkets(MarketSortType marketSortType) {
void onSelectMarketChannelItem(MarketChannelItem item) {
if (item == null) {
selectionService.selectChannel(null);
} else if (!item.getChannel().equals(selectionService.getSelectedChannel().get())) {
selectionService.selectChannel(item.getChannel());
chatNotificationService.consume(item.getChannel());
} else {
maybeUpdateSelectedChannel(item.getChannel());
}
}

private void maybeUpdateSelectedChannel(BisqEasyOfferbookChannel channel) {
if (!channel.equals(selectionService.getSelectedChannel().get())) {
selectionService.selectChannel(channel);
chatNotificationService.consume(channel);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@

package bisq.desktop.main.content.user.profile_card.offers;

import bisq.bisq_easy.NavigationTarget;
import bisq.desktop.common.view.Navigation;
import bisq.desktop.common.view.View;
import bisq.desktop.components.controls.BisqMenuItem;
import bisq.desktop.components.controls.BisqTooltip;
import bisq.desktop.components.table.BisqTableColumn;
import bisq.desktop.components.table.BisqTableView;
import bisq.desktop.main.content.bisq_easy.BisqEasyViewUtils;
import bisq.desktop.main.content.bisq_easy.offerbook.BisqEasyOfferbookController;
import bisq.desktop.main.content.bisq_easy.offerbook.offerbook_list.OfferbookListItem;
import bisq.desktop.main.content.components.MarketImageComposition;
import bisq.desktop.overlay.OverlayController;
import bisq.i18n.Res;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
Expand All @@ -49,14 +54,13 @@ public ProfileCardOffersView(ProfileCardOffersModel model,

VBox vBox = new VBox();
vBox.setFillWidth(true);
vBox.getStyleClass().add("header");
vBox.getStyleClass().add("profile-card-table-header");
tableView = new BisqTableView<>(model.getListItems());
tableView.getStyleClass().addAll("reputation-table", "rich-table-view");
tableView.getStyleClass().addAll("profile-card-table", "rich-table-view");
tableView.allowVerticalScrollbar();
configTableView();
root.getChildren().addAll(vBox, tableView);
root.setPadding(new Insets(20, 0, 0, 0));
root.getStyleClass().add("reputation");
}

@Override
Expand All @@ -73,6 +77,7 @@ private void configTableView() {
BisqTableColumn<OfferbookListItem> marketColumn = new BisqTableColumn.Builder<OfferbookListItem>()
.title(Res.get("user.profileCard.offers.table.columns.market"))
.left()
.minWidth(90)
.comparator(Comparator.comparing(OfferbookListItem::getMarketCurrencyCode)
.thenComparing(OfferbookListItem::getOfferAgeInDays))
.setCellFactory(getMarketCellFactory())
Expand All @@ -82,38 +87,47 @@ private void configTableView() {

tableView.getColumns().add(new BisqTableColumn.Builder<OfferbookListItem>()
.title(Res.get("user.profileCard.offers.table.columns.offerAge"))
.left()
.minWidth(60)
.comparator(Comparator.comparing(OfferbookListItem::getOfferAgeInDays))
.setCellFactory(getOfferAgeCellFactory())
.build());

tableView.getColumns().add(new BisqTableColumn.Builder<OfferbookListItem>()
.title(Res.get("user.profileCard.offers.table.columns.offer"))
.left()
.minWidth(80)
.comparator(Comparator.comparing(OfferbookListItem::getOfferType))
.valueSupplier(OfferbookListItem::getOfferType)
.build());

tableView.getColumns().add(new BisqTableColumn.Builder<OfferbookListItem>()
.title(Res.get("user.profileCard.offers.table.columns.amount"))
.left()
.right()
.minWidth(150)
.comparator(Comparator.comparing(OfferbookListItem::getQuoteSideMinAmount))
.valueSupplier(OfferbookListItem::getFormattedRangeQuoteAmount)
.build());

tableView.getColumns().add(new BisqTableColumn.Builder<OfferbookListItem>()
.title(Res.get("user.profileCard.offers.table.columns.price"))
.right()
.minWidth(90)
.comparator(Comparator.comparing(OfferbookListItem::getPriceSpecAsPercent))
.setCellFactory(getPriceCellFactory())
.build());

tableView.getColumns().add(new BisqTableColumn.Builder<OfferbookListItem>()
.title(Res.get("user.profileCard.offers.table.columns.paymentMethods"))
.left()
.right()
.minWidth(210)
.isSortable(false)
.setCellFactory(getPaymentMethodsCellFactory())
.build());

tableView.getColumns().add(new BisqTableColumn.Builder<OfferbookListItem>()
.minWidth(100)
.isSortable(false)
.setCellFactory(getGotToOfferCellFactory())
.build());
}

private Callback<TableColumn<OfferbookListItem, OfferbookListItem>,
Expand Down Expand Up @@ -204,13 +218,47 @@ protected void updateItem(OfferbookListItem item, boolean empty) {
if (item != null && !empty) {
HBox paymentMethodsBox = BisqEasyViewUtils.getPaymentAndSettlementMethodsBox(
item.getFiatPaymentMethods(), item.getBitcoinPaymentMethods());
paymentMethodsBox.setAlignment(Pos.CENTER_LEFT);
paymentMethodsBox.setPadding(new Insets(0, 10, 0, 0));
paymentMethodsBox.setAlignment(Pos.CENTER_RIGHT);
setGraphic(paymentMethodsBox);
} else {
setGraphic(null);
}
}
};
}

private Callback<TableColumn<OfferbookListItem, OfferbookListItem>,
TableCell<OfferbookListItem, OfferbookListItem>> getGotToOfferCellFactory() {
return column -> new TableCell<>() {
private final BisqMenuItem goToOfferButton = new BisqMenuItem(
Res.get("user.profileCard.offers.table.columns.goToOffer.button"));

{
goToOfferButton.setStyle("-fx-text-fill: -fx-mid-text-color;");
goToOfferButton.getStyleClass().add("go-to-offer-button");
}

@Override
protected void updateItem(OfferbookListItem item, boolean empty) {
super.updateItem(item, empty);

if (item != null && !empty) {
goToOfferButton.setOnAction(e ->
OverlayController.hide(() ->
Navigation.navigateTo(NavigationTarget.BISQ_EASY_OFFERBOOK,
new BisqEasyOfferbookController.InitData(item.getBisqEasyOfferbookMessage()))));
goToOfferButton.setOnMouseEntered(e -> goToOfferButton.setStyle("-fx-text-fill: -fx-light-text-color;"));
goToOfferButton.setOnMouseClicked(e -> goToOfferButton.setStyle("-fx-text-fill: -fx-light-text-color;"));
goToOfferButton.setOnMouseExited(e -> goToOfferButton.setStyle("-fx-text-fill: -fx-mid-text-color;"));
setGraphic(goToOfferButton);
} else {
goToOfferButton.setOnAction(null);
goToOfferButton.setOnMouseEntered(null);
goToOfferButton.setOnMouseClicked(null);
goToOfferButton.setOnMouseExited(null);
setGraphic(null);
}
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ public ProfileCardReputationView(ProfileCardReputationModel model,

VBox vBox = new VBox();
vBox.setFillWidth(true);
vBox.getStyleClass().add("header");
vBox.getStyleClass().add("profile-card-table-header");
tableView = new BisqTableView<>(model.getListItems());
tableView.getStyleClass().addAll("reputation-table", "rich-table-view");
tableView.getStyleClass().addAll("profile-card-table", "rich-table-view");
tableView.allowVerticalScrollbar();
configTableView();
root.getChildren().addAll(vBox, tableView);
root.setPadding(new Insets(20, 0, 0, 0));
root.getStyleClass().add("reputation");
}

@Override
Expand Down
20 changes: 14 additions & 6 deletions apps/desktop/desktop/src/main/resources/css/user.css
Original file line number Diff line number Diff line change
Expand Up @@ -155,34 +155,42 @@
-fx-padding: 35 !important;
}

.profile-card .reputation .header {
.profile-card .profile-card-table-header {
-fx-pref-height: 8;
-fx-background-color: -bisq-dark-grey-30;
-fx-background-radius: 8 8 0 0;
}

.profile-card .reputation .reputation-table.table-view {
.profile-card .profile-card-table.table-view {
-fx-pref-height: 300;
-fx-background-radius: 0 0 8 8;
-fx-background-insets: 0;
-fx-padding: 0;
-fx-border-width: 0;
}

.profile-card .reputation .reputation-table.table-view .table-cell .text {
.profile-card .profile-card-table.table-view .table-cell .text {
-fx-font-size: 0.9em;
-fx-padding: 0;
}

.profile-card .reputation .reputation-table.table-view .column-header {
.profile-card .profile-card-table.table-view .column-header {
-fx-pref-height: 25;
}

.profile-card .reputation .reputation-table.table-view .column-header-background {
.profile-card .profile-card-table.table-view .column-header .label {
-fx-alignment: center;
}

.profile-card .profile-card-table.table-view .column-header-background {
-fx-background-color: -bisq-dark-grey-30;
-fx-padding: 0 0 3 0;
}

.profile-card .reputation .reputation-table.table-view .table-row-cell {
.profile-card .profile-card-table.table-view .table-row-cell {
-fx-border-width: 0;
}

.profile-card .profile-card-table.table-view .table-row-cell .go-to-offer-button {
-fx-underline: true;
}
3 changes: 2 additions & 1 deletion i18n/src/main/resources/user.properties
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,6 @@ user.profileCard.offers.table.columns.offer=Offer
user.profileCard.offers.table.columns.amount=Amount
user.profileCard.offers.table.columns.price=Price
user.profileCard.offers.table.columns.paymentMethods=Payment methods
user.profileCard.offers.table.columns.offerAge=Offer age
user.profileCard.offers.table.columns.offerAge=Age
user.profileCard.offers.table.columns.offerAge.tooltip=Creation date:\n{0}
user.profileCard.offers.table.columns.goToOffer.button=Go to offer
Loading