adjust payment accounts list height dynamically

This commit is contained in:
woodser 2025-07-08 07:11:24 -04:00 committed by GitHub
parent 75b8eb1dc9
commit 0b4f5bf4ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 6 deletions

View file

@ -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);

View file

@ -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"),

View file

@ -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"),