173 lines
5.9 KiB
Dart
173 lines
5.9 KiB
Dart
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? forCustomer;
|
|
InvoiceListRow({Key? key, this.invoice, this.forCustomer}) : 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: <Widget>[
|
|
Expanded(
|
|
child: new Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
|
child: new Row(
|
|
children: <Widget>[
|
|
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: <Widget>[
|
|
new Text(
|
|
invoice!.invoiceNumber ?? "",
|
|
style: new TextStyle(
|
|
fontSize: 15.0, color: Colors.black),
|
|
),
|
|
new Text(
|
|
invoice!.status ?? "",
|
|
style: new TextStyle(
|
|
fontSize: 13.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: RaisedButton(
|
|
child: Row(
|
|
children: <Widget>[
|
|
Icon(
|
|
Icons.payment,
|
|
color: primaryColor,
|
|
),
|
|
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: forCustomer,
|
|
)));
|
|
},
|
|
)),
|
|
)
|
|
: 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: <Widget>[
|
|
CupertinoActionSheetAction(
|
|
child: Row(
|
|
children: <Widget>[
|
|
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: forCustomer)));
|
|
},
|
|
),
|
|
CupertinoActionSheetAction(
|
|
child: Row(
|
|
children: <Widget>[
|
|
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: forCustomer,
|
|
)));
|
|
},
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|