Fix bug which sometimes set an edited expense to Monthly. Fix typo in enum monthly
.
This commit is contained in:
parent
452eb73773
commit
9d478b9cbf
@ -20,7 +20,7 @@ enum Frequency {
|
|||||||
hint: "Twice Per Month",
|
hint: "Twice Per Month",
|
||||||
timesPerYear: 24,
|
timesPerYear: 24,
|
||||||
),
|
),
|
||||||
montly(
|
monthly(
|
||||||
title: "Monthly",
|
title: "Monthly",
|
||||||
hint: "Once Per Month",
|
hint: "Once Per Month",
|
||||||
timesPerYear: 12,
|
timesPerYear: 12,
|
||||||
|
@ -161,12 +161,19 @@ class _ExpenseInputDialogState extends State<ExpenseInputDialog> {
|
|||||||
final _expenseFormKey = GlobalKey<FormState>();
|
final _expenseFormKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
String _name = "";
|
String _name = "";
|
||||||
double _cost = 0.0;
|
double _cost = 0;
|
||||||
Frequency _freq = Frequency.montly;
|
Frequency _freq = Frequency.monthly;
|
||||||
String _desc = "";
|
String _desc = "";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
if (widget.expense != null) {
|
||||||
|
_name = widget.expense!.name;
|
||||||
|
_cost = widget.expense!.cost;
|
||||||
|
_freq = widget.expense!.frequency;
|
||||||
|
_desc = widget.expense!.description;
|
||||||
|
}
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
// prevent AlertDialog from taking full vertical height.
|
// prevent AlertDialog from taking full vertical height.
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@ -206,8 +213,7 @@ class _ExpenseInputDialogState extends State<ExpenseInputDialog> {
|
|||||||
hintStyle: TextStyle(fontSize: 10.0),
|
hintStyle: TextStyle(fontSize: 10.0),
|
||||||
errorStyle: TextStyle(fontSize: 10.0),
|
errorStyle: TextStyle(fontSize: 10.0),
|
||||||
),
|
),
|
||||||
initialValue:
|
initialValue: _name,
|
||||||
widget.expense == null ? "" : widget.expense!.name,
|
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value!.isEmpty) {
|
if (value!.isEmpty) {
|
||||||
return "Name must be provided.";
|
return "Name must be provided.";
|
||||||
@ -229,9 +235,7 @@ class _ExpenseInputDialogState extends State<ExpenseInputDialog> {
|
|||||||
hintStyle: TextStyle(fontSize: 10.0),
|
hintStyle: TextStyle(fontSize: 10.0),
|
||||||
errorStyle: TextStyle(fontSize: 10.0),
|
errorStyle: TextStyle(fontSize: 10.0),
|
||||||
),
|
),
|
||||||
initialValue: widget.expense == null
|
initialValue: _cost != 0 ? _cost.toString() : "",
|
||||||
? ""
|
|
||||||
: widget.expense!.cost.toString(),
|
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value == null || value.isEmpty) {
|
if (value == null || value.isEmpty) {
|
||||||
return "Cost must be provided.";
|
return "Cost must be provided.";
|
||||||
@ -273,9 +277,7 @@ class _ExpenseInputDialogState extends State<ExpenseInputDialog> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
value: widget.expense == null
|
value: _freq,
|
||||||
? Frequency.montly
|
|
||||||
: widget.expense!.frequency,
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: "Frequency",
|
labelText: "Frequency",
|
||||||
errorStyle: TextStyle(fontSize: 10.0),
|
errorStyle: TextStyle(fontSize: 10.0),
|
||||||
@ -301,8 +303,7 @@ class _ExpenseInputDialogState extends State<ExpenseInputDialog> {
|
|||||||
hintStyle: TextStyle(fontSize: 10.0),
|
hintStyle: TextStyle(fontSize: 10.0),
|
||||||
errorStyle: TextStyle(fontSize: 10.0),
|
errorStyle: TextStyle(fontSize: 10.0),
|
||||||
),
|
),
|
||||||
initialValue:
|
initialValue: _desc,
|
||||||
widget.expense == null ? "" : widget.expense!.description,
|
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user