2020-12-10 20:06:15 +06:30
|
|
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
|
|
|
|
import 'package:fcs/helpers/theme.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/my_data_table.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
class CargoTable extends StatefulWidget {
|
|
|
|
|
final List<CargoType> cargoTypes;
|
|
|
|
|
|
|
|
|
|
const CargoTable({
|
|
|
|
|
Key key,
|
|
|
|
|
this.cargoTypes,
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_CargoTableState createState() => _CargoTableState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _CargoTableState extends State<CargoTable> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
child: MyDataTable(
|
|
|
|
|
headingRowHeight: 40,
|
2020-12-11 17:34:56 +06:30
|
|
|
columnSpacing: 50,
|
2020-12-10 20:06:15 +06:30
|
|
|
columns: [
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"cargo.type",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
2020-12-11 17:34:56 +06:30
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"cargo.qty",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
2020-12-10 20:06:15 +06:30
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"cargo.weight",
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
rows: getCargoRows(context),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<MyDataRow> getCargoRows(BuildContext context) {
|
|
|
|
|
if (widget.cargoTypes == null) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
double total = 0;
|
|
|
|
|
var rows = widget.cargoTypes.map((c) {
|
|
|
|
|
total += c.weight;
|
|
|
|
|
return MyDataRow(
|
|
|
|
|
onSelectChanged: (bool selected) async {},
|
|
|
|
|
cells: [
|
|
|
|
|
MyDataCell(new Text(
|
|
|
|
|
c.name == null ? "" : c.name,
|
|
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
2020-12-11 17:34:56 +06:30
|
|
|
MyDataCell(c.qty == null || c.qty == 0
|
|
|
|
|
? Center(
|
|
|
|
|
child: Text(
|
|
|
|
|
"-",
|
|
|
|
|
style: textStyle,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Center(
|
|
|
|
|
child: Text(
|
|
|
|
|
c.qty.toString(),
|
|
|
|
|
style: textStyle,
|
|
|
|
|
),
|
|
|
|
|
)),
|
2020-12-10 20:06:15 +06:30
|
|
|
MyDataCell(
|
|
|
|
|
Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2),
|
|
|
|
|
style: textStyle),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
var totalRow = MyDataRow(
|
|
|
|
|
onSelectChanged: (bool selected) {},
|
|
|
|
|
cells: [
|
|
|
|
|
MyDataCell(Align(
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
child: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"shipment.cargo.total",
|
|
|
|
|
color: Colors.black87,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
)),
|
2020-12-11 17:34:56 +06:30
|
|
|
MyDataCell(Text("")),
|
2020-12-10 20:06:15 +06:30
|
|
|
MyDataCell(
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 48.0),
|
|
|
|
|
child: Align(
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
child: Text(total.toStringAsFixed(2),
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold))),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
rows.add(totalRow);
|
|
|
|
|
return rows;
|
|
|
|
|
}
|
|
|
|
|
}
|