2020-10-20 06:19:10 +06:30
|
|
|
import 'package:fcs/domain/entities/package.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/material.dart';
|
|
|
|
|
|
|
|
|
|
typedef OnSelect = Function(Package package, bool checked);
|
|
|
|
|
|
|
|
|
|
class CartonPackageTable extends StatelessWidget {
|
2021-09-10 12:00:08 +06:30
|
|
|
final List<Package>? packages;
|
|
|
|
|
final OnSelect? onSelect;
|
2020-10-20 06:19:10 +06:30
|
|
|
|
2021-09-10 12:00:08 +06:30
|
|
|
const CartonPackageTable({Key? key, this.packages, 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>[
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 50,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 150,
|
|
|
|
|
child: LocalText(context, 'box.tracking.id', color: Colors.grey),
|
|
|
|
|
),
|
|
|
|
|
LocalText(context, 'box.package.desc', color: Colors.grey),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final rows = packages == null
|
|
|
|
|
? [Container()]
|
2021-09-10 12:00:08 +06:30
|
|
|
: packages!.asMap().entries.map((p) {
|
2020-10-20 06:19:10 +06:30
|
|
|
return Container(
|
|
|
|
|
color: p.value.isChecked
|
|
|
|
|
? Colors.grey.withOpacity(0.2)
|
2021-09-10 12:00:08 +06:30
|
|
|
: Colors.grey.shade50.withOpacity(0.2),
|
2020-10-20 06:19: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 == packages!.length - 1
|
2020-10-20 06:19:10 +06:30
|
|
|
? Colors.white
|
2021-09-10 12:00:08 +06:30
|
|
|
: Colors.grey.shade300,
|
2020-10-20 06:19:10 +06:30
|
|
|
width: 1),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
onSelect == null
|
|
|
|
|
? p.value.isChecked
|
|
|
|
|
? 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-20 06:19:10 +06:30
|
|
|
}),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
2021-09-10 16:33:52 +06:30
|
|
|
p.value.trackingID ?? "",
|
2020-10-20 06:19:10 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
2021-09-10 16:33:52 +06:30
|
|
|
p.value.deliveryAddress?.fullName ?? "",
|
2020-10-20 06:19:10 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
2021-09-10 16:33:52 +06:30
|
|
|
p.value.deliveryAddress?.phoneNumber ?? "",
|
2020-10-20 06:19:10 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
Flexible(
|
|
|
|
|
child: new Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
new Text(
|
2021-09-10 16:33:52 +06:30
|
|
|
p.value.desc ?? "",
|
2020-10-20 06:19:10 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
),
|
|
|
|
|
new Text(
|
2021-09-10 12:00:08 +06:30
|
|
|
"(${p.value.market})",
|
2020-10-20 06:19:10 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
LocalTitle(textKey: "box.packages"),
|
|
|
|
|
tableTitle,
|
|
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey[400],
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
children: rows,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|