Files
fcs/lib/pages/carton/carton_mix_table.dart

90 lines
2.7 KiB
Dart
Raw Normal View History

2020-10-20 06:19:10 +06:30
import 'package:fcs/domain/entities/carton.dart';
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 CartonMixTable extends StatelessWidget {
2021-09-10 12:00:08 +06:30
final List<Carton>? cartons;
final OnSelect? onSelect;
2020-10-20 06:19:10 +06:30
2021-09-10 12:00:08 +06:30
const CartonMixTable({Key? key, this.cartons, this.onSelect})
2020-10-20 06:19:10 +06:30
: super(key: key);
@override
Widget build(BuildContext context) {
final tableTitle = Container(
padding: EdgeInsets.only(right: 10.0, top: 20),
child: Row(
children: <Widget>[
Container(
width: 30,
),
Expanded(
child: LocalText(context, 'box.mix.number', color: Colors.grey),
),
LocalText(context, 'box.cargo.total', color: Colors.grey),
],
),
);
2020-10-21 02:59:10 +06:30
final rows = cartons == null
2021-09-10 12:00:08 +06:30
? [Container()]
: cartons!.asMap().entries.map((p) {
2020-10-21 02:59:10 +06:30
return Container(
2021-09-10 16:33:52 +06:30
color: (p.value.isChecked ?? false)
2020-10-21 02:59:10 +06:30
? Colors.grey.withOpacity(0.2)
2021-09-10 12:00:08 +06:30
: Colors.grey.shade50.withOpacity(0.2),
2020-10-21 02:59:10 +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-21 02:59:10 +06:30
? Colors.white
2021-09-10 12:00:08 +06:30
: Colors.grey.shade300,
2020-10-21 02:59:10 +06:30
width: 1),
),
),
child: Row(
children: <Widget>[
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-21 02:59:10 +06:30
}),
Expanded(
child: new Text(
2021-09-10 16:33:52 +06:30
p.value.cartonNumber ?? "",
2020-10-21 02:59:10 +06:30
style: textStyle,
)),
new Text(
2021-09-10 12:00:08 +06:30
p.value.actualWeight.toString(),
2020-10-21 02:59:10 +06:30
style: textStyle,
),
],
),
2020-10-20 06:19:10 +06:30
),
2020-10-21 02:59:10 +06:30
);
}).toList();
2020-10-20 06:19:10 +06:30
return Column(
children: [
LocalTitle(textKey: "box.shipment.boxes"),
tableTitle,
Divider(
color: Colors.grey[400],
),
Column(
children: rows,
),
],
);
}
}