mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-09-18 20:14:41 -04:00
adjust payment accounts list height dynamically
This commit is contained in:
parent
75b8eb1dc9
commit
0b4f5bf4ed
3 changed files with 15 additions and 6 deletions
|
@ -14,7 +14,9 @@ import haveno.desktop.components.InfoAutoTooltipLabel;
|
|||
import haveno.desktop.main.overlays.popups.Popup;
|
||||
import haveno.desktop.util.GUIUtil;
|
||||
import haveno.desktop.util.ImageUtil;
|
||||
import haveno.desktop.util.Layout;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Node;
|
||||
|
@ -67,6 +69,10 @@ public abstract class PaymentAccountsView<R extends Node, M extends ActivatableW
|
|||
Label placeholder = new AutoTooltipLabel(Res.get("shared.noAccountsSetupYet"));
|
||||
placeholder.setWrapText(true);
|
||||
paymentAccountsListView.setPlaceholder(placeholder);
|
||||
|
||||
getPaymentAccounts().addListener((ListChangeListener<PaymentAccount>) change -> {
|
||||
setPaymentAccountsListHeight();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -153,6 +159,13 @@ public abstract class PaymentAccountsView<R extends Node, M extends ActivatableW
|
|||
});
|
||||
}
|
||||
|
||||
protected void setPaymentAccountsListHeight() {
|
||||
int prefNumRows = Math.min(5, Math.max(2, getPaymentAccounts().size()));
|
||||
double prefHeight = prefNumRows * (Layout.LIST_ROW_HEIGHT + 6);
|
||||
paymentAccountsListView.setMinHeight(prefHeight);
|
||||
paymentAccountsListView.setMaxHeight(prefHeight);
|
||||
}
|
||||
|
||||
protected abstract void removeSelectAccountForm();
|
||||
|
||||
protected abstract boolean deleteAccountFromModel(PaymentAccount paymentAccount);
|
||||
|
|
|
@ -174,9 +174,7 @@ public class CryptoAccountsView extends PaymentAccountsView<GridPane, CryptoAcco
|
|||
|
||||
Tuple3<Label, ListView<PaymentAccount>, VBox> tuple = addTopLabelListView(root, gridRow, Res.get("account.crypto.yourCryptoAccounts"), Layout.FIRST_ROW_DISTANCE);
|
||||
paymentAccountsListView = tuple.second;
|
||||
int prefNumRows = Math.min(4, Math.max(2, model.dataModel.getNumPaymentAccounts()));
|
||||
paymentAccountsListView.setMinHeight(prefNumRows * Layout.LIST_ROW_HEIGHT + 34);
|
||||
paymentAccountsListView.setMaxHeight(prefNumRows * Layout.LIST_ROW_HEIGHT + 34);
|
||||
setPaymentAccountsListHeight();
|
||||
setPaymentAccountsCellFactory();
|
||||
|
||||
Tuple3<Button, Button, Button> tuple3 = add3ButtonsAfterGroup(root, ++gridRow, Res.get("shared.addNewAccount"),
|
||||
|
|
|
@ -455,9 +455,7 @@ public class TraditionalAccountsView extends PaymentAccountsView<GridPane, Tradi
|
|||
|
||||
Tuple3<Label, ListView<PaymentAccount>, VBox> tuple = addTopLabelListView(root, gridRow, Res.get("account.traditional.yourTraditionalAccounts"), Layout.FIRST_ROW_DISTANCE);
|
||||
paymentAccountsListView = tuple.second;
|
||||
int prefNumRows = Math.min(4, Math.max(2, model.dataModel.getNumPaymentAccounts()));
|
||||
paymentAccountsListView.setMinHeight(prefNumRows * Layout.LIST_ROW_HEIGHT + 34);
|
||||
paymentAccountsListView.setMaxHeight(prefNumRows * Layout.LIST_ROW_HEIGHT + 34);
|
||||
setPaymentAccountsListHeight();
|
||||
setPaymentAccountsCellFactory();
|
||||
|
||||
Tuple3<Button, Button, Button> tuple3 = add3ButtonsAfterGroup(root, ++gridRow, Res.get("shared.addNewAccount"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue