Use link icon for cloned offers

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2023-05-05 11:11:58 +07:00
parent 384173c894
commit 4ae89e748c
No known key found for this signature in database
GPG key ID: 02AA2BAE387C8307
7 changed files with 60 additions and 52 deletions

View file

@ -463,12 +463,12 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
ResultHandler resultHandler,
ErrorMessageHandler errorMessageHandler) {
if (offersToBeEdited.containsKey(openOffer.getId())) {
errorMessageHandler.handleErrorMessage("You can't activate an offer that is currently edited.");
errorMessageHandler.handleErrorMessage(Res.get("offerbook.cannotActivateEditedOffer.warning"));
return;
}
if (cannotActivateOffer(openOffer.getOffer())) {
errorMessageHandler.handleErrorMessage(Res.get("offerbook.cannotActivate.info"));
errorMessageHandler.handleErrorMessage(Res.get("offerbook.cannotActivate.warning"));
return;
}

View file

@ -366,11 +366,22 @@ offerbook.timeSinceSigning.tooltip.learnMore=Learn more
offerbook.xmrAutoConf=Is auto-confirm enabled
offerbook.cloneOffer=Clone offer (with shared maker fee)
offerbook.clonedOffer.info=This is a cloned offer with shared maker fee transaction ID
offerbook.nonClonedOffer.info=Regular offer without shared maker fee transaction ID
offerbook.cannotActivate.info=This cloned offer with shared maker fee cannot be activated because it uses \
offerbook.clonedOffer.tooltip=This is a cloned offer with shared maker fee transaction ID.\n\Maker fee transaction ID: {0}
offerbook.nonClonedOffer.tooltip=Regular offer without shared maker fee transaction ID.\n\Maker fee transaction ID: {0}
offerbook.cannotActivate.warning=This cloned offer with shared maker fee cannot be activated because it uses \
the same payment method and currency as another active offer. You need to edit the offer and change the \
payment method or currency or deactivate the offer which has the same payment method and currency.
offerbook.cannotActivateEditedOffer.warning=You can't activate an offer that is currently edited.
offerbook.clonedOffer.info=By cloning an offer one creates a copy of the given offer with a new offer ID but using the same \
maker fee transaction ID.\n\n\
This means there is no extra maker fee needed to get paid and the funds reserved for that offer can \
be re-used by the cloned offers. This reduces the liquidity requirements for market makers and allows them to post the \
same offer in different markets or with different payment methods.\n\n\
As a consequence if one of the offers sharing the same maker fee transaction is taken all the other offers \
will get closed as well because the transaction output of that maker fee transaction is spent and would render the \
other offers invalid. \n\n\
This feature requires to use the same trade amount and security deposit and is only permitted for offers with different \
payment methods or currencies.
offerbook.timeSinceSigning.help=When you successfully complete a trade with a peer who has a signed payment account, your payment account is signed.\n\
{0} days later, the initial limit of {1} is lifted and your account can sign other peers'' payment accounts.

View file

@ -832,6 +832,10 @@ tree-table-view:focused {
-fx-text-fill: -bs-rd-error-red;
}
.icon {
-fx-fill: -bs-text-color;
}
.opaque-icon {
-fx-fill: -bs-color-gray-bbb;
-fx-opacity: 1;

View file

@ -41,7 +41,7 @@
<TableView fx:id="tableView" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="offerIdColumn" minWidth="110" maxWidth="120"/>
<TableColumn fx:id="makerFeeTxIdColumn" minWidth="80"/>
<TableColumn fx:id="makerFeeTxIdColumn" minWidth="70"/>
<TableColumn fx:id="dateColumn" minWidth="170"/>
<TableColumn fx:id="marketColumn" minWidth="75"/>
<TableColumn fx:id="priceColumn" minWidth="100"/>

View file

@ -391,7 +391,7 @@ public class OpenOffersView extends ActivatableViewAndModel<VBox, OpenOffersView
() -> log.debug("Activate offer was successful"),
(message) -> {
log.error(message);
new Popup().warning(Res.get("offerbook.activateOffer.failed", message)).show();
new Popup().warning(message).show();
});
updateSelectToggleButtonState();
}
@ -467,6 +467,20 @@ public class OpenOffersView extends ActivatableViewAndModel<VBox, OpenOffersView
if (item == null) {
return;
}
String key = "clonedOfferInfo";
if (DontShowAgainLookup.showAgain(key)) {
new Popup().backgroundInfo(Res.get("offerbook.clonedOffer.info"))
.useIUnderstandButton()
.dontShowAgainId(key)
.onClose(() -> doCloneOffer(item))
.show();
} else {
doCloneOffer(item);
}
}
private void doCloneOffer(OpenOfferListItem item) {
OpenOffer openOffer = item.getOpenOffer();
if (openOffer == null || openOffer.getOffer() == null || openOffer.getOffer().getOfferPayload().isEmpty()) {
return;
@ -576,60 +590,35 @@ public class OpenOffersView extends ActivatableViewAndModel<VBox, OpenOffersView
@Override
public TableCell<OpenOfferListItem, OpenOfferListItem> call(
TableColumn<OpenOfferListItem, OpenOfferListItem> column) {
return new TableCell<>() {
private HyperlinkWithIcon hyperlinkWithIcon = null;
@Override
public void updateItem(final OpenOfferListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
hyperlinkWithIcon = new HyperlinkWithIcon(item.getMakerFeeTxId());
if (item.isNotPublished()) {
// getStyleClass().add("offer-disabled"); does not work with hyperlinkWithIcon ;-(
hyperlinkWithIcon.setStyle("-fx-text-fill: -bs-color-gray-3;");
hyperlinkWithIcon.getIcon().setOpacity(0.2);
}
hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBlockExplorer(item.getMakerFeeTxId()));
if (openOfferManager.hasOfferSharedMakerFee(item.getOpenOffer())) {
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("offerbook.clonedOffer.info")));
} else {
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("offerbook.nonClonedOffer.info")));
}
setGraphic(hyperlinkWithIcon);
} else {
setGraphic(null);
if (hyperlinkWithIcon != null) {
hyperlinkWithIcon.setOnAction(null);
}
}
}
};
/*return new TableCell<>() {
@Override
public void updateItem(final OpenOfferListItem item, boolean empty) {
super.updateItem(item, empty);
getStyleClass().removeAll("offer-disabled");
if (item != null) {
Label label = new Label(item.getMakerFeeTxId());
Text icon;
if (openOfferManager.hasOfferSharedMakerFee(item.getOpenOffer())) {
icon = getRegularIconForLabel(MaterialDesignIcon.LINK, label, "icon");
setTooltip(new Tooltip(Res.get("offerbook.clonedOffer.tooltip", item.getMakerFeeTxId())));
} else {
icon = getRegularIconForLabel(MaterialDesignIcon.LINK_OFF, label, "icon");
setTooltip(new Tooltip(Res.get("offerbook.nonClonedOffer.tooltip", item.getMakerFeeTxId())));
}
icon.setVisible(!item.getOffer().isBsqSwapOffer());
if (item.isNotPublished()) {
getStyleClass().add("offer-disabled");
}
Label label = new AutoTooltipLabel(item.getMakerFeeTxId());
log.error("{} {}",openOfferManager.hasOfferSharedMakerFee(item.getOpenOffer()),item.getOpenOffer().getId());
if (openOfferManager.hasOfferSharedMakerFee(item.getOpenOffer())) {
Text icon = getRegularIconForLabel(MaterialDesignIcon.CALENDAR_QUESTION, label);
label.setContentDisplay(ContentDisplay.LEFT);
Tooltip.install(icon, new Tooltip(Res.get("offerbook.sharedMakerFeeTxId")));
} else {
label.setGraphic(null);
icon.setOpacity(0.2);
}
setGraphic(label);
} else {
setGraphic(null);
}
}
};*/
};
}
});
}

