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) {
|
||||
//List<Expense> expenses = snapshot.data!;
|
||||
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
|
||||
.frequency.timesPerYear
|
||||
.toStringAsFixed(2)
|
||||
.endsWith(".00") &&
|
||||
curr
|
||||
.calcComparableAmountYearly()
|
||||
.toStringAsFixed(3)
|
||||
.endsWith("0")
|
||||
? ""
|
||||
: "~";
|
||||
final String estimateSymbolDaily = curr.frequency.numDays
|
||||
.toStringAsFixed(2)
|
||||
.endsWith(".00") &&
|
||||
curr
|
||||
.calcComparableAmountDaily()
|
||||
.toStringAsFixed(3)
|
||||
.endsWith("0")
|
||||
itemYearAmount.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(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: Dismissible(
|
||||
key: Key(curr.id!.toString()),
|
||||
key: itemKey,
|
||||
background: Container(
|
||||
color: Colors.red,
|
||||
child: Row(
|
||||
@ -135,11 +164,11 @@ class _ExpensePageState extends State<ExpensePage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
curr.name,
|
||||
itemTitle,
|
||||
style: TextStyle(fontSize: 20.0),
|
||||
),
|
||||
Text(
|
||||
"${curr.amount.toStringAsFixed(2)} ${curr.frequency.title}",
|
||||
itemAmount,
|
||||
style: TextStyle(fontSize: 12.0),
|
||||
),
|
||||
],
|
||||
@ -159,14 +188,16 @@ class _ExpensePageState extends State<ExpensePage> {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
//if (curr.frequency != Frequency.daily)
|
||||
Text(
|
||||
"$estimateSymbolDaily${curr.calcComparableAmountDaily().toStringAsFixed(2)} ${Frequency.daily.title}",
|
||||
itemTopText,
|
||||
style: TextStyle(fontSize: 12.0),
|
||||
),
|
||||
//if (curr.frequency != Frequency.yearly)
|
||||
Text(
|
||||
"$estimateSymbolYearly${curr.calcComparableAmountYearly().toStringAsFixed(2)} ${Frequency.yearly.title}",
|
||||
itemMiddleText,
|
||||
style: TextStyle(fontSize: 12.0),
|
||||
),
|
||||
Text(
|
||||
itemBottomText,
|
||||
style: TextStyle(fontSize: 12.0),
|
||||
),
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user