fix errors
This commit is contained in:
107
lib/pages/invoice/invoice_custom_table.dart
Normal file
107
lib/pages/invoice/invoice_custom_table.dart
Normal file
@@ -0,0 +1,107 @@
|
||||
import 'package:fcs/domain/entities/custom_duty.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(CustomDuty customDuty);
|
||||
typedef OnRemove(CustomDuty customDuty);
|
||||
|
||||
class InvoiceCustomTable extends StatelessWidget {
|
||||
final List<CustomDuty> customDuties;
|
||||
final OnAdd onAdd;
|
||||
final OnRemove onRemove;
|
||||
|
||||
const InvoiceCustomTable(
|
||||
{Key key, this.customDuties, this.onAdd, this.onRemove})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columns: [
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"rate.cutom.product_type",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"rate.custom.fee",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
rows: getRows(context),
|
||||
);
|
||||
}
|
||||
|
||||
List<MyDataRow> getRows(BuildContext context) {
|
||||
if (customDuties == null) {
|
||||
return [];
|
||||
}
|
||||
double total = 0;
|
||||
var rows = customDuties.map((c) {
|
||||
total += c.fee;
|
||||
return MyDataRow(
|
||||
cells: [
|
||||
MyDataCell(new Text(
|
||||
c.productType == null ? "" : c.productType,
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(c.fee == null ? "0" : c.fee.toString(), style: textStyle),
|
||||
onRemove == null
|
||||
? SizedBox(
|
||||
width: 50,
|
||||
)
|
||||
: IconButton(
|
||||
icon: Icon(
|
||||
Icons.remove_circle,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
if (onRemove != null) onRemove(c);
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
|
||||
var totalRow = MyDataRow(
|
||||
onSelectChanged: (bool selected) {},
|
||||
cells: [
|
||||
MyDataCell(Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: LocalText(
|
||||
context,
|
||||
"invoice.total_custom_fee",
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)),
|
||||
MyDataCell(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 48.0),
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text(total.toString(),
|
||||
style: TextStyle(fontWeight: FontWeight.bold))),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
rows.add(totalRow);
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user