View file

@ -557,3 +557,7 @@
-fx-text-fill: -bs-text-color;
-fx-fill: -bs-text-color;
}
.icon {
-fx-fill: #fff;
}

View file

@ -2248,12 +2248,12 @@ public class FormBuilder {
// Icons
///////////////////////////////////////////////////////////////////////////////////////////
public static Text getIconForLabel(GlyphIcons icon, String iconSize, Label label, String style) {
public static Text getIconForLabel(GlyphIcons icon, String iconSize, Label label, String styleClass) {
if (icon.fontFamily().equals(MATERIAL_DESIGN_ICONS)) {
final Text textIcon = MaterialDesignIconFactory.get().createIcon(icon, iconSize);
textIcon.setOpacity(0.7);
if (style != null) {
textIcon.getStyleClass().add(style);
if (styleClass != null) {
textIcon.getStyleClass().add(styleClass);
}
label.setContentDisplay(ContentDisplay.LEFT);
label.setGraphic(textIcon);
@ -2279,8 +2279,8 @@ public class FormBuilder {
return getRegularIconForLabel(icon, label, null);
}
public static Text getRegularIconForLabel(GlyphIcons icon, Label label, String style) {
return getIconForLabel(icon, "1.231em", label, style);
public static Text getRegularIconForLabel(GlyphIcons icon, Label label, String styleClass) {
return getIconForLabel(icon, "1.231em", label, styleClass);
}
public static Text getIcon(GlyphIcons icon) {