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
|
// 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 && curr.frequency != null) {
|
if (curr is RecurringTrackedType) {
|
||||||
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(
|
||||||
itemDescription,
|
curr.description,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12.0,
|
fontSize: 12.0,
|
||||||
),
|
),
|
||||||
|
@ -3,7 +3,9 @@ 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/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:
|
/// TODO:
|
||||||
/// - Expenses (total number, totals by day / month / year)
|
/// - Expenses (total number, totals by day / month / year)
|
||||||
@ -23,16 +25,34 @@ 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: [
|
||||||
expenseSummary,
|
SummaryCard(
|
||||||
|
name: "Expense Totals",
|
||||||
|
leftText: "left",
|
||||||
|
middleText: "middle",
|
||||||
|
rightText: "right",
|
||||||
|
),
|
||||||
SummaryCard(
|
SummaryCard(
|
||||||
name: "Income Totals",
|
name: "Income Totals",
|
||||||
leftText: "left",
|
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 {
|
class SummaryCard extends StatelessWidget {
|
||||||
const SummaryCard({
|
const SummaryCard({
|
||||||
super.key,
|
super.key,
|
||||||
@ -108,18 +91,14 @@ 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(),
|
||||||
Center(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Text(name),
|
|
||||||
Text(middleText),
|
Text(middleText),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Spacer(),
|
Spacer(),
|
||||||
Text(rightText),
|
Text(rightText),
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user