add prompt confirmation and update carton
This commit is contained in:
@@ -98,9 +98,13 @@ class _DiscountEditorState extends State<DiscountEditor> {
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () {
|
||||
showConfirmDialog(context, "back.button_confirm", () {
|
||||
if (isDataChanged()) {
|
||||
showConfirmDialog(context, "back.button_confirm", () {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
@@ -192,4 +196,19 @@ class _DiscountEditorState extends State<DiscountEditor> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
isDataChanged() {
|
||||
if (_isNew) {
|
||||
return _codeController.text != "" ||
|
||||
_amountController.text != "" ||
|
||||
customerName != "";
|
||||
} else {
|
||||
Discount _discount = Discount(
|
||||
code: _codeController.text,
|
||||
customerName: customerName,
|
||||
customerId: customerId,
|
||||
amount: double.parse(_amountController.text));
|
||||
return widget.discount.isChangedForEdit(_discount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user