mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 14:42:37 +01:00
Refactor auto-closing of sell BTC offer view
This commit is contained in:
parent
d2baabc180
commit
ee30cd9739
2 changed files with 13 additions and 8 deletions
|
@ -168,7 +168,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
|||
private ChangeListener<String> tradeCurrencyCodeListener, errorMessageListener,
|
||||
marketPriceMarginListener, volumeListener, buyerSecurityDepositInBTCListener;
|
||||
private ChangeListener<Number> marketPriceAvailableListener;
|
||||
private Navigation.Listener navigationWithCloseListener;
|
||||
private Navigation.Listener closeViewListener;
|
||||
private EventHandler<ActionEvent> currencyComboBoxSelectionHandler, paymentAccountsComboBoxSelectionHandler;
|
||||
private OfferView.CloseHandler closeHandler;
|
||||
|
||||
|
@ -914,10 +914,8 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
|||
}
|
||||
});
|
||||
|
||||
navigationWithCloseListener = (path, data) -> {
|
||||
log.warn("*** target path={}, data={}, dir={}", path, data, model.getDataModel().getDirection());
|
||||
if ("closeOfferView".equals(data)) {
|
||||
log.warn("*** WILL CLOSE");
|
||||
closeViewListener = (path, data) -> {
|
||||
if (OfferViewUtil.isCloseView((String) data)) {
|
||||
close();
|
||||
}
|
||||
};
|
||||
|
@ -978,7 +976,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
|||
paymentAccountsComboBox.setOnAction(paymentAccountsComboBoxSelectionHandler);
|
||||
currencyComboBox.setOnAction(currencyComboBoxSelectionHandler);
|
||||
|
||||
navigation.addListener(navigationWithCloseListener);
|
||||
navigation.addListener(closeViewListener);
|
||||
}
|
||||
|
||||
private void removeListeners() {
|
||||
|
@ -1015,7 +1013,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
|||
paymentAccountsComboBox.setOnAction(null);
|
||||
currencyComboBox.setOnAction(null);
|
||||
|
||||
navigation.removeListener(navigationWithCloseListener);
|
||||
navigation.removeListener(closeViewListener);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -46,6 +46,9 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
// Shared utils for Views
|
||||
public class OfferViewUtil {
|
||||
|
||||
public static final String CLOSE_VIEW = "closeView";
|
||||
|
||||
public static Label createPopOverLabel(String text) {
|
||||
final Label label = new Label(text);
|
||||
label.setPrefWidth(300);
|
||||
|
@ -101,7 +104,7 @@ public class OfferViewUtil {
|
|||
preferences.setSellScreenCurrencyCode("BSQ");
|
||||
navigation.navigateToWithData(
|
||||
// FIXME: replace "closeOfferView" with a more unique object?
|
||||
directionClosure.getDirection() == OfferPayload.Direction.SELL ? "closeOfferView" : null,
|
||||
directionClosure.getDirection() == OfferPayload.Direction.SELL ? CLOSE_VIEW : null,
|
||||
MainView.class, SellOfferView.class, OfferBookView.class);
|
||||
}).show());
|
||||
|
||||
|
@ -112,4 +115,8 @@ public class OfferViewUtil {
|
|||
|
||||
return new Tuple2<>(buyBsqButton, buyBsqButtonVBox);
|
||||
}
|
||||
|
||||
public static boolean isCloseView(String data) {
|
||||
return CLOSE_VIEW.equals(data);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue