Add news badge for instant trade

This commit is contained in:
Christoph Atteneder 2019-03-05 15:02:37 +01:00
parent 95d8f514ad
commit 549348aee0
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B
2 changed files with 39 additions and 4 deletions

View File

@ -18,6 +18,7 @@
package bisq.desktop.components.paymentmethods;
import bisq.desktop.components.InputTextField;
import bisq.desktop.components.NewBadge;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.Layout;
@ -34,6 +35,7 @@ import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.AssetsAccountPayload;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.validation.AltCoinAddressValidator;
import bisq.core.user.Preferences;
import bisq.core.util.BSFormatter;
import bisq.core.util.validation.InputValidator;
@ -45,8 +47,13 @@ import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.collections.FXCollections;
import javafx.util.StringConverter;
@ -55,14 +62,17 @@ import java.util.Optional;
import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField;
import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextFieldWithCopyIcon;
import static bisq.desktop.util.FormBuilder.addLabelCheckBox;
import static bisq.desktop.util.FormBuilder.addTopLabelTextField;
import static bisq.desktop.util.GUIUtil.getComboBoxButtonCell;
public class AssetsForm extends PaymentMethodForm {
public static final String INSTANT_TRADE_NEWS = "instantTradeNews0.9.5";
private final AssetAccount assetAccount;
private final AltCoinAddressValidator altCoinAddressValidator;
private final AssetService assetService;
private final FilterManager filterManager;
private final Preferences preferences;
private InputTextField addressInputTextField;
private CheckBox tradeInstantCheckBox;
@ -85,12 +95,14 @@ public class AssetsForm extends PaymentMethodForm {
int gridRow,
BSFormatter formatter,
AssetService assetService,
FilterManager filterManager) {
FilterManager filterManager,
Preferences preferences) {
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
this.assetAccount = (AssetAccount) paymentAccount;
this.altCoinAddressValidator = altCoinAddressValidator;
this.assetService = assetService;
this.filterManager = filterManager;
this.preferences = preferences;
tradeInstant = paymentAccount instanceof InstantCryptoCurrencyAccount;
}
@ -102,7 +114,7 @@ public class AssetsForm extends PaymentMethodForm {
addTradeCurrencyComboBox();
currencyComboBox.setPrefWidth(250);
tradeInstantCheckBox = FormBuilder.addLabelCheckBox(gridPane, ++gridRow,
tradeInstantCheckBox = addLabelCheckBox(gridPane, ++gridRow,
Res.get("payment.altcoin.tradeInstantCheckbox"), 10);
tradeInstantCheckBox.setSelected(tradeInstant);
tradeInstantCheckBox.setOnAction(e -> {
@ -111,6 +123,20 @@ public class AssetsForm extends PaymentMethodForm {
new Popup<>().information(Res.get("payment.altcoin.tradeInstant.popup")).show();
});
// add new badge for this new feature for this release
// TODO: remove it with 0.9.6+
gridPane.getChildren().remove(tradeInstantCheckBox);
tradeInstantCheckBox.setPadding(new Insets(0, 40, 0, 0));
NewBadge instantTradeNewsBadge = new NewBadge(tradeInstantCheckBox, INSTANT_TRADE_NEWS, preferences);
instantTradeNewsBadge.setAlignment(Pos.CENTER_LEFT);
instantTradeNewsBadge.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
GridPane.setRowIndex(instantTradeNewsBadge, gridRow);
GridPane.setHgrow(instantTradeNewsBadge, Priority.NEVER);
GridPane.setMargin(instantTradeNewsBadge, new Insets(10, 0, 0, 0));
gridPane.getChildren().add(instantTradeNewsBadge);
addressInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow,
Res.get("payment.altcoin.address"));
addressInputTextField.setValidator(altCoinAddressValidator);

View File

@ -37,6 +37,7 @@ import bisq.core.payment.PaymentAccount;
import bisq.core.payment.PaymentAccountFactory;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.payment.validation.AltCoinAddressValidator;
import bisq.core.user.Preferences;
import bisq.core.util.BSFormatter;
import bisq.core.util.validation.InputValidator;
@ -60,6 +61,7 @@ import javafx.collections.ObservableList;
import java.util.Optional;
import static bisq.desktop.components.paymentmethods.AssetsForm.INSTANT_TRADE_NEWS;
import static bisq.desktop.util.FormBuilder.add2ButtonsAfterGroup;
import static bisq.desktop.util.FormBuilder.add3ButtonsAfterGroup;
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
@ -74,6 +76,7 @@ public class AltCoinAccountsView extends PaymentAccountsView<GridPane, AltCoinAc
private final AssetService assetService;
private final FilterManager filterManager;
private final BSFormatter formatter;
private final Preferences preferences;
private PaymentMethodForm paymentMethodForm;
private TitledGroupBg accountTitledGroupBg;
@ -87,7 +90,8 @@ public class AltCoinAccountsView extends PaymentAccountsView<GridPane, AltCoinAc
AccountAgeWitnessService accountAgeWitnessService,
AssetService assetService,
FilterManager filterManager,
BSFormatter formatter) {
BSFormatter formatter,
Preferences preferences) {
super(model);
this.inputValidator = inputValidator;
@ -96,6 +100,7 @@ public class AltCoinAccountsView extends PaymentAccountsView<GridPane, AltCoinAc
this.assetService = assetService;
this.filterManager = filterManager;
this.formatter = formatter;
this.preferences = preferences;
}
@Override
@ -148,11 +153,15 @@ public class AltCoinAccountsView extends PaymentAccountsView<GridPane, AltCoinAc
} else {
new Popup<>().warning(Res.get("shared.accountNameAlreadyUsed")).show();
}
preferences.dontShowAgain(INSTANT_TRADE_NEWS, true);
}
}
private void onCancelNewAccount() {
removeNewAccountForm();
preferences.dontShowAgain(INSTANT_TRADE_NEWS, true);
}
///////////////////////////////////////////////////////////////////////////////////////////
@ -228,7 +237,7 @@ public class AltCoinAccountsView extends PaymentAccountsView<GridPane, AltCoinAc
private PaymentMethodForm getPaymentMethodForm(PaymentAccount paymentAccount) {
return new AssetsForm(paymentAccount, accountAgeWitnessService, altCoinAddressValidator,
inputValidator, root, gridRow, formatter, assetService, filterManager);
inputValidator, root, gridRow, formatter, assetService, filterManager, preferences);
}
private void removeNewAccountForm() {