Added a monthly runner. Moved field values to be in variables outside of the Widget being returned.
This commit is contained in:
parent
9924860181
commit
21f67b8a36
@ -50,29 +50,58 @@ class _ExpensePageState extends State<ExpensePage> {
|
|||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
//List<Expense> expenses = snapshot.data!;
|
//List<Expense> expenses = snapshot.data!;
|
||||||
final RecurringTrackedType curr = snapshot.data![index];
|
final RecurringTrackedType curr = snapshot.data![index];
|
||||||
|
|
||||||
|
final itemKey = Key(curr.id!.toString());
|
||||||
|
final String itemTitle = curr.name;
|
||||||
|
final String itemAmount;
|
||||||
|
if (curr is RecurringTrackedType) {
|
||||||
|
itemAmount =
|
||||||
|
"${curr.amount.toStringAsFixed(2)} ${curr.frequency.title}";
|
||||||
|
} else {
|
||||||
|
itemAmount = curr.amount.toStringAsFixed(2);
|
||||||
|
}
|
||||||
|
final String itemDescription = curr.description;
|
||||||
|
|
||||||
|
final double itemDayAmount =
|
||||||
|
curr.calcComparableAmountDaily();
|
||||||
|
final String estimateSymbolDaily = curr.frequency.numDays
|
||||||
|
.toStringAsFixed(2)
|
||||||
|
.endsWith(".00") &&
|
||||||
|
itemDayAmount.toStringAsFixed(3).endsWith("0")
|
||||||
|
? ""
|
||||||
|
: "~";
|
||||||
|
|
||||||
|
final double itemMonthAmount =
|
||||||
|
(curr.calcComparableAmountYearly() / 12);
|
||||||
|
final String estimateSymbolMonthly = curr
|
||||||
|
.frequency.timesPerYear
|
||||||
|
.toStringAsFixed(2)
|
||||||
|
.endsWith(".00") &&
|
||||||
|
itemMonthAmount.toStringAsFixed(3).endsWith("0")
|
||||||
|
? ""
|
||||||
|
: "~";
|
||||||
|
|
||||||
|
final double itemYearAmount =
|
||||||
|
curr.calcComparableAmountYearly();
|
||||||
final String estimateSymbolYearly = curr
|
final String estimateSymbolYearly = curr
|
||||||
.frequency.timesPerYear
|
.frequency.timesPerYear
|
||||||
.toStringAsFixed(2)
|
.toStringAsFixed(2)
|
||||||
.endsWith(".00") &&
|
.endsWith(".00") &&
|
||||||
curr
|
itemYearAmount.toStringAsFixed(3).endsWith("0")
|
||||||
.calcComparableAmountYearly()
|
|
||||||
.toStringAsFixed(3)
|
|
||||||
.endsWith("0")
|
|
||||||
? ""
|
|
||||||
: "~";
|
|
||||||
final String estimateSymbolDaily = curr.frequency.numDays
|
|
||||||
.toStringAsFixed(2)
|
|
||||||
.endsWith(".00") &&
|
|
||||||
curr
|
|
||||||
.calcComparableAmountDaily()
|
|
||||||
.toStringAsFixed(3)
|
|
||||||
.endsWith("0")
|
|
||||||
? ""
|
? ""
|
||||||
: "~";
|
: "~";
|
||||||
|
|
||||||
|
final String itemTopText =
|
||||||
|
"$estimateSymbolDaily${itemDayAmount.toStringAsFixed(2)} ${Frequency.daily.title}";
|
||||||
|
final String itemMiddleText =
|
||||||
|
"$estimateSymbolMonthly${itemMonthAmount.toStringAsFixed(2)} ${Frequency.monthly.title}";
|
||||||
|
final String itemBottomText =
|
||||||
|
"$estimateSymbolYearly${itemYearAmount.toStringAsFixed(2)} ${Frequency.yearly.title}";
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(4.0),
|
padding: const EdgeInsets.all(4.0),
|
||||||
child: Dismissible(
|
child: Dismissible(
|
||||||
key: Key(curr.id!.toString()),
|
key: itemKey,
|
||||||
background: Container(
|
background: Container(
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -135,11 +164,11 @@ class _ExpensePageState extends State<ExpensePage> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
curr.name,
|
itemTitle,
|
||||||
style: TextStyle(fontSize: 20.0),
|
style: TextStyle(fontSize: 20.0),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"${curr.amount.toStringAsFixed(2)} ${curr.frequency.title}",
|
itemAmount,
|
||||||
style: TextStyle(fontSize: 12.0),
|
style: TextStyle(fontSize: 12.0),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -159,14 +188,16 @@ class _ExpensePageState extends State<ExpensePage> {
|
|||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
//if (curr.frequency != Frequency.daily)
|
|
||||||
Text(
|
Text(
|
||||||
"$estimateSymbolDaily${curr.calcComparableAmountDaily().toStringAsFixed(2)} ${Frequency.daily.title}",
|
itemTopText,
|
||||||
style: TextStyle(fontSize: 12.0),
|
style: TextStyle(fontSize: 12.0),
|
||||||
),
|
),
|
||||||
//if (curr.frequency != Frequency.yearly)
|
|
||||||
Text(
|
Text(
|
||||||
"$estimateSymbolYearly${curr.calcComparableAmountYearly().toStringAsFixed(2)} ${Frequency.yearly.title}",
|
itemMiddleText,
|
||||||
|
style: TextStyle(fontSize: 12.0),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
itemBottomText,
|
||||||
style: TextStyle(fontSize: 12.0),
|
style: TextStyle(fontSize: 12.0),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user