update carton info
This commit is contained in:
@@ -14,10 +14,12 @@ typedef OnRemove(CargoType cargoType);
|
||||
|
||||
class CargoTable extends StatefulWidget {
|
||||
final List<CargoType> cargoTypes;
|
||||
final bool isNew;
|
||||
final OnAdd onAdd;
|
||||
final OnRemove onRemove;
|
||||
|
||||
const CargoTable({Key key, this.cargoTypes, this.onAdd, this.onRemove})
|
||||
const CargoTable(
|
||||
{Key key, this.cargoTypes, this.isNew, this.onAdd, this.onRemove})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -31,6 +33,15 @@ class _CargoTableState extends State<CargoTable> {
|
||||
List<String> _list = [];
|
||||
List<String> _types = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (!widget.isNew) {
|
||||
totalWeight = widget.cargoTypes
|
||||
.fold(0, (previous, current) => previous + current.weight);
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
remainingWeight =
|
||||
@@ -79,61 +90,17 @@ class _CargoTableState extends State<CargoTable> {
|
||||
|
||||
var rows = widget.cargoTypes.map((c) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (bool selected) async {
|
||||
// if (this.totalWeight <= 0) {
|
||||
// showMsgDialog(context, "Error", "Please insert total weight");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (c.isCutomDuty) return;
|
||||
// CargoType cargo = await Navigator.push<CargoType>(
|
||||
// context,
|
||||
// CupertinoPageRoute(
|
||||
// builder: (context) => CargoTypeEditor(
|
||||
// cargo: c,
|
||||
// )));
|
||||
// if (widget.onAdd != null) widget.onAdd(cargo);
|
||||
// if (cargo == null) return;
|
||||
|
||||
// this._cargos.add(cargo);
|
||||
// if (this.remainingWeight <= 0) return;
|
||||
// this.remainingWeight -= cargo.weight;
|
||||
|
||||
// this._cargos.forEach((c) {
|
||||
// _list.add(c.name);
|
||||
// });
|
||||
// widget.cargoTypes.forEach((c) {
|
||||
// _types.add(c.name);
|
||||
// });
|
||||
|
||||
// if (this._cargos.length == widget.cargoTypes.length - 1) {
|
||||
// _types.forEach((t) {
|
||||
// if (!_list.contains(t)) {
|
||||
// widget.cargoTypes.forEach((c) {
|
||||
// if (c.name == t) {
|
||||
// c.weight = this.remainingWeight;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
},
|
||||
onSelectChanged: (bool selected) async {},
|
||||
cells: [
|
||||
MyDataCell(Row(
|
||||
children: [
|
||||
new Text(
|
||||
c.name == null ? "" : c.name,
|
||||
style: textStyle,
|
||||
),
|
||||
new Text(
|
||||
c.qty == null ? "" : " x ${c.qty.toString()}",
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
],
|
||||
)),
|
||||
MyDataCell(
|
||||
new Text(
|
||||
c.name == null ? "" : c.name,
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
MyDataCell(
|
||||
c.isCutomDuty
|
||||
? InkWell(
|
||||
? GestureDetector(
|
||||
onTap: () async {
|
||||
String _t = await showDialog(
|
||||
context: context,
|
||||
|
||||
Reference in New Issue
Block a user