mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 14:42:37 +01:00
adjust bank account combobox and balance label
This commit is contained in:
parent
5fa7872606
commit
4e2f977ff0
7 changed files with 103 additions and 81 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
## About Bitsquare
|
||||
Bitsquare is a **P2P Fiat-BTC Exchange**.
|
||||
It allows to trade fiat money (USD, EURO, ...) for Bitcoins without relying on a centralized exchange like MtGox.
|
||||
It allows to trade fiat money (USD, EURO, ...) for Bitcoins without relying on a centralized exchange like Coinbase or BitStamp.
|
||||
Instead, all participants form a peer to peer market.
|
||||
|
||||
## Dependencies
|
||||
|
|
|
@ -473,13 +473,9 @@ public class WalletFacade
|
|||
{
|
||||
Coin balance;
|
||||
if (balanceListener.getAddress() != null)
|
||||
{
|
||||
balance = getBalanceForAddress(balanceListener.getAddress());
|
||||
}
|
||||
else
|
||||
{
|
||||
balance = getWalletBalance();
|
||||
}
|
||||
|
||||
balanceListener.onBalanceChanged(balance);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import io.bitsquare.btc.listeners.BalanceListener;
|
|||
import io.bitsquare.di.GuiceFXMLLoader;
|
||||
import io.bitsquare.gui.components.NetworkSyncPane;
|
||||
import io.bitsquare.gui.orders.OrdersController;
|
||||
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.gui.util.Profiler;
|
||||
import io.bitsquare.gui.util.Transitions;
|
||||
|
@ -59,6 +60,7 @@ public class MainController extends ViewController
|
|||
private Pane ordersButtonButtonHolder;
|
||||
private boolean messageFacadeInited;
|
||||
private boolean walletFacadeInited;
|
||||
private VBox accountComboBoxHolder;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -272,8 +274,16 @@ public class MainController extends ViewController
|
|||
viewBuilder.leftNavPane.getChildren().add(msgButtonHolder);
|
||||
|
||||
addBalanceInfo(viewBuilder.rightNavPane);
|
||||
|
||||
addAccountComboBox(viewBuilder.rightNavPane);
|
||||
|
||||
user.getBankAccountsSizeProperty().addListener((observableValue, oldValue, newValue) -> {
|
||||
if ((int) newValue == 2)
|
||||
viewBuilder.rightNavPane.getChildren().add(1, accountComboBoxHolder);// accountComboBoxHolder.setVisible(true);
|
||||
else if ((int) newValue < 2)
|
||||
viewBuilder.rightNavPane.getChildren().remove(accountComboBoxHolder);//accountComboBoxHolder.setVisible(false);
|
||||
});
|
||||
|
||||
settingsButton = addNavButton(viewBuilder.rightNavPane, "Settings", NavigationItem.SETTINGS);
|
||||
|
||||
Platform.runLater(this::onNavigationAdded);
|
||||
|
@ -358,71 +368,71 @@ public class MainController extends ViewController
|
|||
balanceTextField.setEditable(false);
|
||||
balanceTextField.setPrefWidth(110);
|
||||
balanceTextField.setId("nav-balance-label");
|
||||
balanceTextField.setText(walletFacade.getWalletBalance().toFriendlyString());
|
||||
balanceTextField.setText(BitSquareFormatter.formatCoinWithCode(walletFacade.getWalletBalance()));
|
||||
walletFacade.addBalanceListener(new BalanceListener()
|
||||
{
|
||||
@Override
|
||||
public void onBalanceChanged(Coin balance)
|
||||
{
|
||||
balanceTextField.setText(balance.toFriendlyString());
|
||||
balanceTextField.setText(BitSquareFormatter.formatCoinWithCode(walletFacade.getWalletBalance()));
|
||||
}
|
||||
});
|
||||
|
||||
final HBox hBox = new HBox();
|
||||
hBox.setSpacing(2);
|
||||
hBox.getChildren().setAll(balanceTextField);
|
||||
|
||||
final Label titleLabel = new Label("Balance");
|
||||
titleLabel.prefWidthProperty().bind(balanceTextField.widthProperty());
|
||||
titleLabel.setMouseTransparent(true);
|
||||
titleLabel.setPrefWidth(90);
|
||||
titleLabel.setId("nav-button-label");
|
||||
|
||||
final VBox vBox = new VBox();
|
||||
vBox.setPadding(new Insets(12, 0, 0, 0));
|
||||
vBox.setSpacing(2);
|
||||
vBox.getChildren().setAll(hBox, titleLabel);
|
||||
vBox.getChildren().setAll(balanceTextField, titleLabel);
|
||||
parent.getChildren().add(vBox);
|
||||
}
|
||||
|
||||
private void addAccountComboBox(Pane parent)
|
||||
{
|
||||
if (user.getBankAccounts().size() > 1)
|
||||
final ComboBox<BankAccount> accountComboBox = new ComboBox<>(FXCollections.observableArrayList(user.getBankAccounts()));
|
||||
accountComboBox.setId("nav-account-combo-box");
|
||||
accountComboBox.setLayoutY(12);
|
||||
if (user.getCurrentBankAccount() != null)
|
||||
accountComboBox.getSelectionModel().select(user.getCurrentBankAccount());
|
||||
accountComboBox.valueProperty().addListener((ov, oldValue, newValue) -> user.setCurrentBankAccount(newValue));
|
||||
accountComboBox.setConverter(new StringConverter<BankAccount>()
|
||||
{
|
||||
final ComboBox<BankAccount> accountComboBox = new ComboBox<>(FXCollections.observableArrayList(user.getBankAccounts()));
|
||||
accountComboBox.setLayoutY(12);
|
||||
accountComboBox.setValue(user.getCurrentBankAccount());
|
||||
accountComboBox.valueProperty().addListener((ov, oldValue, newValue) -> user.setCurrentBankAccount(newValue));
|
||||
accountComboBox.setConverter(new StringConverter<BankAccount>()
|
||||
@Override
|
||||
public String toString(BankAccount bankAccount)
|
||||
{
|
||||
return bankAccount.getAccountTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(BankAccount bankAccount)
|
||||
{
|
||||
return bankAccount.getAccountTitle();
|
||||
}
|
||||
@Override
|
||||
public BankAccount fromString(String s)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
user.getSelectedBankAccountIndexProperty().addListener(observable -> accountComboBox.getSelectionModel().select(user.getCurrentBankAccount()));
|
||||
user.getBankAccountsSizeProperty().addListener(observable -> {
|
||||
accountComboBox.setItems(FXCollections.observableArrayList(user.getBankAccounts()));
|
||||
// need to delay it a bit otherwise it will not be set
|
||||
Platform.runLater(() -> accountComboBox.getSelectionModel().select(user.getCurrentBankAccount()));
|
||||
});
|
||||
|
||||
@Override
|
||||
public BankAccount fromString(String s)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
final Label titleLabel = new Label("Bank account");
|
||||
titleLabel.prefWidthProperty().bind(accountComboBox.widthProperty());
|
||||
titleLabel.setMouseTransparent(true);
|
||||
titleLabel.setId("nav-button-label");
|
||||
|
||||
accountComboBoxHolder = new VBox();
|
||||
accountComboBoxHolder.setPadding(new Insets(12, 0, 0, 0));
|
||||
accountComboBoxHolder.setSpacing(2);
|
||||
accountComboBoxHolder.getChildren().setAll(accountComboBox, titleLabel);
|
||||
|
||||
final Label titleLabel = new Label("Bank account");
|
||||
titleLabel.setMouseTransparent(true);
|
||||
titleLabel.setPrefWidth(90);
|
||||
titleLabel.setId("nav-button-label");
|
||||
|
||||
final VBox vBox = new VBox();
|
||||
vBox.setPadding(new Insets(12, 0, 0, 0));
|
||||
vBox.setSpacing(2);
|
||||
vBox.getChildren().setAll(accountComboBox, titleLabel);
|
||||
parent.getChildren().add(vBox);
|
||||
}
|
||||
if (user.getBankAccounts().size() > 1)
|
||||
parent.getChildren().add(accountComboBoxHolder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,17 +47,15 @@
|
|||
|
||||
#nav-button-label {
|
||||
-fx-font-size: 10;
|
||||
-fx-text-alignment: center;
|
||||
-fx-alignment: center;
|
||||
}
|
||||
|
||||
#nav-balance-label {
|
||||
-fx-font-weight: bold;
|
||||
-fx-text-alignment: right;
|
||||
-fx-alignment: center;
|
||||
}
|
||||
|
||||
#nav-balance-currency-label {
|
||||
-fx-text-alignment: left;
|
||||
#nav-account-combo-box .list-cell{
|
||||
-fx-alignment: center;
|
||||
}
|
||||
|
||||
.text-field:readonly {
|
||||
|
|
|
@ -229,7 +229,7 @@ public class SettingsController extends CachedViewController
|
|||
{
|
||||
user.setCurrentBankAccount(bankAccount);
|
||||
persistence.write(user);
|
||||
initBankAccountScreen();
|
||||
fillWithCurrentBankAccount();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -539,13 +539,8 @@ public class SettingsController extends CachedViewController
|
|||
|
||||
|
||||
// Bank Account Settings
|
||||
private void initBankAccountScreen()
|
||||
private void fillWithCurrentBankAccount()
|
||||
{
|
||||
initBankAccountComboBox();
|
||||
initBankAccountTypesComboBox();
|
||||
initBankAccountCurrencyComboBox();
|
||||
initBankAccountCountryComboBox();
|
||||
|
||||
BankAccount currentBankAccount = user.getCurrentBankAccount();
|
||||
if (currentBankAccount != null)
|
||||
{
|
||||
|
@ -560,6 +555,16 @@ public class SettingsController extends CachedViewController
|
|||
{
|
||||
resetBankAccountInput();
|
||||
}
|
||||
}
|
||||
|
||||
private void initBankAccountScreen()
|
||||
{
|
||||
initBankAccountComboBox();
|
||||
initBankAccountTypesComboBox();
|
||||
initBankAccountCurrencyComboBox();
|
||||
initBankAccountCountryComboBox();
|
||||
|
||||
fillWithCurrentBankAccount();
|
||||
|
||||
//TODO
|
||||
if (BitSquare.fillFormsWithDummyData)
|
||||
|
@ -751,8 +756,6 @@ public class SettingsController extends CachedViewController
|
|||
|
||||
saveUser();
|
||||
|
||||
initBankAccountScreen();
|
||||
|
||||
if (!settings.getAcceptedCountries().contains(bankAccount.getCountry()))
|
||||
{
|
||||
List<Action> actions = new ArrayList<>();
|
||||
|
@ -775,7 +778,7 @@ public class SettingsController extends CachedViewController
|
|||
|
||||
saveUser();
|
||||
saveSettings();
|
||||
initBankAccountScreen();
|
||||
fillWithCurrentBankAccount();
|
||||
}
|
||||
|
||||
private boolean verifyBankAccountData()
|
||||
|
|
|
@ -179,9 +179,9 @@ public class OrderBookController extends CachedViewController
|
|||
updateVolume();
|
||||
});
|
||||
|
||||
orderBookFilter.getDirectionChangedProperty().addListener((observable, oldValue, newValue) -> applyOffers());
|
||||
orderBookFilter.getDirectionChangedProperty().addListener((observable) -> applyOffers());
|
||||
|
||||
user.getBankAccountChangedProperty().addListener((observable, oldValue, newValue) -> orderBook.loadOffers());
|
||||
user.getSelectedBankAccountIndexProperty().addListener((observable) -> orderBook.loadOffers());
|
||||
|
||||
createOfferButton.setOnAction(e -> createOffer());
|
||||
|
||||
|
@ -213,18 +213,9 @@ public class OrderBookController extends CachedViewController
|
|||
if (isRegistered())
|
||||
{
|
||||
createOfferButton.setDisable(true);
|
||||
/* if (walletFacade.isUnusedTradeAddressBalanceAboveCreationFee())
|
||||
{ */
|
||||
ViewController nextController = parentController.loadViewAndGetChildController(NavigationItem.CREATE_OFFER);
|
||||
if (nextController != null)
|
||||
((CreateOfferController) nextController).setOrderBookFilter(orderBookFilter);
|
||||
/* }
|
||||
else
|
||||
{
|
||||
Action response = Popups.openErrorPopup("No funds for a trade", "You have to add some funds before you create a new offer.");
|
||||
if (response == Dialog.Actions.OK)
|
||||
MainController.GET_INSTANCE().navigateToView(NavigationItem.FUNDS);
|
||||
} */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -7,7 +7,9 @@ import java.security.KeyPair;
|
|||
import java.security.PublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javax.annotation.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -19,7 +21,8 @@ public class User implements Serializable
|
|||
private static final Logger log = LoggerFactory.getLogger(User.class);
|
||||
private static final long serialVersionUID = 7409078808248518638L;
|
||||
|
||||
transient private final SimpleBooleanProperty bankAccountChangedProperty = new SimpleBooleanProperty();
|
||||
transient private final IntegerProperty selectedBankAccountIndexProperty = new SimpleIntegerProperty();
|
||||
transient private final IntegerProperty bankAccountsSizeProperty = new SimpleIntegerProperty();
|
||||
|
||||
private KeyPair messageKeyPair;
|
||||
private String accountID;
|
||||
|
@ -42,7 +45,6 @@ public class User implements Serializable
|
|||
{
|
||||
bankAccounts = persistedUser.getBankAccounts();
|
||||
messageKeyPair = persistedUser.getMessageKeyPair();
|
||||
|
||||
accountID = persistedUser.getAccountId();
|
||||
setCurrentBankAccount(persistedUser.getCurrentBankAccount());
|
||||
}
|
||||
|
@ -52,22 +54,33 @@ public class User implements Serializable
|
|||
bankAccounts = new ArrayList<>();
|
||||
messageKeyPair = DSAKeyUtil.generateKeyPair(); // DSAKeyUtil.getKeyPair() runs in same thread now
|
||||
}
|
||||
DSAKeyUtil.generateKeyPair();
|
||||
|
||||
bankAccountsSizeProperty.set(bankAccounts.size());
|
||||
}
|
||||
|
||||
public void addBankAccount(BankAccount bankAccount)
|
||||
{
|
||||
if (!bankAccounts.contains(bankAccount)) bankAccounts.add(bankAccount);
|
||||
if (!bankAccounts.contains(bankAccount))
|
||||
{
|
||||
bankAccounts.add(bankAccount);
|
||||
bankAccountsSizeProperty.set(bankAccounts.size());
|
||||
}
|
||||
|
||||
setCurrentBankAccount(bankAccount);
|
||||
}
|
||||
|
||||
public void removeCurrentBankAccount()
|
||||
{
|
||||
if (currentBankAccount != null) bankAccounts.remove(currentBankAccount);
|
||||
if (currentBankAccount != null)
|
||||
{
|
||||
bankAccounts.remove(currentBankAccount);
|
||||
bankAccountsSizeProperty.set(bankAccounts.size());
|
||||
}
|
||||
|
||||
if (bankAccounts.isEmpty()) currentBankAccount = null;
|
||||
else setCurrentBankAccount(bankAccounts.get(0));
|
||||
if (bankAccounts.isEmpty())
|
||||
setCurrentBankAccount(null);
|
||||
else
|
||||
setCurrentBankAccount(bankAccounts.get(0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,10 +95,16 @@ public class User implements Serializable
|
|||
this.accountID = accountID;
|
||||
}
|
||||
|
||||
public void setCurrentBankAccount(BankAccount bankAccount)
|
||||
public void setCurrentBankAccount(@Nullable BankAccount bankAccount)
|
||||
{
|
||||
this.currentBankAccount = bankAccount;
|
||||
bankAccountChangedProperty.set(!bankAccountChangedProperty.get());
|
||||
currentBankAccount = bankAccount;
|
||||
int index = -1;
|
||||
for (index = 0; index < bankAccounts.size(); index++)
|
||||
{
|
||||
if (currentBankAccount != null && currentBankAccount.equals(bankAccounts.get(index)))
|
||||
break;
|
||||
}
|
||||
selectedBankAccountIndexProperty.set(index);
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,9 +156,9 @@ public class User implements Serializable
|
|||
return null;
|
||||
}
|
||||
|
||||
public SimpleBooleanProperty getBankAccountChangedProperty()
|
||||
public IntegerProperty getSelectedBankAccountIndexProperty()
|
||||
{
|
||||
return bankAccountChangedProperty;
|
||||
return selectedBankAccountIndexProperty;
|
||||
}
|
||||
|
||||
public KeyPair getMessageKeyPair()
|
||||
|
@ -156,4 +175,9 @@ public class User implements Serializable
|
|||
{
|
||||
return DSAKeyUtil.getHexStringFromPublicKey(getMessagePublicKey());
|
||||
}
|
||||
|
||||
public IntegerProperty getBankAccountsSizeProperty()
|
||||
{
|
||||
return bankAccountsSizeProperty;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue