Display how much of the budget is still left
This commit is contained in:
parent
6390155f30
commit
abc44eddc2
@ -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
|
final budgetTotal = state.activeBudget!.items
|
||||||
.map((i) => i.amount)
|
.map((i) => i.amount)
|
||||||
.reduce((acc, val) => acc + val);
|
.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(
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
|
Loading…
Reference in New Issue
Block a user