update invoice
This commit is contained in:
@@ -2,7 +2,9 @@ import 'package:fcs/domain/entities/invoice.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_title.dart';
|
||||
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
||||
import 'package:fcs/pages/widgets/multi_img_file.dart';
|
||||
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||
@@ -24,28 +26,18 @@ class PaymentPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PaymentPageState extends State<PaymentPage> {
|
||||
TextEditingController _addressEditingController = new TextEditingController();
|
||||
TextEditingController _fromTimeEditingController =
|
||||
new TextEditingController();
|
||||
TextEditingController _toTimeEditingController = new TextEditingController();
|
||||
TextEditingController _noOfPackageEditingController =
|
||||
new TextEditingController();
|
||||
TextEditingController _weightEditingController = new TextEditingController();
|
||||
MultiImgController multiImgController = MultiImgController();
|
||||
TextEditingController _amountController = new TextEditingController();
|
||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||
|
||||
Invoice _invoice = new Invoice();
|
||||
bool _isLoading = false;
|
||||
List<String> _receipts = [
|
||||
"assets/buying_online_with_first_last_name.png",
|
||||
];
|
||||
|
||||
bool isNew;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (widget.invoice != null) {
|
||||
_invoice = widget.invoice;
|
||||
// multiImgController.setImageUrls = _receipts;
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
@@ -59,7 +51,16 @@ class _PaymentPageState extends State<PaymentPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final saveBox = fcsButton(context, getLocalString(context, 'btn.save'));
|
||||
final amountBox = InputText(
|
||||
labelTextKey: 'pm.amount',
|
||||
controller: _amountController,
|
||||
iconData: FontAwesomeIcons.moneyBill);
|
||||
|
||||
final receiptFileBox = Row(children: [
|
||||
LocalText(context, 'pm.attachment', fontSize: 16, color: Colors.grey),
|
||||
IconButton(
|
||||
icon: Icon(Icons.attachment, color: primaryColor), onPressed: () {})
|
||||
]);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
@@ -72,117 +73,118 @@ class _PaymentPageState extends State<PaymentPage> {
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(AppTranslations.of(context).text("pm_.title")),
|
||||
actions: [
|
||||
IconButton(icon: Icon(Icons.cloud_upload), onPressed: () {})
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
LocalText(context, 'pm.total.amount',
|
||||
color: Colors.black, fontSize: 16),
|
||||
Text(
|
||||
' \$ ${_invoice.amount}',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold),
|
||||
)
|
||||
],
|
||||
)),
|
||||
Container(
|
||||
padding: const EdgeInsets.only(top: 15.0),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
LocalText(context, 'pm.remaining_balance',
|
||||
color: Colors.black, fontSize: 16),
|
||||
Text(
|
||||
' \$ ${_invoice.amount - _invoice.receipts[0].amount}',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold),
|
||||
)
|
||||
],
|
||||
)),
|
||||
amountBox,
|
||||
SizedBox(height: 10),
|
||||
receiptFileBox,
|
||||
SizedBox(height: 10),
|
||||
Divider(),
|
||||
SizedBox(height: 10),
|
||||
LocalText(context, 'pm.attachment',
|
||||
color: primaryColor, fontSize: 16, fontWeight: FontWeight.bold),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 20, top: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 8),
|
||||
child: Text(
|
||||
'${dateFormatter.format(_invoice.receipts[0].date)} ',
|
||||
style: TextStyle(color: Colors.black, fontSize: 16),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
child: MultiImageFile(
|
||||
enabled: true,
|
||||
controller: multiImgController,
|
||||
title: "Receipt File",
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
LocalTitle(textKey: "pm.receipt"),
|
||||
Column(
|
||||
children: getCustomFeeRows(context),
|
||||
),
|
||||
SizedBox(height: 25),
|
||||
Divider(),
|
||||
SizedBox(height: 10),
|
||||
LocalText(context, 'pm.receipt',
|
||||
color: primaryColor, fontSize: 16, fontWeight: FontWeight.bold),
|
||||
Container(
|
||||
child: MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columnSpacing: 20,
|
||||
columns: [
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"pm.date",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"pm.amount",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
rows: getPackageRow(context),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 25),
|
||||
// saveBox,
|
||||
// SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<MyDataRow> getPackageRow(BuildContext context) {
|
||||
return _invoice.receipts.map((r) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (bool selected) {},
|
||||
cells: [
|
||||
MyDataCell(
|
||||
new Text(dateFormatter.format(r.date), style: textStyle),
|
||||
),
|
||||
MyDataCell(NumberCell(r.amount))
|
||||
],
|
||||
getCustomFeeRows(BuildContext context) {
|
||||
List<Widget> dataRow = [];
|
||||
|
||||
dataRow = _invoice.receipts.asMap().entries.map((receipt) {
|
||||
var r = receipt.value;
|
||||
var k = receipt.key + 1;
|
||||
return Container(
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: Colors.grey))),
|
||||
padding:
|
||||
const EdgeInsets.only(left: 5.0, right: 5.0, top: 5.0, bottom: 5.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(flex: 2, child: Text(dateFormatter.format(r.date))),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Center(child: Text('receipt' + k.toString() + '.png'))),
|
||||
Expanded(flex: 1, child: Center(child: Text('pending'))),
|
||||
Expanded(flex: 1, child: Center(child: Text('\$ ${r.amount}'))),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
|
||||
dataRow.insert(
|
||||
0,
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: Colors.grey))),
|
||||
padding: const EdgeInsets.only(
|
||||
left: 5.0, right: 5.0, top: 10.0, bottom: 15.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text('Product', style: TextStyle(color: Colors.grey))),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text('File',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey))),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Text('Status',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey))),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Text('Fee',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey))),
|
||||
],
|
||||
),
|
||||
));
|
||||
|
||||
dataRow.insert(
|
||||
dataRow.length,
|
||||
Container(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Center(
|
||||
child: LocalText(
|
||||
context,
|
||||
'pm.remaining_balance',
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Container(),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Center(
|
||||
child: Text('\$ 300',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold, fontSize: 16.0)))),
|
||||
],
|
||||
),
|
||||
));
|
||||
return dataRow;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user