This commit is contained in:
PhyoThandar
2020-06-29 16:03:41 +06:30
parent 94e9d79595
commit 8fbfac38de
11 changed files with 701 additions and 273 deletions

View File

@@ -586,6 +586,7 @@
"payment.attachment":"Payment Attachment",
"pdf_view.title":"Payment File",
"remaining_balance":"Remaining Balance : ",
"total.amount": "Amount :",
"payment.method.btn":"Payment Methods",
"payment.method.title":"Payment Methods",

View File

@@ -603,6 +603,7 @@
"payment.attachment":"ပေးချေပြီးဖိုင်များ",
"pdf_view.title":"ပေးဆောင်ခြင်းဖိုင်",
"remaining_balance":"ပေးချေရန်ကျန်ရှိငွေ : ",
"total.amount": "ပမာဏ :",
"payment.method.btn":"ငွေပေးချေစနစ်",
"payment.method.title":"ငွေပေးချေစနစ်",

View File

@@ -86,22 +86,21 @@ class MainModel extends ChangeNotifier {
List<PaymentMethod> methods = [
PaymentMethod(
name: 'AYA Bank',
accountName: 'AYA Co,Ltd',
accountName: 'FCS',
account: '100 23404320548398',
phone: '+959123456789',
mail: 'aya@gmail.com'),
PaymentMethod(
name: 'KBZ Bank',
accountName: 'KBZ Co,Ltd',
accountName: 'FCS',
account: '100 23404320548398',
phone: '+959123456789',
mail: 'kbz@gmail.com'),
PaymentMethod(
name: 'PayPal',
accountName: 'PayPal Co,Ltd',
account: '100 23404320548398',
phone: '+959123456789',
mail: 'paypal@gmail.com'),
accountName: 'FCS',
link: 'https://www.paypal.com/donate/buttons',
),
];
return methods;
}

View File

