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

@@ -29,13 +29,14 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
TextEditingController _minWeight = new TextEditingController();
TextEditingController _deliveryFee = new TextEditingController();
TextEditingController _volumetricRatio = new TextEditingController();
Rate rate;
@override
void initState() {
super.initState();
var shipmentRateModel =
Provider.of<ShipmentRateModel>(context, listen: false);
Rate rate = shipmentRateModel.rate;
rate = shipmentRateModel.rate;
_minWeight.text = rate.freeDeliveryWeight?.toStringAsFixed(2) ?? "";
_deliveryFee.text = rate.deliveryFee?.toStringAsFixed(2) ?? "";
@@ -74,9 +75,13 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
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,
@@ -130,6 +135,14 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
}
}
isDataChanged() {
Rate _rate = new Rate(
deliveryFee: double.parse(_deliveryFee.text),
freeDeliveryWeight: double.parse(_minWeight.text),
volumetricRatio: double.parse(_volumetricRatio.text));
return rate.isChangedForEdit(_rate);
}
List<MyDataRow> getCargoRows(List<CargoType> cargos) {
return cargos.map((r) {
return MyDataRow(