mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Merge pull request #5316 from chimp1984/add-pay-from-bsq-wallet-button
Add pay from BSQ wallet button
This commit is contained in:
commit
16230c7723
5 changed files with 68 additions and 9 deletions
|
@ -672,6 +672,7 @@ portfolio.pending.step2_buyer.amountToTransfer=Amount to transfer
|
||||||
portfolio.pending.step2_buyer.sellersAddress=Seller''s {0} address
|
portfolio.pending.step2_buyer.sellersAddress=Seller''s {0} address
|
||||||
portfolio.pending.step2_buyer.buyerAccount=Your payment account to be used
|
portfolio.pending.step2_buyer.buyerAccount=Your payment account to be used
|
||||||
portfolio.pending.step2_buyer.paymentStarted=Payment started
|
portfolio.pending.step2_buyer.paymentStarted=Payment started
|
||||||
|
portfolio.pending.step2_buyer.fillInBsqWallet=Pay from BSQ wallet
|
||||||
portfolio.pending.step2_buyer.warn=You still have not done your {0} payment!\nPlease note that the trade has to be completed by {1}.
|
portfolio.pending.step2_buyer.warn=You still have not done your {0} payment!\nPlease note that the trade has to be completed by {1}.
|
||||||
portfolio.pending.step2_buyer.openForDispute=You have not completed your payment!\nThe max. period for the trade has elapsed.\
|
portfolio.pending.step2_buyer.openForDispute=You have not completed your payment!\nThe max. period for the trade has elapsed.\
|
||||||
Please contact the mediator for assistance.
|
Please contact the mediator for assistance.
|
||||||
|
|
|
@ -34,6 +34,7 @@ import bisq.desktop.main.dao.wallet.tx.BsqTxView;
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
|
|
||||||
import bisq.common.app.DevEnv;
|
import bisq.common.app.DevEnv;
|
||||||
|
import bisq.common.util.Tuple2;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -46,6 +47,8 @@ import javafx.scene.layout.VBox;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@FxmlView
|
@FxmlView
|
||||||
public class BsqWalletView extends ActivatableView<AnchorPane, Void> {
|
public class BsqWalletView extends ActivatableView<AnchorPane, Void> {
|
||||||
|
|
||||||
|
@ -71,12 +74,24 @@ public class BsqWalletView extends ActivatableView<AnchorPane, Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
listener = viewPath -> {
|
listener = new Navigation.Listener() {
|
||||||
|
@Override
|
||||||
|
public void onNavigationRequested(ViewPath viewPath) {
|
||||||
if (viewPath.size() != 4 || viewPath.indexOf(BsqWalletView.class) != 2)
|
if (viewPath.size() != 4 || viewPath.indexOf(BsqWalletView.class) != 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
selectedViewClass = viewPath.tip();
|
selectedViewClass = viewPath.tip();
|
||||||
loadView(selectedViewClass);
|
loadView(selectedViewClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNavigationRequested(ViewPath viewPath, @Nullable Object data) {
|
||||||
|
if (viewPath.size() != 4 || viewPath.indexOf(BsqWalletView.class) != 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectedViewClass = viewPath.tip();
|
||||||
|
loadView(selectedViewClass, data);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
toggleGroup = new ToggleGroup();
|
toggleGroup = new ToggleGroup();
|
||||||
|
@ -126,12 +141,23 @@ public class BsqWalletView extends ActivatableView<AnchorPane, Void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadView(Class<? extends View> viewClass) {
|
private void loadView(Class<? extends View> viewClass) {
|
||||||
|
loadView(viewClass, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadView(Class<? extends View> viewClass, @Nullable Object data) {
|
||||||
View view = viewLoader.load(viewClass);
|
View view = viewLoader.load(viewClass);
|
||||||
content.getChildren().setAll(view.getRoot());
|
content.getChildren().setAll(view.getRoot());
|
||||||
|
|
||||||
if (view instanceof BsqSendView) toggleGroup.selectToggle(send);
|
if (view instanceof BsqSendView) {
|
||||||
else if (view instanceof BsqReceiveView) toggleGroup.selectToggle(receive);
|
toggleGroup.selectToggle(send);
|
||||||
else if (view instanceof BsqTxView) toggleGroup.selectToggle(transactions);
|
if (data instanceof Tuple2) {
|
||||||
|
((BsqSendView) view).fillFromTradeData((Tuple2) data);
|
||||||
|
}
|
||||||
|
} else if (view instanceof BsqReceiveView) {
|
||||||
|
toggleGroup.selectToggle(receive);
|
||||||
|
} else if (view instanceof BsqTxView) {
|
||||||
|
toggleGroup.selectToggle(transactions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends View> getSelectedViewClass() {
|
public Class<? extends View> getSelectedViewClass() {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import bisq.desktop.main.overlays.popups.Popup;
|
||||||
import bisq.desktop.main.overlays.windows.TxDetailsBsq;
|
import bisq.desktop.main.overlays.windows.TxDetailsBsq;
|
||||||
import bisq.desktop.main.overlays.windows.TxInputSelectionWindow;
|
import bisq.desktop.main.overlays.windows.TxInputSelectionWindow;
|
||||||
import bisq.desktop.main.overlays.windows.WalletPasswordWindow;
|
import bisq.desktop.main.overlays.windows.WalletPasswordWindow;
|
||||||
|
import bisq.desktop.util.DisplayUtils;
|
||||||
import bisq.desktop.util.FormBuilder;
|
import bisq.desktop.util.FormBuilder;
|
||||||
import bisq.desktop.util.GUIUtil;
|
import bisq.desktop.util.GUIUtil;
|
||||||
import bisq.desktop.util.Layout;
|
import bisq.desktop.util.Layout;
|
||||||
|
@ -48,6 +49,7 @@ import bisq.core.btc.wallet.TxBroadcaster;
|
||||||
import bisq.core.btc.wallet.WalletsManager;
|
import bisq.core.btc.wallet.WalletsManager;
|
||||||
import bisq.core.dao.state.model.blockchain.TxType;
|
import bisq.core.dao.state.model.blockchain.TxType;
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
|
import bisq.core.monetary.Volume;
|
||||||
import bisq.core.user.DontShowAgainLookup;
|
import bisq.core.user.DontShowAgainLookup;
|
||||||
import bisq.core.user.Preferences;
|
import bisq.core.user.Preferences;
|
||||||
import bisq.core.util.FormattingUtils;
|
import bisq.core.util.FormattingUtils;
|
||||||
|
@ -253,6 +255,11 @@ public class BsqSendView extends ActivatableView<GridPane, Void> implements BsqB
|
||||||
setSendBtcGroupVisibleState(availableNonBsqBalance.isPositive());
|
setSendBtcGroupVisibleState(availableNonBsqBalance.isPositive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fillFromTradeData(Tuple2<Volume, String> tuple) {
|
||||||
|
amountInputTextField.setText(DisplayUtils.formatVolume(tuple.first));
|
||||||
|
receiversAddressInputTextField.setText(tuple.second);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateBsqValidator(Coin availableConfirmedBalance) {
|
private void updateBsqValidator(Coin availableConfirmedBalance) {
|
||||||
bsqValidator.setAvailableBalance(availableConfirmedBalance);
|
bsqValidator.setAvailableBalance(availableConfirmedBalance);
|
||||||
boolean isValid = bsqAddressValidator.validate(receiversAddressInputTextField.getText()).isValid &&
|
boolean isValid = bsqAddressValidator.validate(receiversAddressInputTextField.getText()).isValid &&
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package bisq.desktop.main.portfolio.pendingtrades;
|
package bisq.desktop.main.portfolio.pendingtrades;
|
||||||
|
|
||||||
|
import bisq.desktop.Navigation;
|
||||||
import bisq.desktop.common.model.ActivatableWithDataModel;
|
import bisq.desktop.common.model.ActivatableWithDataModel;
|
||||||
import bisq.desktop.common.model.ViewModel;
|
import bisq.desktop.common.model.ViewModel;
|
||||||
import bisq.desktop.util.DisplayUtils;
|
import bisq.desktop.util.DisplayUtils;
|
||||||
|
@ -101,6 +102,8 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
||||||
private final TradeUtil tradeUtil;
|
private final TradeUtil tradeUtil;
|
||||||
public final ClockWatcher clockWatcher;
|
public final ClockWatcher clockWatcher;
|
||||||
@Getter
|
@Getter
|
||||||
|
private final Navigation navigation;
|
||||||
|
@Getter
|
||||||
private final User user;
|
private final User user;
|
||||||
|
|
||||||
private final ObjectProperty<BuyerState> buyerState = new SimpleObjectProperty<>();
|
private final ObjectProperty<BuyerState> buyerState = new SimpleObjectProperty<>();
|
||||||
|
@ -126,6 +129,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
||||||
TradeUtil tradeUtil,
|
TradeUtil tradeUtil,
|
||||||
AccountAgeWitnessService accountAgeWitnessService,
|
AccountAgeWitnessService accountAgeWitnessService,
|
||||||
ClockWatcher clockWatcher,
|
ClockWatcher clockWatcher,
|
||||||
|
Navigation navigation,
|
||||||
User user) {
|
User user) {
|
||||||
super(dataModel);
|
super(dataModel);
|
||||||
|
|
||||||
|
@ -138,6 +142,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
||||||
this.tradeUtil = tradeUtil;
|
this.tradeUtil = tradeUtil;
|
||||||
this.accountAgeWitnessService = accountAgeWitnessService;
|
this.accountAgeWitnessService = accountAgeWitnessService;
|
||||||
this.clockWatcher = clockWatcher;
|
this.clockWatcher = clockWatcher;
|
||||||
|
this.navigation = navigation;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package bisq.desktop.main.portfolio.pendingtrades.steps.buyer;
|
package bisq.desktop.main.portfolio.pendingtrades.steps.buyer;
|
||||||
|
|
||||||
|
import bisq.desktop.components.AutoTooltipButton;
|
||||||
import bisq.desktop.components.BusyAnimation;
|
import bisq.desktop.components.BusyAnimation;
|
||||||
import bisq.desktop.components.TextFieldWithCopyIcon;
|
import bisq.desktop.components.TextFieldWithCopyIcon;
|
||||||
import bisq.desktop.components.TitledGroupBg;
|
import bisq.desktop.components.TitledGroupBg;
|
||||||
|
@ -50,6 +51,10 @@ import bisq.desktop.components.paymentmethods.USPostalMoneyOrderForm;
|
||||||
import bisq.desktop.components.paymentmethods.UpholdForm;
|
import bisq.desktop.components.paymentmethods.UpholdForm;
|
||||||
import bisq.desktop.components.paymentmethods.WeChatPayForm;
|
import bisq.desktop.components.paymentmethods.WeChatPayForm;
|
||||||
import bisq.desktop.components.paymentmethods.WesternUnionForm;
|
import bisq.desktop.components.paymentmethods.WesternUnionForm;
|
||||||
|
import bisq.desktop.main.MainView;
|
||||||
|
import bisq.desktop.main.dao.DaoView;
|
||||||
|
import bisq.desktop.main.dao.wallet.BsqWalletView;
|
||||||
|
import bisq.desktop.main.dao.wallet.send.BsqSendView;
|
||||||
import bisq.desktop.main.overlays.popups.Popup;
|
import bisq.desktop.main.overlays.popups.Popup;
|
||||||
import bisq.desktop.main.overlays.windows.SetXmrTxKeyWindow;
|
import bisq.desktop.main.overlays.windows.SetXmrTxKeyWindow;
|
||||||
import bisq.desktop.main.portfolio.pendingtrades.PendingTradesViewModel;
|
import bisq.desktop.main.portfolio.pendingtrades.PendingTradesViewModel;
|
||||||
|
@ -59,6 +64,7 @@ import bisq.desktop.util.Layout;
|
||||||
import bisq.desktop.util.Transitions;
|
import bisq.desktop.util.Transitions;
|
||||||
|
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
|
import bisq.core.monetary.Volume;
|
||||||
import bisq.core.network.MessageState;
|
import bisq.core.network.MessageState;
|
||||||
import bisq.core.offer.Offer;
|
import bisq.core.offer.Offer;
|
||||||
import bisq.core.payment.PaymentAccount;
|
import bisq.core.payment.PaymentAccount;
|
||||||
|
@ -81,6 +87,7 @@ import bisq.core.user.DontShowAgainLookup;
|
||||||
import bisq.common.Timer;
|
import bisq.common.Timer;
|
||||||
import bisq.common.UserThread;
|
import bisq.common.UserThread;
|
||||||
import bisq.common.app.DevEnv;
|
import bisq.common.app.DevEnv;
|
||||||
|
import bisq.common.util.Tuple2;
|
||||||
import bisq.common.util.Tuple4;
|
import bisq.common.util.Tuple4;
|
||||||
|
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
@ -108,6 +115,7 @@ public class BuyerStep2View extends TradeStepView {
|
||||||
private BusyAnimation busyAnimation;
|
private BusyAnimation busyAnimation;
|
||||||
private Subscription tradeStatePropertySubscription;
|
private Subscription tradeStatePropertySubscription;
|
||||||
private Timer timeoutTimer;
|
private Timer timeoutTimer;
|
||||||
|
private AutoTooltipButton fillBsqButton;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor, Initialisation
|
// Constructor, Initialisation
|
||||||
|
@ -342,11 +350,23 @@ public class BuyerStep2View extends TradeStepView {
|
||||||
Tuple4<Button, BusyAnimation, Label, HBox> tuple3 = addButtonBusyAnimationLabel(gridPane, ++gridRow, 0,
|
Tuple4<Button, BusyAnimation, Label, HBox> tuple3 = addButtonBusyAnimationLabel(gridPane, ++gridRow, 0,
|
||||||
Res.get("portfolio.pending.step2_buyer.paymentStarted"), 10);
|
Res.get("portfolio.pending.step2_buyer.paymentStarted"), 10);
|
||||||
|
|
||||||
GridPane.setColumnSpan(tuple3.fourth, 2);
|
HBox hBox = tuple3.fourth;
|
||||||
|
GridPane.setColumnSpan(hBox, 2);
|
||||||
confirmButton = tuple3.first;
|
confirmButton = tuple3.first;
|
||||||
confirmButton.setOnAction(e -> onPaymentStarted());
|
confirmButton.setOnAction(e -> onPaymentStarted());
|
||||||
busyAnimation = tuple3.second;
|
busyAnimation = tuple3.second;
|
||||||
statusLabel = tuple3.third;
|
statusLabel = tuple3.third;
|
||||||
|
|
||||||
|
if (trade.getOffer().getCurrencyCode().equals("BSQ")) {
|
||||||
|
fillBsqButton = new AutoTooltipButton(Res.get("portfolio.pending.step2_buyer.fillInBsqWallet"));
|
||||||
|
hBox.getChildren().add(1, fillBsqButton);
|
||||||
|
fillBsqButton.setOnAction(e -> {
|
||||||
|
AssetsAccountPayload assetsAccountPayload = (AssetsAccountPayload) paymentAccountPayload;
|
||||||
|
Tuple2<Volume, String> data = new Tuple2<>(trade.getTradeVolume(), assetsAccountPayload.getAddress());
|
||||||
|
model.getNavigation().navigateToWithData(data, MainView.class, DaoView.class, BsqWalletView.class,
|
||||||
|
BsqSendView.class);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Reference in a new issue