From abc44eddc2ac670a80a2dd86328fd9fa6c21438c Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sun, 4 May 2025 22:30:06 +0200 Subject: [PATCH] Display how much of the budget is still left --- lib/ui/pages/budgets/budget_details.dart | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/ui/pages/budgets/budget_details.dart b/lib/ui/pages/budgets/budget_details.dart index ac4d8b5..c197fce 100644 --- a/lib/ui/pages/budgets/budget_details.dart +++ b/lib/ui/pages/budgets/budget_details.dart @@ -126,6 +126,7 @@ class BudgetDetailsPage extends StatelessWidget { ); } + final totalSpent = spending.isEmpty ? 0 : spending.values.reduce((acc, val) => acc + val); final budgetTotal = state.activeBudget!.items .map((i) => i.amount) .reduce((acc, val) => acc + val); @@ -170,6 +171,38 @@ class BudgetDetailsPage extends StatelessWidget { ), ), ), + Padding( + padding: EdgeInsets.all(8), + child: SizedBox( + height: 100, + width: 150, + child: Card( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Budget left", + textAlign: TextAlign.center, + style: + Theme.of( + context, + ).textTheme.titleLarge, + ), + Text( + formatCurrency(budgetTotal + totalSpent), + textAlign: TextAlign.center, + style: + Theme.of( + context, + ).textTheme.bodyLarge, + ), + ], + ), + ), + ), + ), Padding( padding: EdgeInsets.all(8), child: SizedBox(