@@ -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>[
widget.invoice != null
? Padding(
padding: EdgeInsets.only(left: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 20),
child: Row(children: <Widget>[
LocalText(
context,
"invoice.payment",
color: Colors.grey,
fontSize: 14,
padding: EdgeInsets.only(top: 10),
child: Text(
'${dateFormatter.format(_invoice.receipts[0].date)} ',
style: TextStyle(
color: Colors.black, fontSize: 16),
),
MultiImageFile(
enabled: true,
),
Container(
padding: EdgeInsets.only(left: 10),
child: MultiImageFile(
enabled: false,
controller: multiImgController,
title: "Receipt File",
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,7 +720,6 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
}
getCargoTableByBox(BuildContext context) {
return _boxes.map((b) {
return Padding(
padding: const EdgeInsets.all(5.0),
child: Container(
@@ -560,8 +768,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
),
),
],
rows: getCargoDataRow(context, b),
),
rows: getCargoDataRow(context)),
),
),
)
@@ -569,11 +776,21 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
),
),
);
}).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(

View File

@@ -30,7 +30,6 @@ class _InvoiceListRowState extends State<InvoiceListRow> {
var dateFormatter = new DateFormat('dd MMM yyyy');
final double dotSize = 15.0;
Invoice _invoice = new Invoice();
// String pdfPath = 'assets/Invoice-A092(A)-32.pdf';
String pdfPath = '';
@override
@@ -41,11 +40,12 @@ class _InvoiceListRowState extends State<InvoiceListRow> {
_invoice = widget.invoice;
}
// fromAsset('assets/demo.pdf', 'demo.pdf').then((f) {
// setState(() {
// pdfPath = f.path;
// });
// });
fromAsset('assets/Invoice-A092(A)-32.pdf', 'Invoice-A092(A)-32.pdf')
.then((f) {
setState(() {
pdfPath = f.path;
});
});
}
Future<File> fromAsset(String asset, String filename) async {
@@ -73,21 +73,21 @@ class _InvoiceListRowState extends State<InvoiceListRow> {
var owner = Provider.of<MainModel>(context).isOwner();
return Container(
padding: EdgeInsets.only(left: 15, right: 15),
child: InkWell(
onTap: () {
owner
? Navigator.of(context)
.push(BottomUpPageRoute(InvoiceEditor(invoice: _invoice)))
: Navigator.pop(context);
// Navigator.of(context).push(BottomUpPageRoute(PaymentPDFScreen(
// path: pdfPath,
// )));
},
child: Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: InkWell(
onTap: () {
owner
? Navigator.of(context).push(
BottomUpPageRoute(InvoiceEditor(invoice: _invoice)))
: Navigator.of(context)
.push(BottomUpPageRoute(PaymentPDFScreen(
path: pdfPath,
)));
},
child: new Row(
children: <Widget>[
Container(
@@ -127,6 +127,7 @@ class _InvoiceListRowState extends State<InvoiceListRow> {
),
),
),
),
Padding(
padding: const EdgeInsets.all(0),
child: getStatus(_invoice.status),
@@ -160,7 +161,6 @@ class _InvoiceListRowState extends State<InvoiceListRow> {
),
],
),
),
);
}

View File

@@ -15,8 +15,6 @@ import 'package:flutter_icons/flutter_icons.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart';
class PaymentPage extends StatefulWidget {
final Invoice invoice;
@@ -40,9 +38,7 @@ class _PaymentPageState extends State<PaymentPage> {
Invoice _invoice = new Invoice();
bool _isLoading = false;
List<String> _receipts = [
"assets/photos/1.jpg",
"assets/photos/2.jpg",
"assets/photos/3.jpg"
"assets/photos/amazon_ins.png",
];
bool isNew;
@@ -50,6 +46,7 @@ class _PaymentPageState extends State<PaymentPage> {
void initState() {
if (widget.invoice != null) {
_invoice = widget.invoice;
multiImgController.setImageUrls = _receipts;
}
super.initState();
}
@@ -63,8 +60,6 @@ class _PaymentPageState extends State<PaymentPage> {
@override
Widget build(BuildContext context) {
var owner = Provider.of<MainModel>(context).isOwner();
// var images = isNew ? [] : _images;
return LocalProgress(
inAsyncCall: _isLoading,
@@ -81,6 +76,23 @@ class _PaymentPageState extends State<PaymentPage> {
body: Card(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(15.0),
child: Container(
child: Row(
children: <Widget>[
LocalText(context, 'total.amount',
color: Colors.black, fontSize: 16),
Text(
' \$ ${_invoice.amount}',
style: TextStyle(
color: primaryColor,
fontSize: 16,
fontWeight: FontWeight.bold),
)
],
)),
),
Padding(
padding: const EdgeInsets.all(15.0),
child: Container(
@@ -89,7 +101,7 @@ class _PaymentPageState extends State<PaymentPage> {
LocalText(context, 'remaining_balance',
color: Colors.black, fontSize: 16),
Text(
'${_invoice.amount}',
' \$ ${_invoice.amount - _invoice.receipts[0].amount}',
style: TextStyle(
color: primaryColor,
fontSize: 16,
@@ -105,21 +117,30 @@ class _PaymentPageState extends State<PaymentPage> {
title: LocalText(context, 'payment.attachment',
color: Colors.black, fontSize: 16),
children: <Widget>[
Container(
Padding(
padding: EdgeInsets.only(left: 20),
child: Row(children: <Widget>[
LocalText(
context,
"invoice.payment",
color: Colors.grey,
fontSize: 14,
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),
),
MultiImageFile(
),
Container(
padding: EdgeInsets.only(left: 10),
child: MultiImageFile(
enabled: true,
controller: multiImgController,
title: "Receipt File",
)
])),
)),
],
),
),
SizedBox(
height: 25,
),

View File

@@ -27,6 +27,7 @@ class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
TextEditingController _accountNumberController = new TextEditingController();
TextEditingController _mailController = new TextEditingController();
TextEditingController _phoneController = new TextEditingController();
TextEditingController _linkController = new TextEditingController();
bool isNew = false;
@@ -40,6 +41,7 @@ class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
_accountNumberController.text = _paymentMethod.account;
_mailController.text = _paymentMethod.mail;
_phoneController.text = _paymentMethod.phone;
_linkController.text = _paymentMethod.link;
} else {
isNew = true;
_nameController.text = '';
@@ -73,10 +75,12 @@ class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
controller: _accountNameController),
fcsInput('Account Number', FontAwesomeIcons.moneyBill,
controller: _accountNumberController),
fcsInput('E-mail', Icons.mail,
controller: _mailController),
fcsInput('Phone', Icons.phone,
controller: _phoneController)
// fcsInput('E-mail', Icons.mail,
// controller: _mailController),
// fcsInput('Phone', Icons.phone,
// controller: _phoneController),
fcsInput('Phone', Icons.link,
controller: _linkController)
],
),
),

View File

@@ -63,13 +63,6 @@ class _PaymentMethodPageState extends State<PaymentMethodPage> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Text(
// 'Account Name: ',
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.normal,
// fontSize: 15),
// ),
Text(
method.accountName,
style: TextStyle(
@@ -80,18 +73,12 @@ class _PaymentMethodPageState extends State<PaymentMethodPage> {
],
),
),
Padding(
method.account != null
? Padding(
padding: const EdgeInsets.only(left: 8.0, top: 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Text(
// 'Account Number: ',
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.normal,
// fontSize: 15),
// ),
Text(
method.account,
style: TextStyle(
@@ -101,21 +88,14 @@ class _PaymentMethodPageState extends State<PaymentMethodPage> {
),
],
),
),
Padding(
)
: Padding(
padding: const EdgeInsets.only(left: 8.0, top: 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Text(
// 'Email: ',
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.normal,
// fontSize: 15),
// ),
Text(
method.mail,
method.link,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
@@ -123,29 +103,7 @@ class _PaymentMethodPageState extends State<PaymentMethodPage> {
),
],
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, top: 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Text(
// 'Phone: ',
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.normal,
// fontSize: 15),
// ),
Text(
method.phone,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
fontSize: 15),
),
],
),
),
)
],
),
),
@@ -160,7 +118,7 @@ class _PaymentMethodPageState extends State<PaymentMethodPage> {
);
},
icon: Icon(Icons.add),
label: Text(AppTranslations.of(context).text("discount.new")),
label: Text(AppTranslations.of(context).text("payment.method.new")),
backgroundColor: primaryColor,
),
),

View File

@@ -1,7 +1,9 @@
import 'package:fcs/model/main_model.dart';
import 'package:fcs/model/shipment_model.dart';
import 'package:fcs/pages/barcode_screen_page.dart';
import 'package:fcs/pages/shipping_address_editor.dart';
import 'package:fcs/pages/util.dart';
import 'package:fcs/pages_fcs/shipping_address_row.dart';
import 'package:fcs/vo/package.dart';
import 'package:fcs/vo/shipping_address.dart';
import 'package:fcs/widget/bottom_up_page_route.dart';
@@ -17,6 +19,7 @@ import 'package:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart';
import '../theme/theme.dart';
import 'shipping_address_list.dart';
class PackageEditor extends StatefulWidget {
final Package package;
@@ -43,6 +46,13 @@ class _PackageEditorState extends State<PackageEditor> {
"assets/photos/3.jpg"
];
bool isNew;
ShippingAddress shippingAddress = ShippingAddress(
fullName: 'U Nyi Nyi',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247');
@override
void initState() {
@@ -352,6 +362,7 @@ class _PackageEditorState extends State<PackageEditor> {
),
],
),
getShippingAddressList(context),
isNew
? Container()
: ExpansionTile(
@@ -373,7 +384,6 @@ class _PackageEditorState extends State<PackageEditor> {
),
],
),
getShippingAddressList(context),
],
),
),
@@ -432,45 +442,152 @@ class _PackageEditorState extends State<PackageEditor> {
color: primaryColor),
),
children: <Widget>[
// Column(
// children: getAddressList(context, shipmentModel.shippingAddresses),
// ),
Container(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: MyDataTable(
headingRowHeight: 40,
columnSpacing: 50,
columns: [
MyDataColumn(
label: Text(
"Full Name",
style: TextStyle(
fontSize: 15,
color: Colors.grey[600],
padding: EdgeInsets.only(left: 10, right: 10),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Row(
children: <Widget>[
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.fullName == null
? ''
: shippingAddress.fullName,
style: new TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.addressLine1 == null
? ''
: shippingAddress.addressLine1,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.addressLine2 == null
? ''
: shippingAddress.addressLine2,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.city == null
? ''
: shippingAddress.city,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.state == null
? ''
: shippingAddress.state,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.phoneNumber == null
? ''
: "Phone:${shippingAddress.phoneNumber}",
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
)),
MyDataColumn(
label: Text(
"Phone Number",
style: TextStyle(
fontSize: 15,
color: Colors.grey[600],
),
)),
],
rows: getAddressRows(shipmentModel.shippingAddresses),
),
],
),
),
),
],
),
],
),
),
Container(
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 130,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () async {
var address = await Navigator.push(
context,
BottomUpPageRoute(ShippingAddressList()),
);
print('address => ${address}');
setState(() {
if (address != null) {
this.shippingAddress = address;
}
});
},
icon: Icon(Icons.add),
label: Text(
'Add Shipping\nAddress',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
)
],
),
);
}
List<Widget> getAddressList(
BuildContext context, List<ShippingAddress> addresses) {
return addresses.asMap().entries.map((s) {
return InkWell(
onTap: () {
Navigator.push(
context,
BottomUpPageRoute(ShippingAddressEditor(shippingAddress: s.value)),
);
},
child: ShippingAddressRow(shippingAddress: s.value, index: s.key),
);
}).toList();
}
List<MyDataRow> getAddressRows(List<ShippingAddress> addresses) {
return addresses.map((s) {
return MyDataRow(
onSelectChanged: (selected) {
},
onSelectChanged: (selected) {},
cells: [
MyDataCell(
new Text(

View File

@@ -0,0 +1,106 @@
import 'package:fcs/model/shipment_model.dart';
import 'package:fcs/pages/search_page.dart';
import 'package:fcs/pages_fcs/shipping_address_row.dart';
import 'package:fcs/vo/shipping_address.dart';
import 'package:fcs/widget/bottom_up_page_route.dart';
import 'package:fcs/widget/localization/app_translations.dart';
import 'package:fcs/widget/progress.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../theme/theme.dart';
class ShippingAddressList extends StatefulWidget {
@override
_ShippingAddressListState createState() => _ShippingAddressListState();
}
class _ShippingAddressListState extends State<ShippingAddressList> {
bool _isLoading = false;
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
var shipmentModel = Provider.of<ShipmentModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("shipping_address")),
actions: <Widget>[
IconButton(
icon: Icon(
Icons.search,
color: Colors.white,
),
iconSize: 30,
onPressed: () => showPlacesSearch(context),
),
],
),
body: Column(
children: <Widget>[
Expanded(
child: Column(
children:
getAddressList(context, shipmentModel.shippingAddresses),
),
),
Container(
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 130,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(ShippingAddressList()),
);
},
icon: Icon(Icons.add),
label: Text(
'Add Shipping\nAddress',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
),
],
)),
);
}
List<Widget> getAddressList(
BuildContext context, List<ShippingAddress> addresses) {
return addresses.asMap().entries.map((s) {
return InkWell(
onTap: () {
Navigator.pop(context, s.value);
},
child: ShippingAddressRow(shippingAddress: s.value, index: s.key),
);
}).toList();
}
}

View File

@@ -4,7 +4,13 @@ class PaymentMethod {
String account;
String phone;
String mail;
String link;
PaymentMethod(
{this.name, this.accountName, this.account, this.phone, this.mail});
{this.name,
this.accountName,
this.account,
this.phone,
this.mail,
this.link});
}