From 8a4386272534a4cabfbf0f3a42ae6547026e6117 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Mon, 8 Jan 2024 11:21:40 -0500 Subject: [PATCH] Cleaned up account and transaction tiles, and removed unneeded CSS references from most places. --- .../perfin/view/component/AccountTile.java | 24 +++++-------- .../perfin/view/component/PropertiesPane.java | 9 ++++- .../view/component/TransactionTile.java | 36 ++++++++++++------- src/main/resources/account-view.fxml | 1 - src/main/resources/accounts-view.fxml | 1 - src/main/resources/create-balance-record.fxml | 1 - src/main/resources/create-transaction.fxml | 1 - src/main/resources/edit-account.fxml | 1 - src/main/resources/style/base.css | 10 +++++- 9 files changed, 48 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/andrewlalis/perfin/view/component/AccountTile.java b/src/main/java/com/andrewlalis/perfin/view/component/AccountTile.java index 90103cf..ea9df27 100644 --- a/src/main/java/com/andrewlalis/perfin/view/component/AccountTile.java +++ b/src/main/java/com/andrewlalis/perfin/view/component/AccountTile.java @@ -14,8 +14,6 @@ import javafx.scene.layout.BorderPane; import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; -import javafx.scene.paint.Color; -import javafx.scene.text.Text; import java.math.BigDecimal; import java.util.Map; @@ -26,10 +24,10 @@ import static com.andrewlalis.perfin.PerfinApp.router; * A compact tile that displays information about an account. */ public class AccountTile extends BorderPane { - private static final Map ACCOUNT_TYPE_COLORS = Map.of( - AccountType.CHECKING, Color.rgb(3, 127, 252), - AccountType.SAVINGS, Color.rgb(57, 158, 74), - AccountType.CREDIT_CARD, Color.rgb(207, 8, 68) + private static final Map ACCOUNT_TYPE_COLORS = Map.of( + AccountType.CHECKING, "-fx-theme-account-type-checking", + AccountType.SAVINGS, "-fx-theme-account-type-savings", + AccountType.CREDIT_CARD, "-fx-theme-account-type-credit-card" ); public AccountTile(Account account) { @@ -44,9 +42,9 @@ public class AccountTile extends BorderPane { } private Node getHeader(Account account) { - Text title = new Text("Account #" + account.id); - title.getStyleClass().addAll("large-font", "bold-text"); - return title; + Label titleLabel = new Label(account.getName()); + titleLabel.getStyleClass().addAll("large-font", "bold-text"); + return titleLabel; } private Node getFooter(Account account) { @@ -70,16 +68,12 @@ public class AccountTile extends BorderPane { valueConstraints.setHalignment(HPos.RIGHT); propertiesPane.getColumnConstraints().setAll(keyConstraints, valueConstraints); - Label accountNameLabel = new Label(account.getName()); - accountNameLabel.setWrapText(true); - accountNameLabel.getStyleClass().add("italic-text"); - Label accountNumberLabel = new Label(account.getAccountNumber()); accountNumberLabel.getStyleClass().add("mono-font"); Label accountTypeLabel = new Label(account.getType().toString()); - accountTypeLabel.setTextFill(ACCOUNT_TYPE_COLORS.get(account.getType())); accountTypeLabel.getStyleClass().add("bold-text"); + accountTypeLabel.setStyle("-fx-text-fill: " + ACCOUNT_TYPE_COLORS.get(account.getType())); Label balanceLabel = new Label("Computing balance..."); balanceLabel.getStyleClass().addAll("mono-font"); @@ -103,8 +97,6 @@ public class AccountTile extends BorderPane { }); propertiesPane.getChildren().addAll( - newPropertyLabel("Account Name"), - accountNameLabel, newPropertyLabel("Account Number"), accountNumberLabel, newPropertyLabel("Account Type"), diff --git a/src/main/java/com/andrewlalis/perfin/view/component/PropertiesPane.java b/src/main/java/com/andrewlalis/perfin/view/component/PropertiesPane.java index a8e9c69..bbdffd0 100644 --- a/src/main/java/com/andrewlalis/perfin/view/component/PropertiesPane.java +++ b/src/main/java/com/andrewlalis/perfin/view/component/PropertiesPane.java @@ -21,15 +21,22 @@ public class PropertiesPane extends GridPane { private final ColumnConstraints defaultValueColumnConstraints; private boolean columnConstraintsSet = false; - public PropertiesPane() { + public PropertiesPane(int keyColumnMinWidth) { defaultKeyColumnConstraints = new ColumnConstraints(); defaultKeyColumnConstraints.setHgrow(Priority.NEVER); defaultKeyColumnConstraints.setHalignment(HPos.LEFT); + if (keyColumnMinWidth != -1) { + defaultKeyColumnConstraints.setMinWidth(keyColumnMinWidth); + } defaultValueColumnConstraints = new ColumnConstraints(); defaultValueColumnConstraints.setHgrow(Priority.ALWAYS); defaultValueColumnConstraints.setHalignment(HPos.LEFT); } + public PropertiesPane() { + this(-1); + } + @Override protected void layoutChildren() { // Apply grid positioning to all children in the order in which they appear, like so: diff --git a/src/main/java/com/andrewlalis/perfin/view/component/TransactionTile.java b/src/main/java/com/andrewlalis/perfin/view/component/TransactionTile.java index 2753ebf..e889371 100644 --- a/src/main/java/com/andrewlalis/perfin/view/component/TransactionTile.java +++ b/src/main/java/com/andrewlalis/perfin/view/component/TransactionTile.java @@ -3,6 +3,7 @@ package com.andrewlalis.perfin.view.component; import com.andrewlalis.perfin.data.util.CurrencyUtil; import com.andrewlalis.perfin.data.util.DateUtil; import com.andrewlalis.perfin.model.CreditAndDebitAccounts; +import com.andrewlalis.perfin.model.MoneyValue; import com.andrewlalis.perfin.model.Profile; import com.andrewlalis.perfin.model.Transaction; import javafx.application.Platform; @@ -14,7 +15,6 @@ import javafx.scene.control.Label; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; -import javafx.scene.paint.Color; import javafx.scene.text.Text; import javafx.scene.text.TextFlow; @@ -37,28 +37,38 @@ public class TransactionTile extends BorderPane { selected.addListener((observable, oldValue, newValue) -> { if (newValue) { - getStyleClass().add("tile-border-selected"); + getStyleClass().add("tile-selected"); } else { - getStyleClass().remove("tile-border-selected"); + getStyleClass().remove("tile-selected"); } }); } private Node getHeader(Transaction transaction) { - Label currencyLabel = new Label(CurrencyUtil.formatMoney(transaction.getMoneyAmount())); - currencyLabel.getStyleClass().add("mono-font"); - HBox headerHBox = new HBox( - currencyLabel - ); - headerHBox.getStyleClass().addAll("std-spacing"); - return headerHBox; + Label headerLabel = new Label("Transaction #" + transaction.id); + headerLabel.getStyleClass().addAll("bold-text"); + return headerLabel; } private Node getBody(Transaction transaction) { - Label descriptionLabel = new Label(transaction.getDescription()); - descriptionLabel.setWrapText(true); + PropertiesPane propertiesPane = new PropertiesPane(150); + Label amountLabel = new Label("Amount"); + amountLabel.getStyleClass().add("bold-text"); + Label amountValue = new Label(CurrencyUtil.formatMoneyWithCurrencyPrefix(transaction.getMoneyAmount())); + amountValue.getStyleClass().add("mono-font"); + + Label descriptionLabel = new Label("Description"); + descriptionLabel.getStyleClass().add("bold-text"); + Label descriptionValue = new Label(transaction.getDescription()); + descriptionValue.setWrapText(true); + + propertiesPane.getChildren().addAll( + amountLabel, amountValue, + descriptionLabel, descriptionValue + ); + VBox bodyVBox = new VBox( - descriptionLabel + propertiesPane ); getCreditAndDebitAccounts(transaction).thenAccept(accounts -> { accounts.ifCredit(acc -> { diff --git a/src/main/resources/account-view.fxml b/src/main/resources/account-view.fxml index a2e411f..e193955 100644 --- a/src/main/resources/account-view.fxml +++ b/src/main/resources/account-view.fxml @@ -8,7 +8,6 @@ xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="com.andrewlalis.perfin.control.AccountViewController" - stylesheets="@style/base.css" >