diff --git a/assets/local/localization_en.json b/assets/local/localization_en.json index f2ce227..20e8fbb 100644 --- a/assets/local/localization_en.json +++ b/assets/local/localization_en.json @@ -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", diff --git a/assets/local/localization_mu.json b/assets/local/localization_mu.json index 0d24c08..83993ac 100644 --- a/assets/local/localization_mu.json +++ b/assets/local/localization_mu.json @@ -603,6 +603,7 @@ "payment.attachment":"ပေးချေပြီးဖိုင်များ", "pdf_view.title":"ပေးဆောင်ခြင်းဖိုင်", "remaining_balance":"ပေးချေရန်ကျန်ရှိငွေ : ", + "total.amount": "ပမာဏ :", "payment.method.btn":"ငွေပေးချေစနစ်", "payment.method.title":"ငွေပေးချေစနစ်", diff --git a/lib/model/main_model.dart b/lib/model/main_model.dart index 4d5d3e9..730b399 100644 --- a/lib/model/main_model.dart +++ b/lib/model/main_model.dart @@ -86,22 +86,21 @@ class MainModel extends ChangeNotifier { List 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; } diff --git a/lib/pages/invoice/invoice_editor.dart b/lib/pages/invoice/invoice_editor.dart index 603710d..a4c54e8 100644 --- a/lib/pages/invoice/invoice_editor.dart +++ b/lib/pages/invoice/invoice_editor.dart @@ -40,13 +40,26 @@ class _InvoiceEditorState extends State { 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 _boxes = []; bool isSwitched = false; String deliveryfee = '\$0'; + List _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 _receipts = [ + "assets/photos/amazon_ins.png", + ]; @override void initState() { @@ -57,10 +70,24 @@ class _InvoiceEditorState extends State { _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 { child: Padding( padding: const EdgeInsets.all(10.0), child: ListView(children: [ - 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 { 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 { 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 { 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 { // 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 { 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 { )), ), + 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: [ 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 { child: Row( children: [ 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 { 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 { 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: [ - Container( - padding: EdgeInsets.only(left: 20), - child: Row(children: [ - 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: [ + 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: [ Container( child: SingleChildScrollView( @@ -446,9 +612,52 @@ class _InvoiceEditorState extends State { //Cargo Table ExpansionTile( - title: Text('Cargo Table'), - children: getCargoTableByBox(context), - ), + title: Text( + 'Cargo Table', + style: TextStyle( + color: primaryColor, fontWeight: FontWeight.bold), + ), + children: [ + 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 { } 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: [ - Expanded( - child: Container( - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: MyDataTable( + ), + child: Row( + children: [ + Expanded( + child: Container( + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: MyDataTable( headingRowHeight: 40, columnSpacing: 20, columns: [ @@ -560,20 +768,29 @@ class _InvoiceEditorState extends State { ), ), ], - rows: getCargoDataRow(context, b), - ), - ), + rows: getCargoDataRow(context)), ), - ) - ], - ), + ), + ) + ], ), - ); - }).toList(); + ), + ); } List 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 { }).toList(); } - List getCargoDataRow(BuildContext context, Box box) { - var rate = 5; - return box.cargoTypes.map((p) { - rate++; - var amt = p.weight * rate; + List 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( diff --git a/lib/pages/invoice/invoice_list_row.dart b/lib/pages/invoice/invoice_list_row.dart index f0972d4..7de114a 100644 --- a/lib/pages/invoice/invoice_list_row.dart +++ b/lib/pages/invoice/invoice_list_row.dart @@ -30,7 +30,6 @@ class _InvoiceListRowState extends State { 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 { _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 fromAsset(String asset, String filename) async { @@ -73,21 +73,21 @@ class _InvoiceListRowState extends State { var owner = Provider.of(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: [ - Expanded( - child: new Padding( - padding: const EdgeInsets.symmetric(vertical: 10.0), + child: Row( + children: [ + 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: [ Container( @@ -127,39 +127,39 @@ class _InvoiceListRowState extends State { ), ), ), - Padding( - padding: const EdgeInsets.all(0), - child: getStatus(_invoice.status), - ), - Padding( - padding: const EdgeInsets.only(left: 10.0), - child: InkWell( - child: Icon( - Icons.payment, - color: primaryColor, - ), - onTap: () { - Navigator.of(context) - .push(BottomUpPageRoute(PaymentPage(invoice: _invoice))); - }, + ), + Padding( + padding: const EdgeInsets.all(0), + child: getStatus(_invoice.status), + ), + Padding( + padding: const EdgeInsets.only(left: 10.0), + child: InkWell( + child: Icon( + Icons.payment, + color: primaryColor, ), + onTap: () { + Navigator.of(context) + .push(BottomUpPageRoute(PaymentPage(invoice: _invoice))); + }, ), - Padding( - padding: const EdgeInsets.only(left: 8.0), - child: InkWell( - child: Icon( - Icons.more_vert, - color: primaryColor, - ), - onTap: () { - var act = actionSheet(context); - showCupertinoModalPopup( - context: context, builder: (BuildContext context) => act); - }, + ), + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: InkWell( + child: Icon( + Icons.more_vert, + color: primaryColor, ), + onTap: () { + var act = actionSheet(context); + showCupertinoModalPopup( + context: context, builder: (BuildContext context) => act); + }, ), - ], - ), + ), + ], ), ); } diff --git a/lib/pages/invoice/payment_page.dart b/lib/pages/invoice/payment_page.dart index 5aaff11..105e37a 100644 --- a/lib/pages/invoice/payment_page.dart +++ b/lib/pages/invoice/payment_page.dart @@ -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 { Invoice _invoice = new Invoice(); bool _isLoading = false; List _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 { void initState() { if (widget.invoice != null) { _invoice = widget.invoice; + multiImgController.setImageUrls = _receipts; } super.initState(); } @@ -63,8 +60,6 @@ class _PaymentPageState extends State { @override Widget build(BuildContext context) { - var owner = Provider.of(context).isOwner(); - // var images = isNew ? [] : _images; return LocalProgress( inAsyncCall: _isLoading, @@ -81,6 +76,23 @@ class _PaymentPageState extends State { body: Card( child: Column( children: [ + Padding( + padding: const EdgeInsets.all(15.0), + child: Container( + child: Row( + children: [ + 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 { 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 { title: LocalText(context, 'payment.attachment', color: Colors.black, fontSize: 16), children: [ - Container( - padding: EdgeInsets.only(left: 20), - child: Row(children: [ - LocalText( - context, - "invoice.payment", - color: Colors.grey, - fontSize: 14, + Padding( + padding: EdgeInsets.only(left: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only(top: 8), + child: Text( + '${dateFormatter.format(_invoice.receipts[0].date)} ', + style: TextStyle( + color: Colors.black, fontSize: 16), + ), ), - MultiImageFile( - enabled: true, - controller: multiImgController, - title: "Receipt File", - ) - ])), + Container( + padding: EdgeInsets.only(left: 10), + child: MultiImageFile( + enabled: true, + controller: multiImgController, + title: "Receipt File", + )), + ], + ), + ), SizedBox( height: 25, ), diff --git a/lib/pages/payment_editor.dart b/lib/pages/payment_editor.dart index 11b17f5..43d947a 100644 --- a/lib/pages/payment_editor.dart +++ b/lib/pages/payment_editor.dart @@ -27,6 +27,7 @@ class _PaymentMethodEditorState extends State { 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 { _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 { 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) ], ), ), diff --git a/lib/pages/payment_method_page.dart b/lib/pages/payment_method_page.dart index 6809e0a..876e1b6 100644 --- a/lib/pages/payment_method_page.dart +++ b/lib/pages/payment_method_page.dart @@ -63,13 +63,6 @@ class _PaymentMethodPageState extends State { child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Text( - // 'Account Name: ', - // style: TextStyle( - // color: Colors.black, - // fontWeight: FontWeight.normal, - // fontSize: 15), - // ), Text( method.accountName, style: TextStyle( @@ -80,72 +73,37 @@ class _PaymentMethodPageState extends State { ], ), ), - Padding( - padding: const EdgeInsets.only(left: 8.0, top: 8.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Text( - // 'Account Number: ', - // style: TextStyle( - // color: Colors.black, - // fontWeight: FontWeight.normal, - // fontSize: 15), - // ), - Text( - method.account, - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.normal, - fontSize: 15), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.only(left: 8.0, top: 8.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Text( - // 'Email: ', - // style: TextStyle( - // color: Colors.black, - // fontWeight: FontWeight.normal, - // fontSize: 15), - // ), - Text( - method.mail, - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.normal, - fontSize: 15), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.only(left: 8.0, top: 8.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // 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), - ), - ], - ), - ), + method.account != null + ? Padding( + padding: const EdgeInsets.only(left: 8.0, top: 8.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + method.account, + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.normal, + fontSize: 15), + ), + ], + ), + ) + : Padding( + padding: const EdgeInsets.only(left: 8.0, top: 8.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + method.link, + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.normal, + fontSize: 15), + ), + ], + ), + ) ], ), ), @@ -160,7 +118,7 @@ class _PaymentMethodPageState extends State { ); }, icon: Icon(Icons.add), - label: Text(AppTranslations.of(context).text("discount.new")), + label: Text(AppTranslations.of(context).text("payment.method.new")), backgroundColor: primaryColor, ), ), diff --git a/lib/pages_fcs/package_editor.dart b/lib/pages_fcs/package_editor.dart index 02e85ad..423d6ce 100644 --- a/lib/pages_fcs/package_editor.dart +++ b/lib/pages_fcs/package_editor.dart @@ -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 { "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 { ), ], ), + getShippingAddressList(context), isNew ? Container() : ExpansionTile( @@ -373,7 +384,6 @@ class _PackageEditorState extends State { ), ], ), - getShippingAddressList(context), ], ), ), @@ -432,45 +442,152 @@ class _PackageEditorState extends State { color: primaryColor), ), children: [ + // 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: [ + Row( + children: [ + Expanded( + child: new Padding( + padding: const EdgeInsets.symmetric(vertical: 10.0), + child: Row( + children: [ + new Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + 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 getAddressList( + BuildContext context, List 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 getAddressRows(List addresses) { return addresses.map((s) { return MyDataRow( - onSelectChanged: (selected) { - - }, + onSelectChanged: (selected) {}, cells: [ MyDataCell( new Text( diff --git a/lib/pages_fcs/shipping_address_list.dart b/lib/pages_fcs/shipping_address_list.dart new file mode 100644 index 0000000..4207516 --- /dev/null +++ b/lib/pages_fcs/shipping_address_list.dart @@ -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 { + bool _isLoading = false; + + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + var shipmentModel = Provider.of(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: [ + IconButton( + icon: Icon( + Icons.search, + color: Colors.white, + ), + iconSize: 30, + onPressed: () => showPlacesSearch(context), + ), + ], + ), + body: Column( + children: [ + 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 getAddressList( + BuildContext context, List addresses) { + return addresses.asMap().entries.map((s) { + return InkWell( + onTap: () { + Navigator.pop(context, s.value); + }, + child: ShippingAddressRow(shippingAddress: s.value, index: s.key), + ); + }).toList(); + } +} diff --git a/lib/vo/payment_method.dart b/lib/vo/payment_method.dart index 07252d4..35c4222 100644 --- a/lib/vo/payment_method.dart +++ b/lib/vo/payment_method.dart @@ -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}); }