update invoice page
This commit is contained in:
105
lib/pages/invoice/invoice_shipment_table.dart
Normal file
105
lib/pages/invoice/invoice_shipment_table.dart
Normal file
@@ -0,0 +1,105 @@
|
||||
import 'package:fcs/domain/entities/shipment.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef OnAdd(Shipment shipment);
|
||||
typedef OnRemove(Shipment shipment);
|
||||
|
||||
class InvoiceShipmentTable extends StatelessWidget {
|
||||
final List<Shipment> shipments;
|
||||
final OnAdd onAdd;
|
||||
final OnRemove onRemove;
|
||||
|
||||
const InvoiceShipmentTable(
|
||||
{Key key, this.shipments, this.onAdd, this.onRemove})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(
|
||||
context,
|
||||
"invoice.shipment.handling.fee.title",
|
||||
fontSize: 20,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: table(context),
|
||||
));
|
||||
}
|
||||
|
||||
Widget table(BuildContext context) {
|
||||
return MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columns: [
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"invoice.shipment.number",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"invoice.add.handling.fee.menu",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
rows: getRows(context),
|
||||
);
|
||||
}
|
||||
|
||||
List<MyDataRow> getRows(BuildContext context) {
|
||||
if (shipments == null) {
|
||||
return [];
|
||||
}
|
||||
var rows = shipments.map((c) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (value) => Navigator.pop(context, c),
|
||||
cells: [
|
||||
MyDataCell(new Text(
|
||||
c.shipmentNumber ?? "",
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(c.handlingFee?.toStringAsFixed(2) ?? "0",
|
||||
style: textStyle),
|
||||
onRemove == null
|
||||
? SizedBox(
|
||||
width: 50,
|
||||
)
|
||||
: IconButton(
|
||||
icon: Icon(
|
||||
Icons.remove_circle,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
if (onRemove != null) onRemove(c);
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user