add prompt confirmation and update carton

This commit is contained in:
Thinzar Win
2020-12-08 20:24:15 +06:30
parent 1a7b1ce97b
commit 20477b6915
39 changed files with 637 additions and 259 deletions

View File

@@ -94,9 +94,13 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
if (isDataChanged()) {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
} else {
Navigator.of(context).pop();
});
}
},
),
backgroundColor: Colors.white,
@@ -271,4 +275,20 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
});
}
}
isDataChanged() {
if (_isNew) {
var mainModel = Provider.of<MainModel>(context, listen: false);
return _shipmentNumberController.text != "" ||
_cutoffDateController.text != "" ||
_arrivalDateController.text != "" ||
_consigneeController.text != "" ||
_portController.text != "" ||
_destinationController.text != "" ||
_currentShipmentType != mainModel.setting.shipmentTypes[0];
} else {
FcsShipment fcsShipment = _getPayload();
return widget.shipment.isChangedForEdit(fcsShipment);
}
}
}