Files
fcs/lib/pages/carton/carton_mix_table.dart
phyothandar 5e672937b5 null safety
2021-09-10 12:00:08 +06:30

90 lines
2.7 KiB
Dart

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 {
final List<Carton>? cartons;
final OnSelect? onSelect;
const CartonMixTable({Key? key, this.cartons, this.onSelect})
: 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),
],
),
);
final rows = cartons == null
? [Container()]
: cartons!.asMap().entries.map((p) {
return Container(
color: p.value.isChecked
? Colors.grey.withOpacity(0.2)
: Colors.grey.shade50.withOpacity(0.2),
child: Container(
padding: EdgeInsets.only(
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: p.key == cartons!.length - 1
? Colors.white
: Colors.grey.shade300,
width: 1),
),
),
child: Row(
children: <Widget>[
Checkbox(
value: p.value.isChecked,
activeColor: primaryColor,
onChanged: (bool? check) {
if (onSelect != null) onSelect!(p.value, check!);
}),
Expanded(
child: new Text(
p.value.cartonNumber,
style: textStyle,
)),
new Text(
p.value.actualWeight.toString(),
style: textStyle,
),
],
),
),
);
}).toList();
return Column(
children: [
LocalTitle(textKey: "box.shipment.boxes"),
tableTitle,
Divider(
color: Colors.grey[400],
),
Column(
children: rows,
),
],
);
}
}