Updates from idk when...

This commit is contained in:
Nathan Anderson
2023-08-17 13:34:30 -06:00
parent 6fae83674b
commit 1d1b5f0620
18 changed files with 614 additions and 161 deletions
@@ -9,6 +9,7 @@ import 'package:rluv/global/styles.dart';
import 'package:rluv/global/utils.dart';
import '../../../global/store.dart';
import '../../../global/widgets/ui_button.dart';
import '../../../models/transaction_model.dart';
import '../widgets/add_budget_category_dialog.dart';
@@ -26,11 +27,13 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
final budgetListScrollController = ScrollController();
@override
Widget build(BuildContext context) {
final budget = ref.watch(budgetProvider);
final budgetCategories = ref.watch(budgetCategoriesProvider);
final transactions = ref.watch(transactionsProvider);
final screen = BuildMedia(context).size;
double netExpense = 0.0;
double netIncome = 0.0;
double expectedExpenses = 0.0;
Map<int, double> budgetCategoryNetMap = {};
netExpense = transactions
.where((t) => t.type == TransactionType.expense)
@@ -40,6 +43,7 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
.fold(netIncome, (net, t) => net + t.amount);
for (final bud in budgetCategories) {
double net = 0.0;
expectedExpenses += bud.amount;
net = transactions
.where((t) => t.budgetCategoryId == bud.id)
.fold(net, (net, t) => net + t.amount);
@@ -68,9 +72,15 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
style:
TextStyle(fontSize: 42, color: Styles.electricBlue)),
const Spacer(flex: 2),
BudgetNetBar(isPositive: true, net: netIncome),
BudgetNetBar(
isPositive: true,
net: netIncome,
expected: budget?.expectedIncome ?? 0.0),
const Spacer(),
BudgetNetBar(isPositive: false, net: netExpense),
BudgetNetBar(
isPositive: false,
net: netExpense,
expected: expectedExpenses),
const Spacer(),
],
),
@@ -113,7 +123,7 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
child: Text(
'No budget categories created yet, add some!'),
),
ElevatedButton(
UiButton(
onPressed:
ref.watch(budgetProvider) ==
null
@@ -127,9 +137,9 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
Styles
.dialogColor,
child:
const AddBudgetCategoryDialog()),
const BudgetCategoryDialog()),
),
child: const Text('Add Category'),
text: 'Add Category',
),
],
),
@@ -181,7 +191,7 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
Styles
.dialogColor,
child:
const AddBudgetCategoryDialog()),
const BudgetCategoryDialog()),
),
child: const Text(
'Add Category'),
@@ -259,7 +269,7 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
return Dialog(
backgroundColor: Styles.dialogColor,
shape: Styles.dialogShape,
child: const AddTransactionDialog());
child: const TransactionDialog());
},
);
},