import 'package:fcs/domain/constants.dart'; import 'package:fcs/domain/entities/invoice.dart'; import 'package:fcs/helpers/theme.dart'; import 'package:fcs/pages/invoice/invoice_info.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:intl/intl.dart'; import 'payment/payment_page.dart'; import '../widgets/pdf_screen.dart'; class InvoiceListRow extends StatelessWidget { final dateFormatter = new DateFormat('dd MMM yyyy'); final Invoice? invoice; final bool isCustomer; InvoiceListRow({Key? key, this.invoice, required this.isCustomer}) : super(key: key); @override Widget build(BuildContext context) { return InkWell( onTap: () { Navigator.of(context).push(CupertinoPageRoute( builder: (context) => PDFScreen( title: invoice!.invoiceNumber, url: invoice!.invoiceURL))); }, child: Row( children: [ Expanded( child: new Padding( padding: const EdgeInsets.symmetric(vertical: 10.0), child: new Row( children: [ Container( padding: EdgeInsets.only(left: 5, right: 10), child: Icon( FontAwesomeIcons.fileInvoice, color: primaryColor, size: 30, ), ), new Expanded( child: Padding( padding: const EdgeInsets.only(left: 0), child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ new Text( invoice!.invoiceNumber ?? "", style: new TextStyle( fontSize: 15.0, color: Colors.black), ), new Text( invoice!.status ?? "", style: new TextStyle( fontSize: 15.0, color: primaryColor), ), new Text( invoice!.invoiceDate != null ? dateFormatter.format(invoice!.invoiceDate!) : '', style: new TextStyle( fontSize: 15.0, color: Colors.grey), ) ], ), ), ), ], ), ), ), invoice!.status == invoice_issued_status ? Padding( padding: const EdgeInsets.only(left: 10.0), child: InkWell( child: ElevatedButton.icon( style: ElevatedButton.styleFrom( // shape: RoundedRectangleBorder( // borderRadius: BorderRadius.all(Radius.circular(5))), elevation: 0, backgroundColor: Colors.grey.shade300), icon: Icon( Icons.payment, color: primaryColor, ), label: Padding( padding: const EdgeInsets.only(left: 3.0), child: Text("Payment", style: TextStyle(fontSize: 12, color: Colors.black))), onPressed: () { Navigator.of(context).push(CupertinoPageRoute( builder: (context) => PaymentPage( invoice: invoice, forCustomer: isCustomer))); }, )), ) : Container(), Padding( padding: const EdgeInsets.only(left: 8.0), child: IconButton( icon: Icon( Icons.more_vert, color: primaryColor, ), onPressed: () { var act = actionSheet(context); showCupertinoModalPopup( context: context, builder: (BuildContext context) => act); }, ), ), ], ), ); } actionSheet(BuildContext context) { return CupertinoActionSheet( actions: [ CupertinoActionSheetAction( child: Row( children: [ Padding( padding: const EdgeInsets.only(left: 8.0), child: Text( 'See detail', style: TextStyle(fontSize: 16, color: Colors.black), ), ), ], ), onPressed: () async { //to go invoice info page Navigator.pop(context); Navigator.of(context).push(CupertinoPageRoute( builder: (context) => InvoiceInfo(invoice: invoice, forCustomer: isCustomer))); }, ), CupertinoActionSheetAction( child: Row( children: [ Padding( padding: const EdgeInsets.only(left: 8.0), child: Text( 'Payments', style: TextStyle(fontSize: 16, color: Colors.black), ), ), ], ), onPressed: () async { //to go invoice info page Navigator.pop(context); Navigator.of(context).push(CupertinoPageRoute( builder: (context) => PaymentPage( invoice: invoice, forCustomer: isCustomer, ))); }, ) ], ); } }