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

Edit offer button #5955

Merged
merged 2 commits into from Jan 12, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions desktop/src/main/java/bisq/desktop/images.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
-fx-image: url("../../images/remove.png");
}

#image-edit {
-fx-image: url("../../images/edit.png");
}

#image-buy-white {
-fx-image: url("../../images/buy_white.png");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.BsqSwapOfferDetailsWindow;
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
import bisq.desktop.main.portfolio.PortfolioView;
import bisq.desktop.main.portfolio.editoffer.EditOfferView;
import bisq.desktop.util.CssTheme;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.GUIUtil;
Expand All @@ -58,6 +60,7 @@
import bisq.core.offer.OfferDirection;
import bisq.core.offer.OfferFilterService;
import bisq.core.offer.OfferRestrictions;
import bisq.core.offer.OpenOffer;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.user.DontShowAgainLookup;
Expand Down Expand Up @@ -732,6 +735,13 @@ private void onRemoveOpenOffer(Offer offer) {
}
}

private void onEditOpenOffer(Offer offer) {
OpenOffer openOffer = model.getOpenOffer(offer);
if (openOffer != null) {
navigation.navigateToWithData(openOffer, MainView.class, PortfolioView.class, EditOfferView.class);
}
}

private void doRemoveOffer(Offer offer) {
String key = "WithdrawFundsAfterRemoveOfferInfo";
model.onRemoveOpenOffer(offer,
Expand Down Expand Up @@ -1080,15 +1090,32 @@ private TableColumn<OfferBookListItem, OfferBookListItem> getActionColumn() {
@Override
public TableCell<OfferBookListItem, OfferBookListItem> call(TableColumn<OfferBookListItem, OfferBookListItem> column) {
return new TableCell<>() {
final ImageView iconView = new ImageView();
final AutoTooltipButton button = new AutoTooltipButton();
OfferFilterService.Result canTakeOfferResult = null;

final ImageView iconView = new ImageView();
final AutoTooltipButton button = new AutoTooltipButton();
{
button.setGraphic(iconView);
button.setMinWidth(200);
button.setMaxWidth(Double.MAX_VALUE);
button.setGraphicTextGap(10);
button.setPrefWidth(10000);
}

final ImageView iconView2 = new ImageView();
final AutoTooltipButton button2 = new AutoTooltipButton();
{
button2.setGraphic(iconView2);
button2.setGraphicTextGap(10);
button2.setPrefWidth(10000);
}

final HBox hbox = new HBox();
{
hbox.setSpacing(8);
hbox.setAlignment(Pos.CENTER);
hbox.getChildren().add(button);
hbox.getChildren().add(button2);
HBox.setHgrow(button, Priority.ALWAYS);
HBox.setHgrow(button2, Priority.ALWAYS);
}

@Override
Expand All @@ -1100,6 +1127,7 @@ public void updateItem(final OfferBookListItem item, boolean empty) {
Offer offer = item.getOffer();
boolean myOffer = model.isMyOffer(offer);

// https://github.com/bisq-network/bisq/issues/4986
if (tableRow != null) {
canTakeOfferResult = model.offerFilterService.canTakeOffer(offer, false);
tableRow.setOpacity(canTakeOfferResult.isValid() || myOffer ? 1 : 0.4);
Expand Down Expand Up @@ -1128,6 +1156,13 @@ public void updateItem(final OfferBookListItem item, boolean empty) {
button.setId(null);
button.setStyle(CssTheme.isDarkTheme() ? "-fx-text-fill: white" : "-fx-text-fill: #444444");
button.setOnAction(e -> onRemoveOpenOffer(offer));

iconView2.setId("image-edit");
button2.updateText(Res.get("shared.edit"));
button2.setId(null);
button2.setStyle(CssTheme.isDarkTheme() ? "-fx-text-fill: white" : "-fx-text-fill: #444444");
button2.setOnAction(e -> onEditOpenOffer(offer));
button2.setManaged(true);
} else {
boolean isSellOffer = offer.getDirection() == OfferDirection.SELL;
iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
Expand All @@ -1144,6 +1179,7 @@ public void updateItem(final OfferBookListItem item, boolean empty) {
}
button.setTooltip(new Tooltip(Res.get("offerbook.takeOfferButton.tooltip", model.getDirectionLabelTooltip(offer))));
button.setOnAction(e -> onTakeOffer(offer));
button2.setManaged(false);
}

if (!myOffer) {
Expand All @@ -1158,7 +1194,7 @@ public void updateItem(final OfferBookListItem item, boolean empty) {

button.updateText(title);
setPadding(new Insets(0, 15, 0, 0));
setGraphic(button);
setGraphic(hbox);
} else {
setGraphic(null);
button.setOnAction(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import bisq.core.offer.Offer;
import bisq.core.offer.OfferDirection;
import bisq.core.offer.OfferFilterService;
import bisq.core.offer.OpenOffer;
import bisq.core.offer.OpenOfferManager;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.PaymentAccountUtil;
Expand Down Expand Up @@ -711,4 +712,8 @@ private void updateSelectedTradeCurrency() {
}
tradeCurrencyCode.set(selectedTradeCurrency.getCode());
}

public OpenOffer getOpenOffer(Offer offer) {
return openOfferManager.getOpenOfferById(offer.getId()).orElse(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import bisq.core.locale.Res;
import bisq.core.offer.OpenOffer;
import bisq.core.offer.OpenOfferManager;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.trade.bisq_v1.FailedTradesManager;
import bisq.core.trade.model.bisq_v1.Trade;
Expand Down Expand Up @@ -67,6 +68,7 @@ public class PortfolioView extends ActivatableView<TabPane, Void> {
private final CachingViewLoader viewLoader;
private final Navigation navigation;
private final FailedTradesManager failedTradesManager;
private final OpenOfferManager openOfferManager;
private EditOfferView editOfferView;
private DuplicateOfferView duplicateOfferView;
private boolean editOpenOfferViewOpen;
Expand All @@ -75,10 +77,12 @@ public class PortfolioView extends ActivatableView<TabPane, Void> {
private int initialTabCount = 0;

@Inject
public PortfolioView(CachingViewLoader viewLoader, Navigation navigation, FailedTradesManager failedTradesManager) {
public PortfolioView(CachingViewLoader viewLoader, Navigation navigation, FailedTradesManager failedTradesManager,
OpenOfferManager openOfferManager) {
this.viewLoader = viewLoader;
this.navigation = navigation;
this.failedTradesManager = failedTradesManager;
this.openOfferManager = openOfferManager;
}

@Override
Expand Down Expand Up @@ -209,6 +213,9 @@ private void loadView(Class<? extends View> viewClass, @Nullable Object data) {
} else if (view instanceof FailedTradesView) {
currentTab = failedTradesTab;
} else if (view instanceof EditOfferView) {
if (data instanceof OpenOffer) {
openOffer = (OpenOffer) data;
}
if (openOffer != null) {
if (editOfferView == null) {
editOfferView = (EditOfferView) view;
Expand Down
Binary file added desktop/src/main/resources/images/edit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added desktop/src/main/resources/images/edit@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.