update carton
This commit is contained in:
@@ -43,19 +43,23 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
Carton _carton;
|
||||
bool _isLoading = false;
|
||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||
|
||||
List<DeliveryAddress> _deliveryAddresses = [];
|
||||
List<CargoType> _cargoTypes = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_load();
|
||||
}
|
||||
|
||||
_load() {
|
||||
_carton = widget.carton;
|
||||
_getDeliverAddresses();
|
||||
if (widget.isNew) {
|
||||
_carton = widget.carton;
|
||||
_lengthCtl.text = "0";
|
||||
_widthCtl.text = "0";
|
||||
_heightCtl.text = "0";
|
||||
} else {
|
||||
_carton = widget.carton;
|
||||
_cargoTypes = List.from(widget.carton.cargoTypes);
|
||||
_lengthCtl.text = _carton.length.toString();
|
||||
_widthCtl.text = _carton.width.toString();
|
||||
@@ -64,6 +68,13 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
}
|
||||
}
|
||||
|
||||
_getDeliverAddresses() async {
|
||||
var addressModel =
|
||||
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||
this._deliveryAddresses =
|
||||
await addressModel.getDeliveryAddresses(_carton.userID);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final lengthBox = LengthPicker(
|
||||
@@ -163,8 +174,8 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => DeliveryAddressSelection(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
)),
|
||||
deliveryAddress: _deliveryAddress,
|
||||
deliveryAddresses: this._deliveryAddresses)),
|
||||
);
|
||||
if (d == null) return;
|
||||
setState(() {
|
||||
@@ -308,11 +319,12 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
CartonModel cartonModel =
|
||||
Provider.of<CartonModel>(context, listen: false);
|
||||
if (widget.isNew) {
|
||||
await cartonModel.createCarton(carton);
|
||||
Carton _c = await cartonModel.createCarton(carton);
|
||||
Navigator.pop(context, _c);
|
||||
} else {
|
||||
await cartonModel.updateCarton(carton);
|
||||
Navigator.pop(context, carton);
|
||||
}
|
||||
Navigator.pop(context, true);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user