diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsController.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsController.java index 91a73fdddd..8178155565 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsController.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsController.java @@ -17,6 +17,7 @@ package bisq.desktop.main.content.bisq_easy.open_trades.trade_details; +import bisq.account.payment_method.BitcoinPaymentRail; import bisq.bisq_easy.NavigationTarget; import bisq.chat.bisqeasy.open_trades.BisqEasyOpenTradeChannel; import bisq.contract.bisq_easy.BisqEasyContract; @@ -80,36 +81,37 @@ public void initWithData(InitData initData) { @Override public void onActivate() { - model.getTradeDate().set(DateFormatter.formatDateTime(contract.getTakeOfferDate())); - model.getMe().set(String.format("%s (%s)", channel.getMyUserIdentity().getNickName(), BisqEasyTradeFormatter.getMakerTakerRole(trade).toLowerCase())); - model.getPeer().set(channel.getPeer().getUserName()); - model.getOfferType().set(trade.getOffer().getDirection().isBuy() + model.setTradeDate(DateFormatter.formatDateTime(contract.getTakeOfferDate())); + model.setMe(String.format("%s (%s)", channel.getMyUserIdentity().getNickName(), BisqEasyTradeFormatter.getMakerTakerRole(trade).toLowerCase())); + model.setPeer(channel.getPeer().getUserName()); + model.setOfferType(trade.getOffer().getDirection().isBuy() ? Res.get("bisqEasy.openTrades.tradeDetails.offerTypeAndMarket.buyOffer") : Res.get("bisqEasy.openTrades.tradeDetails.offerTypeAndMarket.sellOffer")); - model.getMarket().set(Res.get("bisqEasy.openTrades.tradeDetails.offerTypeAndMarket.fiatMarket", + model.setMarket(Res.get("bisqEasy.openTrades.tradeDetails.offerTypeAndMarket.fiatMarket", trade.getOffer().getMarket().getQuoteCurrencyCode())); - model.getFiatAmount().set(BisqEasyTradeFormatter.formatQuoteSideAmount(trade)); - model.getFiatCurrency().set(trade.getOffer().getMarket().getQuoteCurrencyCode()); - model.getBtcAmount().set(BisqEasyTradeFormatter.formatBaseSideAmount(trade)); - model.getPrice().set(PriceFormatter.format(BisqEasyTradeUtils.getPriceQuote(contract))); - model.getPriceCodes().set(trade.getOffer().getMarket().getMarketCodes()); - model.getPriceSpec().set(trade.getOffer().getPriceSpec() instanceof FixPriceSpec + model.setFiatAmount(BisqEasyTradeFormatter.formatQuoteSideAmount(trade)); + model.setFiatCurrency(trade.getOffer().getMarket().getQuoteCurrencyCode()); + model.setBtcAmount(BisqEasyTradeFormatter.formatBaseSideAmount(trade)); + model.setPrice(PriceFormatter.format(BisqEasyTradeUtils.getPriceQuote(contract))); + model.setPriceCodes(trade.getOffer().getMarket().getMarketCodes()); + model.setPriceSpec(trade.getOffer().getPriceSpec() instanceof FixPriceSpec ? "" : String.format("(%s)", BisqEasyServiceUtil.getFormattedPriceSpec(trade.getOffer().getPriceSpec(), true))); - model.getPaymentMethod().set(contract.getQuoteSidePaymentMethodSpec().getShortDisplayString()); - model.getSettlementMethod().set(contract.getBaseSidePaymentMethodSpec().getShortDisplayString()); - model.getTradeId().set(trade.getId()); - model.getPeerNetworkAddress().set(channel.getPeer().getAddressByTransportDisplayString(50)); - model.getBtcPaymentAddress().set(trade.getBitcoinPaymentData().get() == null + model.setPaymentMethod(contract.getQuoteSidePaymentMethodSpec().getShortDisplayString()); + model.setSettlementMethod(contract.getBaseSidePaymentMethodSpec().getShortDisplayString()); + model.setTradeId(trade.getId()); + model.setPeerNetworkAddress(channel.getPeer().getAddressByTransportDisplayString(50)); + model.setOnChainSettlement(contract.getBaseSidePaymentMethodSpec().getPaymentMethod().getPaymentRail() == BitcoinPaymentRail.MAIN_CHAIN); + model.setBtcPaymentAddress(trade.getBitcoinPaymentData().get() == null ? Res.get("bisqEasy.openTrades.tradeDetails.dataNotYetProvided") : trade.getBitcoinPaymentData().get()); - model.getIsBtcPaymentDataEmpty().set(trade.getBitcoinPaymentData().get() == null); - model.getPaymentAccountData().set(trade.getPaymentAccountData().get() == null + model.setBtcPaymentDataEmpty(trade.getBitcoinPaymentData().get() == null); + model.setPaymentAccountData(trade.getPaymentAccountData().get() == null ? Res.get("bisqEasy.openTrades.tradeDetails.dataNotYetProvided") : trade.getPaymentAccountData().get()); - model.getIsPaymentAccountDataEmpty().set(trade.getPaymentAccountData().get() == null); - model.getAssignedMediator().set(channel.getMediator().map(UserProfile::getUserName).orElse("")); - model.getHasMediatorBeenAssigned().set(channel.getMediator().isPresent()); + model.setPaymentAccountDataEmpty(trade.getPaymentAccountData().get() == null); + model.setAssignedMediator(channel.getMediator().map(UserProfile::getUserName).orElse("")); + model.setHasMediatorBeenAssigned(channel.getMediator().isPresent()); } @Override diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsModel.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsModel.java index 0acfbf442b..dd017eff0d 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsModel.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsModel.java @@ -19,35 +19,36 @@ import bisq.bisq_easy.NavigationTarget; import bisq.desktop.common.view.NavigationModel; -import javafx.beans.property.SimpleBooleanProperty; -import javafx.beans.property.SimpleStringProperty; import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; @Slf4j @Getter +@Setter public class TradeDetailsModel extends NavigationModel { - private final SimpleStringProperty tradeDate = new SimpleStringProperty(); - private final SimpleStringProperty me = new SimpleStringProperty(); - private final SimpleStringProperty peer = new SimpleStringProperty(); - private final SimpleStringProperty offerType = new SimpleStringProperty(); - private final SimpleStringProperty market = new SimpleStringProperty(); - private final SimpleStringProperty fiatAmount = new SimpleStringProperty(); - private final SimpleStringProperty fiatCurrency = new SimpleStringProperty(); - private final SimpleStringProperty btcAmount = new SimpleStringProperty(); - private final SimpleStringProperty price = new SimpleStringProperty(); - private final SimpleStringProperty priceCodes = new SimpleStringProperty(); - private final SimpleStringProperty priceSpec = new SimpleStringProperty(); - private final SimpleStringProperty paymentMethod = new SimpleStringProperty(); - private final SimpleStringProperty settlementMethod = new SimpleStringProperty(); - private final SimpleStringProperty tradeId = new SimpleStringProperty(); - private final SimpleStringProperty peerNetworkAddress = new SimpleStringProperty(); - private final SimpleStringProperty btcPaymentAddress = new SimpleStringProperty(); - private final SimpleBooleanProperty isBtcPaymentDataEmpty = new SimpleBooleanProperty(); - private final SimpleStringProperty paymentAccountData = new SimpleStringProperty(); - private final SimpleBooleanProperty isPaymentAccountDataEmpty = new SimpleBooleanProperty(); - private final SimpleStringProperty assignedMediator = new SimpleStringProperty(); - private final SimpleBooleanProperty hasMediatorBeenAssigned = new SimpleBooleanProperty(); + private String tradeDate; + private String me; + private String peer; + private String offerType; + private String market; + private String fiatAmount; + private String fiatCurrency; + private String btcAmount; + private String price; + private String priceCodes; + private String priceSpec; + private String paymentMethod; + private String settlementMethod; + private String tradeId; + private String peerNetworkAddress; + private boolean isOnChainSettlement; + private String btcPaymentAddress; + private boolean isBtcPaymentDataEmpty; + private String paymentAccountData; + private boolean isPaymentAccountDataEmpty; + private String assignedMediator; + private boolean hasMediatorBeenAssigned; @Override public NavigationTarget getDefaultNavigationTarget() { diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsView.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsView.java index 5b482ab798..1e69b077a4 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsView.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/open_trades/trade_details/TradeDetailsView.java @@ -34,8 +34,6 @@ import javafx.scene.layout.Region; import javafx.scene.layout.VBox; import lombok.extern.slf4j.Slf4j; -import org.fxmisc.easybind.EasyBind; -import org.fxmisc.easybind.Subscription; import java.util.Optional; @@ -44,12 +42,11 @@ public class TradeDetailsView extends NavigationView button) { Label titleLabel = new Label(Res.get(title)); + return createAndGetTitleAndDetailsBox(titleLabel, detailsNode, button); + } + + private HBox createAndGetTitleAndDetailsBox(Label titleLabel, Node detailsNode, Optional button) { double width = 180; titleLabel.setMaxWidth(width); titleLabel.setMinWidth(width); @@ -228,72 +230,58 @@ private HBox createAndGetTitleAndDetailsBox(String title, Node detailsNode, Opti @Override protected void onViewAttached() { - tradeDateLabel.textProperty().bind(model.getTradeDate()); - meLabel.textProperty().bind(model.getMe()); - peerLabel.textProperty().bind(model.getPeer()); - offerTypeLabel.textProperty().bind(model.getOfferType()); - marketLabel.textProperty().bind(model.getMarket()); - fiatAmountLabel.textProperty().bind(model.getFiatAmount()); - fiatCurrencyLabel.textProperty().bind(model.getFiatCurrency()); - btcAmountLabel.textProperty().bind(model.getBtcAmount()); - priceLabel.textProperty().bind(model.getPrice()); - priceCodesLabel.textProperty().bind(model.getPriceCodes()); - priceSpecLabel.textProperty().bind(model.getPriceSpec()); - paymentMethodLabel.textProperty().bind(model.getPaymentMethod()); - settlementMethodLabel.textProperty().bind(model.getSettlementMethod()); - tradeIdLabel.textProperty().bind(model.getTradeId()); - peerNetworkAddressLabel.textProperty().bind(model.getPeerNetworkAddress()); - btcPaymentAddressLabel.textProperty().bind(model.getBtcPaymentAddress()); - paymentAccountDataLabel.textProperty().bind(model.getPaymentAccountData()); - assignedMediatorLabel.textProperty().bind(model.getAssignedMediator()); - assignedMediatorBox.visibleProperty().bind(model.getHasMediatorBeenAssigned()); - assignedMediatorBox.managedProperty().bind(model.getHasMediatorBeenAssigned()); - - isBtcPaymentAddressEmptyPin = EasyBind.subscribe(model.getIsBtcPaymentDataEmpty(), isEmpty -> { - btcPaymentAddressLabel.getStyleClass().remove("text-fill-grey-dimmed"); - btcPaymentAddressLabel.getStyleClass().remove("text-fill-white"); - btcPaymentAddressLabel.getStyleClass().add(isEmpty ? "text-fill-grey-dimmed" : "text-fill-white"); - }); - isPaymentAccountDataEmptyPin = EasyBind.subscribe(model.getIsPaymentAccountDataEmpty(), isEmpty -> { + tradeDateLabel.setText(model.getTradeDate()); + meLabel.setText(model.getMe()); + peerLabel.setText(model.getPeer()); + offerTypeLabel.setText(model.getOfferType()); + marketLabel.setText(model.getMarket()); + fiatAmountLabel.setText(model.getFiatAmount()); + fiatCurrencyLabel.setText(model.getFiatCurrency()); + btcAmountLabel.setText(model.getBtcAmount()); + priceLabel.setText(model.getPrice()); + priceCodesLabel.setText(model.getPriceCodes()); + priceSpecLabel.setText(model.getPriceSpec()); + paymentMethodLabel.setText(model.getPaymentMethod()); + settlementMethodLabel.setText(model.getSettlementMethod()); + tradeIdLabel.setText(model.getTradeId()); + peerNetworkAddressLabel.setText(model.getPeerNetworkAddress()); + btcPaymentAddressTitleLabel.setText(model.isOnChainSettlement() + ? Res.get("bisqEasy.openTrades.tradeDetails.btcPaymentAddress") + : Res.get("bisqEasy.openTrades.tradeDetails.lightningInvoice")); + btcPaymentAddressDetailsLabel.setText(model.getBtcPaymentAddress()); + btcPaymentAddressCopyButton.setTooltip(model.isOnChainSettlement() + ? Res.get("bisqEasy.openTrades.tradeDetails.btcPaymentAddress.copy") + : Res.get("bisqEasy.openTrades.tradeDetails.lightningInvoice.copy")); + paymentAccountDataLabel.setText(model.getPaymentAccountData()); + assignedMediatorLabel.setText(model.getAssignedMediator()); + assignedMediatorBox.setVisible(model.isHasMediatorBeenAssigned()); + assignedMediatorBox.setManaged(model.isHasMediatorBeenAssigned()); + + if (model.isBtcPaymentDataEmpty()) { + btcPaymentAddressDetailsLabel.getStyleClass().remove("text-fill-grey-dimmed"); + btcPaymentAddressDetailsLabel.getStyleClass().remove("text-fill-white"); + btcPaymentAddressDetailsLabel.getStyleClass().add(model.isBtcPaymentDataEmpty() + ? "text-fill-grey-dimmed" + : "text-fill-white"); + } + if (model.isPaymentAccountDataEmpty()) { paymentAccountDataLabel.getStyleClass().remove("text-fill-grey-dimmed"); paymentAccountDataLabel.getStyleClass().remove("text-fill-white"); - paymentAccountDataLabel.getStyleClass().add(isEmpty ? "text-fill-grey-dimmed" : "text-fill-white"); - }); + paymentAccountDataLabel.getStyleClass().add(model.isPaymentAccountDataEmpty() + ? "text-fill-grey-dimmed" + : "text-fill-white"); + } closeButton.setOnAction(e -> controller.onClose()); - tradersAndRoleCopyButton.setOnAction(e -> ClipboardUtil.copyToClipboard(model.getPeer().get())); - tradeIdCopyButton.setOnAction(e -> ClipboardUtil.copyToClipboard(model.getTradeId().get())); - peerNetworkAddressCopyButton.setOnAction(e -> ClipboardUtil.copyToClipboard(model.getPeerNetworkAddress().get())); - btcPaymentAddressCopyButton.setOnAction(e -> ClipboardUtil.copyToClipboard(model.getBtcPaymentAddress().get())); - paymentAccountDataCopyButton.setOnAction(e -> ClipboardUtil.copyToClipboard(model.getPaymentAccountData().get())); + tradersAndRoleCopyButton.setOnAction(e -> ClipboardUtil.copyToClipboard(model.getPeer())); + tradeIdCopyButton.setOnAction(e -> ClipboardUtil.copyToClipboard(model.getTradeId())); + peerNetworkAddressCopyButton.setOnAction(e -> ClipboardUtil.copyToClipboard(model.getPeerNetworkAddress())); + btcPaymentAddressCopyButton.setOnAction(e -> ClipboardUtil.copyToClipboard(model.getBtcPaymentAddress())); + paymentAccountDataCopyButton.setOnAction(e -> ClipboardUtil.copyToClipboard(model.getPaymentAccountData())); } @Override protected void onViewDetached() { - tradeDateLabel.textProperty().unbind(); - meLabel.textProperty().unbind(); - peerLabel.textProperty().unbind(); - offerTypeLabel.textProperty().unbind(); - marketLabel.textProperty().unbind(); - fiatAmountLabel.textProperty().unbind(); - fiatCurrencyLabel.textProperty().unbind(); - btcAmountLabel.textProperty().unbind(); - priceLabel.textProperty().unbind(); - priceCodesLabel.textProperty().unbind(); - priceSpecLabel.textProperty().unbind(); - paymentMethodLabel.textProperty().unbind(); - settlementMethodLabel.textProperty().unbind(); - tradeIdLabel.textProperty().unbind(); - peerNetworkAddressLabel.textProperty().unbind(); - btcPaymentAddressLabel.textProperty().unbind(); - paymentAccountDataLabel.textProperty().unbind(); - assignedMediatorLabel.textProperty().unbind(); - assignedMediatorBox.visibleProperty().unbind(); - assignedMediatorBox.managedProperty().unbind(); - - isBtcPaymentAddressEmptyPin.unsubscribe(); - isPaymentAccountDataEmptyPin.unsubscribe(); - closeButton.setOnAction(null); tradersAndRoleCopyButton.setOnAction(null); tradeIdCopyButton.setOnAction(null); diff --git a/i18n/src/main/resources/bisq_easy.properties b/i18n/src/main/resources/bisq_easy.properties index 9bfebdd7c2..130a82f7e8 100644 --- a/i18n/src/main/resources/bisq_easy.properties +++ b/i18n/src/main/resources/bisq_easy.properties @@ -667,7 +667,9 @@ bisqEasy.openTrades.tradeDetails.tradeId.copy=Copy trade ID bisqEasy.openTrades.tradeDetails.peerNetworkAddress=Peer network address bisqEasy.openTrades.tradeDetails.peerNetworkAddress.copy=Copy peer network address bisqEasy.openTrades.tradeDetails.btcPaymentAddress=BTC payment address +bisqEasy.openTrades.tradeDetails.lightningInvoice=Lighting invoice bisqEasy.openTrades.tradeDetails.btcPaymentAddress.copy=Copy BTC payment address +bisqEasy.openTrades.tradeDetails.lightningInvoice.copy=Copy lighting invoice bisqEasy.openTrades.tradeDetails.paymentAccountData=Payment account data bisqEasy.openTrades.tradeDetails.paymentAccountData.copy=Copy payment account data bisqEasy.openTrades.tradeDetails.assignedMediator=Assigned mediator