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 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: [ Container( width: 30, ), Expanded( child: LocalText(context, 'box.mix.number', color: Colors.grey), ), LocalText(context, 'box.cargo.total', color: Colors.grey), ], ), ); final rows = cartons.asMap().entries.map((p) { return Container( color: p.value.isChecked ? Colors.grey.withOpacity(0.2) : Colors.grey[50].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[350], width: 1), ), ), child: Row( children: [ 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, ), ], ); } }