add prompt confirmation and update carton
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user