modify
This commit is contained in:
@@ -40,13 +40,26 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
TextEditingController _discountController = new TextEditingController();
|
||||
TextEditingController _amountController = new TextEditingController();
|
||||
TextEditingController _statusController = new TextEditingController();
|
||||
TextEditingController _handlingFeeController = new TextEditingController();
|
||||
TextEditingController _customFeeController = new TextEditingController();
|
||||
MultiImgController multiImgController = MultiImgController();
|
||||
TextEditingController _descriptionController = new TextEditingController();
|
||||
TextEditingController _balanceController = new TextEditingController();
|
||||
|
||||
Invoice _invoice;
|
||||
bool _isLoading = false;
|
||||
List<Box> _boxes = [];
|
||||
bool isSwitched = false;
|
||||
String deliveryfee = '\$0';
|
||||
List<Cargo> _cargoTypes = [
|
||||
Cargo(type: 'General Cargo', weight: 33, price: 6),
|
||||
Cargo(type: 'Medicine', weight: 33, price: 7),
|
||||
Cargo(type: 'Dangerous Cargo', weight: 33, price: 8)
|
||||
];
|
||||
|
||||
List<String> _receipts = [
|
||||
"assets/photos/amazon_ins.png",
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -57,10 +70,24 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
_dateController.text = dateFormatter.format(_invoice.invoiceDate);
|
||||
_nameController.text = _invoice.customerName;
|
||||
_phoneController.text = _invoice.customerPhoneNumber;
|
||||
_amountController.text = _invoice.getAmount.toString();
|
||||
// _amountController.text = _invoice.getAmount.toString();
|
||||
_amountController.text = _invoice.amount.toString();
|
||||
_statusController.text = _invoice.status.toString();
|
||||
_handlingFeeController.text = '0';
|
||||
_customFeeController.text = '0';
|
||||
multiImgController.setImageUrls = _receipts;
|
||||
_descriptionController.text = 'For Electronics goods';
|
||||
_balanceController.text =
|
||||
(_invoice.amount - _invoice.receipts[0].amount).toString();
|
||||
// _boxes = _invoice.packages;
|
||||
} else {}
|
||||
} else {
|
||||
_dateController.text = dateFormatter.format(DateTime.now());
|
||||
_amountController.text = '0';
|
||||
_handlingFeeController.text = '0';
|
||||
_customFeeController.text = '0';
|
||||
_descriptionController.text = '';
|
||||
_balanceController.text = '0';
|
||||
}
|
||||
|
||||
_boxes = [
|
||||
Box(
|
||||
@@ -140,8 +167,22 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(children: <Widget>[
|
||||
fcsInput('Invoice Date', Icons.date_range,
|
||||
controller: _dateController),
|
||||
TextFormField(
|
||||
controller: _dateController,
|
||||
readOnly: true,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Invoice Date',
|
||||
labelStyle:
|
||||
TextStyle(fontSize: 16,),
|
||||
filled: true,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
icon: Icon(
|
||||
Icons.date_range,
|
||||
color: primaryColor,
|
||||
),
|
||||
)),
|
||||
widget.invoice == null
|
||||
? Container()
|
||||
: Container(
|
||||
@@ -152,8 +193,8 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Invoice Number',
|
||||
labelStyle:
|
||||
TextStyle(fontSize: 16, color: Colors.grey),
|
||||
labelStyle: TextStyle(
|
||||
fontSize: 16,),
|
||||
filled: true,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
@@ -173,7 +214,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Customer Name',
|
||||
labelStyle:
|
||||
TextStyle(fontSize: 16, color: Colors.grey),
|
||||
TextStyle(fontSize: 16,),
|
||||
filled: true,
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
@@ -202,7 +243,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Customer Name',
|
||||
labelStyle: TextStyle(
|
||||
fontSize: 16, color: primaryColor),
|
||||
fontSize: 16,),
|
||||
filled: true,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
@@ -236,28 +277,6 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
// controller: _amountController),
|
||||
// ),
|
||||
|
||||
widget.invoice == null
|
||||
? Container()
|
||||
: Container(
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
child: TextFormField(
|
||||
controller: _amountController,
|
||||
readOnly: true,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Amount',
|
||||
labelStyle: TextStyle(
|
||||
fontSize: 16, color: primaryColor),
|
||||
filled: true,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.moneyBill,
|
||||
color: primaryColor,
|
||||
),
|
||||
)),
|
||||
),
|
||||
|
||||
widget.invoice == null
|
||||
? Container()
|
||||
: Container(
|
||||
@@ -269,7 +288,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Status',
|
||||
labelStyle: TextStyle(
|
||||
fontSize: 16, color: primaryColor),
|
||||
fontSize: 16, ),
|
||||
filled: true,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
@@ -280,13 +299,120 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
)),
|
||||
),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
child: TextFormField(
|
||||
controller: _amountController,
|
||||
readOnly: true,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Amount',
|
||||
labelStyle:
|
||||
TextStyle(fontSize: 16,),
|
||||
filled: true,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.moneyBill,
|
||||
color: primaryColor,
|
||||
),
|
||||
)),
|
||||
),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: TextFormField(
|
||||
controller: _balanceController,
|
||||
readOnly: true,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Balance',
|
||||
labelStyle:
|
||||
TextStyle(fontSize: 16, ),
|
||||
filled: true,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.moneyBill,
|
||||
color: primaryColor,
|
||||
),
|
||||
)),
|
||||
),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: TextFormField(
|
||||
controller: _handlingFeeController,
|
||||
readOnly: true,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Handling Fee',
|
||||
labelStyle:
|
||||
TextStyle(fontSize: 16,),
|
||||
filled: true,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.moneyBill,
|
||||
color: primaryColor,
|
||||
),
|
||||
)),
|
||||
),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: TextFormField(
|
||||
controller: _customFeeController,
|
||||
readOnly: false,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Customs Fee',
|
||||
labelStyle:
|
||||
TextStyle(fontSize: 16,),
|
||||
filled: true,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.moneyBill,
|
||||
color: primaryColor,
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.grey, width: 1.0)),
|
||||
)),
|
||||
),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: TextFormField(
|
||||
controller: _descriptionController,
|
||||
readOnly: false,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Customs Fee Description',
|
||||
labelStyle:
|
||||
TextStyle(fontSize: 16,),
|
||||
filled: true,
|
||||
icon: Icon(
|
||||
Icons.comment,
|
||||
color: primaryColor,
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.grey, width: 1.0)),
|
||||
)),
|
||||
),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 20, left: 18),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text('Discounts',
|
||||
style: TextStyle(fontSize: 16))),
|
||||
child: Text(
|
||||
'Discounts',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold),
|
||||
)),
|
||||
Container(
|
||||
width: 150.0,
|
||||
child: DropdownButtonFormField(
|
||||
@@ -306,8 +432,13 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text('Payment Method',
|
||||
style: TextStyle(fontSize: 16))),
|
||||
child: Text(
|
||||
'Payment Method',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold),
|
||||
)),
|
||||
Container(
|
||||
width: 150.0,
|
||||
child: DropdownButtonFormField(
|
||||
@@ -330,7 +461,10 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
padding: const EdgeInsets.only(left: 18.0),
|
||||
child: Text(
|
||||
'Delivery fee:',
|
||||
style: TextStyle(fontSize: 16),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
)),
|
||||
Switch(
|
||||
@@ -349,38 +483,70 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
activeTrackColor: primaryColor.withOpacity(0.8),
|
||||
activeColor: primaryColor,
|
||||
),
|
||||
Text('(Delivery fee : $deliveryfee)',style: TextStyle(color: primaryColor,fontWeight: FontWeight.bold),),
|
||||
Text(
|
||||
'(Delivery fee : $deliveryfee)',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
|
||||
ExpansionTile(
|
||||
title: Text('Payment Attachment'),
|
||||
title: Text(
|
||||
'Payment Attachment',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 20),
|
||||
child: Row(children: <Widget>[
|
||||
LocalText(
|
||||
context,
|
||||
"invoice.payment",
|
||||
color: Colors.grey,
|
||||
fontSize: 14,
|
||||
),
|
||||
MultiImageFile(
|
||||
enabled: true,
|
||||
controller: multiImgController,
|
||||
title: "Receipt File",
|
||||
widget.invoice != null
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(left: 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
'${dateFormatter.format(_invoice.receipts[0].date)} ',
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 16),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
child: MultiImageFile(
|
||||
enabled: false,
|
||||
controller: multiImgController,
|
||||
title: "Receipt",
|
||||
)),
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 10, left: 10),
|
||||
child: Text(
|
||||
'\$${_invoice.receipts[0].amount} ',
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
])),
|
||||
: Container(),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text('Box Information'),
|
||||
title: Text(
|
||||
'Box Information',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: SingleChildScrollView(
|
||||
@@ -446,9 +612,52 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
|
||||
//Cargo Table
|
||||
ExpansionTile(
|
||||
title: Text('Cargo Table'),
|
||||
children: getCargoTableByBox(context),
|
||||
),
|
||||
title: Text(
|
||||
'Cargo Table',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columnSpacing: 20,
|
||||
columns: [
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"cargo.type",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"cargo.weight",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"cargo.rate",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"cargo.amount",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
rows: getCargoDataRow(context)),
|
||||
),
|
||||
),
|
||||
]),
|
||||
]),
|
||||
)),
|
||||
widget.invoice == null
|
||||
@@ -511,23 +720,22 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
}
|
||||
|
||||
getCargoTableByBox(BuildContext context) {
|
||||
return _boxes.map((b) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.grey[100],
|
||||
width: 1,
|
||||
),
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.grey[100],
|
||||
width: 1,
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: MyDataTable(
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columnSpacing: 20,
|
||||
columns: [
|
||||
@@ -560,20 +768,29 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
),
|
||||
),
|
||||
],
|
||||
rows: getCargoDataRow(context, b),
|
||||
),
|
||||
),
|
||||
rows: getCargoDataRow(context)),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<MyDataRow> getBoxRow(BuildContext context) {
|
||||
return _boxes.map((p) {
|
||||
p.cargoTypes.map((cargo) {
|
||||
print('cargo => $cargo');
|
||||
_cargoTypes.asMap().map((index, _cargo) {
|
||||
if (_cargo.type == cargo.type) {
|
||||
setState(() {
|
||||
_cargoTypes[index].weight += cargo.weight;
|
||||
});
|
||||
print('${_cargoTypes[index].type} =>${_cargoTypes[index]}');
|
||||
}
|
||||
});
|
||||
});
|
||||
return MyDataRow(
|
||||
onSelectChanged: (bool selected) {},
|
||||
cells: [
|
||||
@@ -600,24 +817,22 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
List<MyDataRow> getCargoDataRow(BuildContext context, Box box) {
|
||||
var rate = 5;
|
||||
return box.cargoTypes.map((p) {
|
||||
rate++;
|
||||
var amt = p.weight * rate;
|
||||
List<MyDataRow> getCargoDataRow(BuildContext context) {
|
||||
return _cargoTypes.map((cargo) {
|
||||
var amt = cargo.weight * cargo.price;
|
||||
return MyDataRow(
|
||||
onSelectChanged: (bool selected) {},
|
||||
cells: [
|
||||
MyDataCell(new Text(
|
||||
p.type,
|
||||
cargo.type,
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(new Text(
|
||||
p.weight.toString(),
|
||||
cargo.weight.toString(),
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(new Text(
|
||||
'\$${rate}',
|
||||
'\$${cargo.price}',
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(new Text(
|
||||
|
||||
Reference in New Issue
Block a user