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

Cash By Mail currency selection to use drop down combo #5114

Merged
merged 1 commit into from Jan 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.CashByMailAccount;
import bisq.core.payment.payload.PaymentAccountPayload;
Expand All @@ -32,9 +33,10 @@
import com.jfoenix.controls.JFXTextArea;

import javafx.scene.control.TextArea;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;

import javafx.collections.FXCollections;

import static bisq.desktop.util.FormBuilder.*;

public class CashByMailForm extends PaymentMethodForm {
Expand Down Expand Up @@ -69,24 +71,13 @@ public CashByMailForm(PaymentAccount paymentAccount,
this.cashByMailAccount = (CashByMailAccount) paymentAccount;
}

private void addCurrenciesGrid(boolean isEditable) {
FlowPane flowPane = addTopLabelFlowPane(gridPane, ++gridRow,
Res.get("payment.supportedCurrenciesForReceiver"), 20, 20).second;

if (isEditable) {
flowPane.setId("flow-pane-checkboxes-bg");
} else {
flowPane.setId("flow-pane-checkboxes-non-editable-bg");
}

CurrencyUtil.getMainFiatCurrencies().forEach(currency ->
fillUpFlowPaneWithCurrencies(isEditable, flowPane, currency, paymentAccount));
}

@Override
public void addFormForAddAccount() {
gridRowFrom = gridRow + 1;

addTradeCurrencyComboBox();
currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllSortedFiatCurrencies()));

contactField = addInputTextField(gridPane, ++gridRow,
Res.get("payment.cashByMail.contact"));
contactField.setPromptText(Res.get("payment.cashByMail.contact.prompt"));
Expand All @@ -113,8 +104,6 @@ public void addFormForAddAccount() {
updateFromInputs();
});

addCurrenciesGrid(true);

addLimitations(false);
addAccountNameTextFieldWithAutoFillToggleButton();
}
Expand All @@ -131,6 +120,11 @@ public void addFormForDisplayAccount() {
cashByMailAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
Res.get(cashByMailAccount.getPaymentMethod().getId()));

TradeCurrency tradeCurrency = paymentAccount.getSingleTradeCurrency();
String nameAndCode = tradeCurrency != null ? tradeCurrency.getNameAndCode() : "";
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);

addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.f2f.contact"),
cashByMailAccount.getContact());
TextArea textArea = addCompactTopLabelTextArea(gridPane, ++gridRow, Res.get("payment.postal.address"), "").second;
Expand All @@ -143,8 +137,6 @@ public void addFormForDisplayAccount() {
textAreaExtra.setMinHeight(70);
textAreaExtra.setEditable(false);

addCurrenciesGrid(false);

addLimitations(true);
}

Expand All @@ -153,6 +145,6 @@ public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& !postalAddressTextArea.getText().isEmpty()
&& inputValidator.validate(cashByMailAccount.getContact()).isValid
&& paymentAccount.getTradeCurrencies().size() > 0);
&& paymentAccount.getSingleTradeCurrency() != null);
}
}