add prompt confirmation and update carton
This commit is contained in:
@@ -118,9 +118,13 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||
onPressed: () {
|
||||
showConfirmDialog(context, "back.button_confirm", () {
|
||||
if (isDataChanged()) {
|
||||
showConfirmDialog(context, "back.button_confirm", () {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
shadowColor: Colors.transparent,
|
||||
@@ -261,4 +265,12 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
isDataChanged() {
|
||||
return _user.fcsID != "" ||
|
||||
selectedMarket != "" ||
|
||||
_descCtl.text != "" ||
|
||||
_remarkCtl.text != "" ||
|
||||
multiImgController.getAddedFile.isNotEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,9 +172,13 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
icon:
|
||||
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||
onPressed: () {
|
||||
showConfirmDialog(context, "back.button_confirm", () {
|
||||
if (isDataChanged()) {
|
||||
showConfirmDialog(context, "back.button_confirm", () {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
shadowColor: Colors.transparent,
|
||||
@@ -324,4 +328,14 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
isDataChanged() {
|
||||
if (_isNew) {
|
||||
return this.packages.isNotEmpty || user != null || shipper != null;
|
||||
} else {
|
||||
Processing _processing = Processing(
|
||||
userID: user.fcsID, fcsID: shipper.fcsID, packages: this.packages);
|
||||
return widget.processing.isChangedForEdit(_processing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user