Compare commits

..

No commits in common. "e896611bd1b20c72de4a44235d28bfd64c6e8a6c" and "c5f1a4e9ba18388bffd855b64c1f7e3d700c20e2" have entirely different histories.

4 changed files with 191 additions and 245 deletions

View File

@ -2,26 +2,21 @@ enum ItemType {
expense(
title: "Expense",
plural: "Expenses",
description: "Items which cost revenue, or decrease asset value.",
),
income(
title: "Income",
plural: "Income",
description: "Items which bring in revenue, or increase asset value.",
plural: "Incomes",
),
asset(
title: "Asset",
plural: "Assets",
description: "Value which has been earned and can be spent.",
);
const ItemType({
required this.title,
required this.plural,
required this.description,
});
final String title;
final String plural;
final String description;
}

View File

@ -45,7 +45,7 @@ class HelpPage extends StatelessWidget {
" adding receipts.",
),
Text(
"\n\t\t Tracked items can be swiped left to right for"
"\n\t\t Tracked items can be swiped left to right for ,"
" Deletion or right to left for Editing. Items are sorted"
" from highest to lowest so that the biggest impacts are"
" always in view.",

View File

@ -56,7 +56,7 @@ class _HomePageState extends State<HomePage> {
switch (pageSelected) {
case 0:
page = TrackedItemPage(
assetType: ItemType.expense,
assetsToLoad: DatabaseHelper.instance.getExpenses(),
notifyParent: refresh,
);
dialog = TrackedItemInputDialog(
@ -66,7 +66,7 @@ class _HomePageState extends State<HomePage> {
break;
case 1:
page = TrackedItemPage(
assetType: ItemType.income,
assetsToLoad: DatabaseHelper.instance.getIncomes(),
notifyParent: refresh,
);
dialog = TrackedItemInputDialog(
@ -76,7 +76,7 @@ class _HomePageState extends State<HomePage> {
break;
case 2:
page = TrackedItemPage(
assetType: ItemType.asset,
assetsToLoad: DatabaseHelper.instance.getAssets(),
notifyParent: refresh,
);
dialog = TrackedItemInputDialog(
@ -120,15 +120,15 @@ class _HomePageState extends State<HomePage> {
destinations: [
NavigationRailDestination(
icon: Icon(Icons.payment),
label: Text(ItemType.expense.plural),
label: Text('Expenses'),
),
NavigationRailDestination(
icon: Icon(Icons.account_balance),
label: Text(ItemType.income.plural),
label: Text('Income'),
),
NavigationRailDestination(
icon: Icon(Icons.attach_money),
label: Text(ItemType.asset.plural),
label: Text('Liquid Assets'),
),
NavigationRailDestination(
icon: Icon(Icons.bar_chart),

View File

@ -11,12 +11,12 @@ import '/models/frequency.dart';
import '/db.dart';
class TrackedItemPage extends StatefulWidget {
final ItemType assetType;
final Future<List<TrackedItem>> assetsToLoad;
final Function() notifyParent;
const TrackedItemPage({
super.key,
required this.assetType,
required this.assetsToLoad,
required this.notifyParent,
});
@ -25,28 +25,12 @@ class TrackedItemPage extends StatefulWidget {
}
class _TrackedItemPageState extends State<TrackedItemPage> {
late Future<List<TrackedItem>> _assetsToLoad;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
switch (widget.assetType) {
case ItemType.expense:
_assetsToLoad = DatabaseHelper.instance.getExpenses();
break;
case ItemType.income:
_assetsToLoad = DatabaseHelper.instance.getIncomes();
break;
case ItemType.asset:
_assetsToLoad = DatabaseHelper.instance.getAssets();
break;
default:
throw UnimplementedError("Unsure whch asset group to load.");
}
return FutureBuilder<List<TrackedItem>>(
future: _assetsToLoad,
future: widget.assetsToLoad,
builder:
(BuildContext context, AsyncSnapshot<List<TrackedItem>> snapshot) {
if (!snapshot.hasData) {
@ -62,26 +46,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
"Add items to get started.",
softWrap: true,
)
: Column(
children: [
Text(
"${widget.assetType.plural}",
style: TextStyle(
fontSize: 24.0,
decoration: TextDecoration.underline,
fontWeight: FontWeight.bold,
),
),
/*Text(
"${widget.assetType.description}",
style: TextStyle(
fontSize: 16.0,
decoration: TextDecoration.none,
fontWeight: FontWeight.bold,
),
),*/
Expanded(
child: ListView.builder(
: ListView.builder(
itemCount: snapshot.data!.length,
itemBuilder: (_, index) {
final TrackedItem curr = snapshot.data![index];
@ -98,9 +63,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
}
final String itemDescription = curr.description;
final double itemDayAmount,
itemMonthAmount,
itemYearAmount;
final double itemDayAmount, itemMonthAmount, itemYearAmount;
final String estimateSymbolDaily,
estimateSymbolMonthly,
estimateSymbolYearly;
@ -110,9 +73,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
estimateSymbolDaily = curr.frequency!.numDays
.toStringAsFixed(2)
.endsWith(".00") &&
itemDayAmount
.toStringAsFixed(3)
.endsWith("0")
itemDayAmount.toStringAsFixed(3).endsWith("0")
? ""
: "~";
@ -121,9 +82,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
estimateSymbolMonthly = curr.frequency!.timesPerYear
.toStringAsFixed(2)
.endsWith(".00") &&
itemMonthAmount
.toStringAsFixed(3)
.endsWith("0")
itemMonthAmount.toStringAsFixed(3).endsWith("0")
? ""
: "~";
@ -131,9 +90,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
estimateSymbolYearly = curr.frequency!.timesPerYear
.toStringAsFixed(2)
.endsWith(".00") &&
itemYearAmount
.toStringAsFixed(3)
.endsWith("0")
itemYearAmount.toStringAsFixed(3).endsWith("0")
? ""
: "~";
} else {
@ -145,8 +102,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
estimateSymbolYearly = "";
}
final String monthlyTitle =
curr.type == ItemType.asset
final String monthlyTitle = curr.type == ItemType.asset
? ""
: " ${Frequency.monthly.title}";
@ -240,8 +196,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
children: [
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
itemTitle,
@ -266,8 +221,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
),
),
Column(
crossAxisAlignment:
CrossAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
itemTopText,
@ -290,9 +244,6 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
),
);
},
),
),
],
);
});
}