2020-10-22 04:14:53 +06:30
|
|
|
import 'package:fcs/domain/entities/carton.dart';
|
2020-10-22 05:27:03 +06:30
|
|
|
import 'package:fcs/domain/entities/rate.dart';
|
2020-10-22 04:14:53 +06:30
|
|
|
import 'package:fcs/helpers/theme.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/local_title.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
typedef OnSelect = Function(Carton carton, bool checked);
|
|
|
|
|
|
|
|
|
|
class InvoiceCartonTable extends StatelessWidget {
|
2021-09-10 12:00:08 +06:30
|
|
|
final List<Carton>? cartons;
|
|
|
|
|
final OnSelect? onSelect;
|
|
|
|
|
final Rate? rate;
|
2020-10-22 04:14:53 +06:30
|
|
|
|
2021-09-10 12:00:08 +06:30
|
|
|
const InvoiceCartonTable({Key? key, this.cartons, this.onSelect, this.rate})
|
2020-10-22 04:14:53 +06:30
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final tableTitle = Container(
|
2020-10-24 06:14:07 +06:30
|
|
|
padding: EdgeInsets.only(right: 10.0, top: 5),
|
2020-10-22 04:14:53 +06:30
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 50,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 150,
|
|
|
|
|
child: LocalText(context, 'invoice.box.number', color: Colors.grey),
|
|
|
|
|
),
|
|
|
|
|
LocalText(context, 'invoice.shipment_weight', color: Colors.grey),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final rows = cartons == null
|
|
|
|
|
? [Container()]
|
2021-09-10 12:00:08 +06:30
|
|
|
: cartons!.asMap().entries.map((p) {
|
2020-10-22 04:14:53 +06:30
|
|
|
return Container(
|
2021-09-10 15:22:11 +06:30
|
|
|
color: p.value.isChecked!
|
2020-10-22 04:14:53 +06:30
|
|
|
? Colors.grey.withOpacity(0.2)
|
2021-09-10 12:00:08 +06:30
|
|
|
: Colors.grey.shade50.withOpacity(0.2),
|
2020-10-22 04:14:53 +06:30
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border(
|
|
|
|
|
bottom: BorderSide(
|
2021-09-10 12:00:08 +06:30
|
|
|
color: p.key == cartons!.length - 1
|
2020-10-22 04:14:53 +06:30
|
|
|
? Colors.white
|
2021-09-10 12:00:08 +06:30
|
|
|
: Colors.grey.shade300,
|
2020-10-22 04:14:53 +06:30
|
|
|
width: 1),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
onSelect == null
|
2021-09-10 15:22:11 +06:30
|
|
|
? p.value.isChecked!
|
2020-10-22 04:14:53 +06:30
|
|
|
? SizedBox(
|
|
|
|
|
child: Icon(Icons.check, color: primaryColor),
|
|
|
|
|
width: 30)
|
|
|
|
|
: SizedBox(width: 30)
|
|
|
|
|
: Checkbox(
|
|
|
|
|
value: p.value.isChecked,
|
|
|
|
|
activeColor: primaryColor,
|
2021-09-10 12:00:08 +06:30
|
|
|
onChanged: (bool? check) {
|
|
|
|
|
if (onSelect != null) onSelect!(p.value, check!);
|
2020-10-22 04:14:53 +06:30
|
|
|
}),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
2021-09-10 15:22:11 +06:30
|
|
|
p.value.cartonNumber!,
|
2020-10-22 04:14:53 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
Flexible(
|
|
|
|
|
child: new Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
new Text(
|
2021-09-10 12:00:08 +06:30
|
|
|
"${p.value.length} x ${p.value.width} x ${p.value.height}",
|
2020-10-22 04:14:53 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
),
|
2020-10-22 05:27:03 +06:30
|
|
|
new Text(
|
2021-09-10 12:00:08 +06:30
|
|
|
"${p.value.getShipmentWeight(rate!.volumetricRatio).toStringAsFixed(2)} lb",
|
2020-10-22 05:27:03 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
),
|
|
|
|
|
new Text(
|
2021-09-10 12:00:08 +06:30
|
|
|
"${p.value.actualWeight.toStringAsFixed(2)} lb (Actual)",
|
2020-10-22 05:27:03 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
),
|
2020-10-22 04:14:53 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
LocalTitle(textKey: "invoice.box_info"),
|
|
|
|
|
tableTitle,
|
|
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey[400],
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
children: rows,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|