Compare commits
3 Commits
0b4937b141
...
064884dc07
Author | SHA1 | Date | |
---|---|---|---|
064884dc07 | |||
98e511056c | |||
58102bab02 |
@ -58,12 +58,12 @@ class _ExpensePageState extends State<ExpensePage> {
|
|||||||
// if the Widgets are expecting RecurringTrackedType, but we
|
// if the Widgets are expecting RecurringTrackedType, but we
|
||||||
// need to be using Frequency? Change to only have one abstract
|
// need to be using Frequency? Change to only have one abstract
|
||||||
// class and make it nully again? Hmmm...
|
// class and make it nully again? Hmmm...
|
||||||
if (curr is RecurringTrackedType) {
|
//if (curr is RecurringTrackedType && curr.frequency != null) {
|
||||||
itemAmount =
|
itemAmount =
|
||||||
"${curr.amount.toStringAsFixed(2)} ${curr.frequency.title}";
|
"${curr.amount.toStringAsFixed(2)} ${curr.frequency.title}";
|
||||||
} else {
|
/*} else {
|
||||||
itemAmount = curr.amount.toStringAsFixed(2);
|
itemAmount = curr.amount.toStringAsFixed(2);
|
||||||
}
|
}*/
|
||||||
final String itemDescription = curr.description;
|
final String itemDescription = curr.description;
|
||||||
|
|
||||||
final double itemDayAmount =
|
final double itemDayAmount =
|
||||||
@ -180,7 +180,7 @@ class _ExpensePageState extends State<ExpensePage> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
curr.description,
|
itemDescription,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12.0,
|
fontSize: 12.0,
|
||||||
),
|
),
|
||||||
|
@ -3,9 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
// Local
|
// Local
|
||||||
import 'package:flutter_expense_tracker/db.dart';
|
import 'package:flutter_expense_tracker/db.dart';
|
||||||
import 'package:flutter_expense_tracker/models/asset.dart';
|
import 'package:flutter_expense_tracker/models/tracked_type_recurring.dart';
|
||||||
import 'package:flutter_expense_tracker/models/expense.dart';
|
|
||||||
import 'package:flutter_expense_tracker/models/income.dart';
|
|
||||||
|
|
||||||
/// TODO:
|
/// TODO:
|
||||||
/// - Expenses (total number, totals by day / month / year)
|
/// - Expenses (total number, totals by day / month / year)
|
||||||
@ -25,34 +23,16 @@ class ProjectionPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ProjectionPageState extends State<ProjectionPage> {
|
class _ProjectionPageState extends State<ProjectionPage> {
|
||||||
late Future<List<Expense>> expenses;
|
|
||||||
late Future<List<Income>> incomes;
|
|
||||||
late Future<List<Asset>> assets;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
/***** Load DB Data *****/
|
|
||||||
// Expenses
|
|
||||||
expenses = DatabaseHelper.instance.getExpenses();
|
|
||||||
|
|
||||||
// Income
|
|
||||||
//incomes = DatabaseHelper.instance.getIncomes();
|
|
||||||
|
|
||||||
// Assets
|
|
||||||
//assets = DatabaseHelper.instance.getAssets();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Widget expenseSummary = SummaryCardForTotals(
|
||||||
|
list: DatabaseHelper.instance.getExpenses(),
|
||||||
|
summaryTypeLabel: "Expense",
|
||||||
|
);
|
||||||
|
|
||||||
return ListView(
|
return ListView(
|
||||||
children: [
|
children: [
|
||||||
SummaryCard(
|
expenseSummary,
|
||||||
name: "Expense Totals",
|
|
||||||
leftText: "left",
|
|
||||||
middleText: "middle",
|
|
||||||
rightText: "right",
|
|
||||||
),
|
|
||||||
SummaryCard(
|
SummaryCard(
|
||||||
name: "Income Totals",
|
name: "Income Totals",
|
||||||
leftText: "left",
|
leftText: "left",
|
||||||
@ -70,6 +50,43 @@ class _ProjectionPageState extends State<ProjectionPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SummaryCardForTotals extends StatelessWidget {
|
||||||
|
const SummaryCardForTotals({
|
||||||
|
super.key,
|
||||||
|
required this.list,
|
||||||
|
required this.summaryTypeLabel,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Future<List<RecurringTrackedType>> list;
|
||||||
|
final String summaryTypeLabel;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return FutureBuilder<List<RecurringTrackedType>>(
|
||||||
|
future: list,
|
||||||
|
builder: (
|
||||||
|
BuildContext context,
|
||||||
|
AsyncSnapshot<List<RecurringTrackedType>> snapshot,
|
||||||
|
) {
|
||||||
|
if (!snapshot.hasData) {
|
||||||
|
return Text('Loading $summaryTypeLabel Section...');
|
||||||
|
}
|
||||||
|
double dailyTotal = 0, monthlyTotal = 0, yearlyTotal = 0;
|
||||||
|
for (RecurringTrackedType e in snapshot.data!) {
|
||||||
|
dailyTotal += e.calcComparableAmountDaily();
|
||||||
|
monthlyTotal += e.calcComparableAmountYearly() / 12;
|
||||||
|
yearlyTotal += e.calcComparableAmountYearly();
|
||||||
|
}
|
||||||
|
return SummaryCard(
|
||||||
|
name: "$summaryTypeLabel Totals",
|
||||||
|
leftText: "${dailyTotal.toStringAsFixed(2)} Daily",
|
||||||
|
middleText: "${monthlyTotal.toStringAsFixed(2)} Monthly",
|
||||||
|
rightText: "${yearlyTotal.toStringAsFixed(2)} Yearly",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class SummaryCard extends StatelessWidget {
|
class SummaryCard extends StatelessWidget {
|
||||||
const SummaryCard({
|
const SummaryCard({
|
||||||
super.key,
|
super.key,
|
||||||
@ -91,14 +108,18 @@ class SummaryCard extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Center(
|
|
||||||
child: Text(name),
|
|
||||||
),
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(leftText),
|
Text(leftText),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
Text(middleText),
|
Center(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(name),
|
||||||
|
Text(middleText),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
Text(rightText),
|
Text(rightText),
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user