update shipment and carton
This commit is contained in:
@@ -70,10 +70,11 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
_fromTimeEditingController.text = "${timeFormatter.format(now)}";
|
||||
_toTimeEditingController.text = "${timeFormatter.format(now)}";
|
||||
// _shipment = Shipment(boxes: []);
|
||||
var shipmentModel =
|
||||
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||
_shipment!.pickupAddress = shipmentModel.defalutAddress;
|
||||
_shipment!.boxes = [];
|
||||
|
||||
Shipment _s = Shipment(
|
||||
pickupAddress: context.read<DeliveryAddressModel>().defalutAddress,
|
||||
boxes: []);
|
||||
_shipment = _s;
|
||||
_pickupDate.text = dateFormatter.format(now);
|
||||
}
|
||||
}
|
||||
@@ -87,12 +88,12 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
Widget build(BuildContext context) {
|
||||
MainModel mainModel = Provider.of<MainModel>(context);
|
||||
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
|
||||
final shipmentNumberBox = getShipmentNumberStatus(context, _shipment!);
|
||||
final shipmentNumberBox = getShipmentNumberStatus(context, _shipment);
|
||||
bool isLocalPickup = _selectedShipmentType == shipment_local_pickup;
|
||||
bool isCourierPickup = _selectedShipmentType == shipment_courier_pickup;
|
||||
bool isLocalDropoff = _selectedShipmentType == shipment_local_dropoff;
|
||||
bool isCourierDropoff = _selectedShipmentType == shipment_courier_dropoff;
|
||||
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
||||
|
||||
final fromTimeBox = InputTime(
|
||||
labelTextKey: 'shipment.from',
|
||||
iconData: Icons.timer,
|
||||
@@ -122,7 +123,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
backgroundColor: Colors.white,
|
||||
));
|
||||
final pickupAddressBox = DefaultDeliveryAddress(
|
||||
deliveryAddress: _shipment!.pickupAddress,
|
||||
deliveryAddress: _shipment?.pickupAddress,
|
||||
iconData: Icons.location_on,
|
||||
labelKey: "shipment.location",
|
||||
onTap: () async {
|
||||
@@ -130,12 +131,15 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => DeliveryAddressSelection(
|
||||
deliveryAddress: _shipment!.pickupAddress,
|
||||
deliveryAddress: _shipment?.pickupAddress,
|
||||
user: mainModel.user)),
|
||||
);
|
||||
|
||||
if (address == null) return;
|
||||
|
||||
setState(() {
|
||||
_shipment!.pickupAddress = address;
|
||||
Shipment _s = Shipment(pickupAddress: address);
|
||||
_shipment = _s;
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -230,17 +234,18 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
Carton box = await Navigator.push(
|
||||
Carton? box = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => ShipmentBoxEditor()),
|
||||
);
|
||||
if (box == null) return;
|
||||
_addBox(box);
|
||||
},
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: getBoxList(context, _shipment!.boxes),
|
||||
children: getBoxList(context, _shipment?.boxes ?? []),
|
||||
),
|
||||
_isNew ? createBtn : updateBtn,
|
||||
],
|
||||
@@ -324,6 +329,6 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
}
|
||||
|
||||
isDataChanged() {
|
||||
return _shipment!.boxes.isNotEmpty;
|
||||
return _shipment?.boxes.isNotEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user