Compare commits
No commits in common. "e896611bd1b20c72de4a44235d28bfd64c6e8a6c" and "c5f1a4e9ba18388bffd855b64c1f7e3d700c20e2" have entirely different histories.
e896611bd1
...
c5f1a4e9ba
@ -2,26 +2,21 @@ enum ItemType {
|
|||||||
expense(
|
expense(
|
||||||
title: "Expense",
|
title: "Expense",
|
||||||
plural: "Expenses",
|
plural: "Expenses",
|
||||||
description: "Items which cost revenue, or decrease asset value.",
|
|
||||||
),
|
),
|
||||||
income(
|
income(
|
||||||
title: "Income",
|
title: "Income",
|
||||||
plural: "Income",
|
plural: "Incomes",
|
||||||
description: "Items which bring in revenue, or increase asset value.",
|
|
||||||
),
|
),
|
||||||
asset(
|
asset(
|
||||||
title: "Asset",
|
title: "Asset",
|
||||||
plural: "Assets",
|
plural: "Assets",
|
||||||
description: "Value which has been earned and can be spent.",
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const ItemType({
|
const ItemType({
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.plural,
|
required this.plural,
|
||||||
required this.description,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
final String plural;
|
final String plural;
|
||||||
final String description;
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class HelpPage extends StatelessWidget {
|
|||||||
" adding receipts.",
|
" adding receipts.",
|
||||||
),
|
),
|
||||||
Text(
|
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"
|
" Deletion or right to left for Editing. Items are sorted"
|
||||||
" from highest to lowest so that the biggest impacts are"
|
" from highest to lowest so that the biggest impacts are"
|
||||||
" always in view.",
|
" always in view.",
|
||||||
|
@ -56,7 +56,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
switch (pageSelected) {
|
switch (pageSelected) {
|
||||||
case 0:
|
case 0:
|
||||||
page = TrackedItemPage(
|
page = TrackedItemPage(
|
||||||
assetType: ItemType.expense,
|
assetsToLoad: DatabaseHelper.instance.getExpenses(),
|
||||||
notifyParent: refresh,
|
notifyParent: refresh,
|
||||||
);
|
);
|
||||||
dialog = TrackedItemInputDialog(
|
dialog = TrackedItemInputDialog(
|
||||||
@ -66,7 +66,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
page = TrackedItemPage(
|
page = TrackedItemPage(
|
||||||
assetType: ItemType.income,
|
assetsToLoad: DatabaseHelper.instance.getIncomes(),
|
||||||
notifyParent: refresh,
|
notifyParent: refresh,
|
||||||
);
|
);
|
||||||
dialog = TrackedItemInputDialog(
|
dialog = TrackedItemInputDialog(
|
||||||
@ -76,7 +76,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
page = TrackedItemPage(
|
page = TrackedItemPage(
|
||||||
assetType: ItemType.asset,
|
assetsToLoad: DatabaseHelper.instance.getAssets(),
|
||||||
notifyParent: refresh,
|
notifyParent: refresh,
|
||||||
);
|
);
|
||||||
dialog = TrackedItemInputDialog(
|
dialog = TrackedItemInputDialog(
|
||||||
@ -120,15 +120,15 @@ class _HomePageState extends State<HomePage> {
|
|||||||
destinations: [
|
destinations: [
|
||||||
NavigationRailDestination(
|
NavigationRailDestination(
|
||||||
icon: Icon(Icons.payment),
|
icon: Icon(Icons.payment),
|
||||||
label: Text(ItemType.expense.plural),
|
label: Text('Expenses'),
|
||||||
),
|
),
|
||||||
NavigationRailDestination(
|
NavigationRailDestination(
|
||||||
icon: Icon(Icons.account_balance),
|
icon: Icon(Icons.account_balance),
|
||||||
label: Text(ItemType.income.plural),
|
label: Text('Income'),
|
||||||
),
|
),
|
||||||
NavigationRailDestination(
|
NavigationRailDestination(
|
||||||
icon: Icon(Icons.attach_money),
|
icon: Icon(Icons.attach_money),
|
||||||
label: Text(ItemType.asset.plural),
|
label: Text('Liquid Assets'),
|
||||||
),
|
),
|
||||||
NavigationRailDestination(
|
NavigationRailDestination(
|
||||||
icon: Icon(Icons.bar_chart),
|
icon: Icon(Icons.bar_chart),
|
||||||
|
@ -11,12 +11,12 @@ import '/models/frequency.dart';
|
|||||||
import '/db.dart';
|
import '/db.dart';
|
||||||
|
|
||||||
class TrackedItemPage extends StatefulWidget {
|
class TrackedItemPage extends StatefulWidget {
|
||||||
final ItemType assetType;
|
final Future<List<TrackedItem>> assetsToLoad;
|
||||||
final Function() notifyParent;
|
final Function() notifyParent;
|
||||||
|
|
||||||
const TrackedItemPage({
|
const TrackedItemPage({
|
||||||
super.key,
|
super.key,
|
||||||
required this.assetType,
|
required this.assetsToLoad,
|
||||||
required this.notifyParent,
|
required this.notifyParent,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -25,28 +25,12 @@ class TrackedItemPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _TrackedItemPageState extends State<TrackedItemPage> {
|
class _TrackedItemPageState extends State<TrackedItemPage> {
|
||||||
late Future<List<TrackedItem>> _assetsToLoad;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(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>>(
|
return FutureBuilder<List<TrackedItem>>(
|
||||||
future: _assetsToLoad,
|
future: widget.assetsToLoad,
|
||||||
builder:
|
builder:
|
||||||
(BuildContext context, AsyncSnapshot<List<TrackedItem>> snapshot) {
|
(BuildContext context, AsyncSnapshot<List<TrackedItem>> snapshot) {
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
@ -62,26 +46,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
|
|||||||
"Add items to get started.",
|
"Add items to get started.",
|
||||||
softWrap: true,
|
softWrap: true,
|
||||||
)
|
)
|
||||||
: Column(
|
: ListView.builder(
|
||||||
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(
|
|
||||||
itemCount: snapshot.data!.length,
|
itemCount: snapshot.data!.length,
|
||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
final TrackedItem curr = snapshot.data![index];
|
final TrackedItem curr = snapshot.data![index];
|
||||||
@ -98,9 +63,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
|
|||||||
}
|
}
|
||||||
final String itemDescription = curr.description;
|
final String itemDescription = curr.description;
|
||||||
|
|
||||||
final double itemDayAmount,
|
final double itemDayAmount, itemMonthAmount, itemYearAmount;
|
||||||
itemMonthAmount,
|
|
||||||
itemYearAmount;
|
|
||||||
final String estimateSymbolDaily,
|
final String estimateSymbolDaily,
|
||||||
estimateSymbolMonthly,
|
estimateSymbolMonthly,
|
||||||
estimateSymbolYearly;
|
estimateSymbolYearly;
|
||||||
@ -110,9 +73,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
|
|||||||
estimateSymbolDaily = curr.frequency!.numDays
|
estimateSymbolDaily = curr.frequency!.numDays
|
||||||
.toStringAsFixed(2)
|
.toStringAsFixed(2)
|
||||||
.endsWith(".00") &&
|
.endsWith(".00") &&
|
||||||
itemDayAmount
|
itemDayAmount.toStringAsFixed(3).endsWith("0")
|
||||||
.toStringAsFixed(3)
|
|
||||||
.endsWith("0")
|
|
||||||
? ""
|
? ""
|
||||||
: "~";
|
: "~";
|
||||||
|
|
||||||
@ -121,9 +82,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
|
|||||||
estimateSymbolMonthly = curr.frequency!.timesPerYear
|
estimateSymbolMonthly = curr.frequency!.timesPerYear
|
||||||
.toStringAsFixed(2)
|
.toStringAsFixed(2)
|
||||||
.endsWith(".00") &&
|
.endsWith(".00") &&
|
||||||
itemMonthAmount
|
itemMonthAmount.toStringAsFixed(3).endsWith("0")
|
||||||
.toStringAsFixed(3)
|
|
||||||
.endsWith("0")
|
|
||||||
? ""
|
? ""
|
||||||
: "~";
|
: "~";
|
||||||
|
|
||||||
@ -131,9 +90,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
|
|||||||
estimateSymbolYearly = curr.frequency!.timesPerYear
|
estimateSymbolYearly = curr.frequency!.timesPerYear
|
||||||
.toStringAsFixed(2)
|
.toStringAsFixed(2)
|
||||||
.endsWith(".00") &&
|
.endsWith(".00") &&
|
||||||
itemYearAmount
|
itemYearAmount.toStringAsFixed(3).endsWith("0")
|
||||||
.toStringAsFixed(3)
|
|
||||||
.endsWith("0")
|
|
||||||
? ""
|
? ""
|
||||||
: "~";
|
: "~";
|
||||||
} else {
|
} else {
|
||||||
@ -145,8 +102,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
|
|||||||
estimateSymbolYearly = "";
|
estimateSymbolYearly = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
final String monthlyTitle =
|
final String monthlyTitle = curr.type == ItemType.asset
|
||||||
curr.type == ItemType.asset
|
|
||||||
? ""
|
? ""
|
||||||
: " ${Frequency.monthly.title}";
|
: " ${Frequency.monthly.title}";
|
||||||
|
|
||||||
@ -240,8 +196,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
|
|||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment:
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
itemTitle,
|
itemTitle,
|
||||||
@ -266,8 +221,7 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
CrossAxisAlignment.end,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
itemTopText,
|
itemTopText,
|
||||||
@ -290,9 +244,6 @@ class _TrackedItemPageState extends State<TrackedItemPage> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user