Compare commits
No commits in common. "064884dc0793a5e4605b4817ea69820dbdf49e15" and "0b4937b1414ad4b8c35d58b450811b0c516a6924" have entirely different histories.
064884dc07
...
0b4937b141
@ -58,12 +58,12 @@ class _ExpensePageState extends State<ExpensePage> {
|
||||
// if the Widgets are expecting RecurringTrackedType, but we
|
||||
// need to be using Frequency? Change to only have one abstract
|
||||
// class and make it nully again? Hmmm...
|
||||
//if (curr is RecurringTrackedType && curr.frequency != null) {
|
||||
if (curr is RecurringTrackedType) {
|
||||
itemAmount =
|
||||
"${curr.amount.toStringAsFixed(2)} ${curr.frequency.title}";
|
||||
/*} else {
|
||||
} else {
|
||||
itemAmount = curr.amount.toStringAsFixed(2);
|
||||
}*/
|
||||
}
|
||||
final String itemDescription = curr.description;
|
||||
|
||||
final double itemDayAmount =
|
||||
@ -180,7 +180,7 @@ class _ExpensePageState extends State<ExpensePage> {
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
itemDescription,
|
||||
curr.description,
|
||||
style: TextStyle(
|
||||
fontSize: 12.0,
|
||||
),
|
||||
|
@ -3,7 +3,9 @@ import 'package:flutter/material.dart';
|
||||
|
||||
// Local
|
||||
import 'package:flutter_expense_tracker/db.dart';
|
||||
import 'package:flutter_expense_tracker/models/tracked_type_recurring.dart';
|
||||
import 'package:flutter_expense_tracker/models/asset.dart';
|
||||
import 'package:flutter_expense_tracker/models/expense.dart';
|
||||
import 'package:flutter_expense_tracker/models/income.dart';
|
||||
|
||||
/// TODO:
|
||||
/// - Expenses (total number, totals by day / month / year)
|
||||
@ -23,16 +25,34 @@ class ProjectionPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
Widget expenseSummary = SummaryCardForTotals(
|
||||
list: DatabaseHelper.instance.getExpenses(),
|
||||
summaryTypeLabel: "Expense",
|
||||
);
|
||||
|
||||
return ListView(
|
||||
children: [
|
||||
expenseSummary,
|
||||
SummaryCard(
|
||||
name: "Expense Totals",
|
||||
leftText: "left",
|
||||
middleText: "middle",
|
||||
rightText: "right",
|
||||
),
|
||||
SummaryCard(
|
||||
name: "Income Totals",
|
||||
leftText: "left",
|
||||
@ -50,43 +70,6 @@ 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 {
|
||||
const SummaryCard({
|
||||
super.key,
|
||||
@ -108,18 +91,14 @@ class SummaryCard extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Center(
|
||||
child: Text(name),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(leftText),
|
||||
Spacer(),
|
||||
Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(name),
|
||||
Text(middleText),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(middleText),
|
||||
Spacer(),
|
||||
Text(rightText),
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user