add payment
This commit is contained in:
@@ -1,137 +1,75 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
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:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'payment_page.dart';
|
||||
import 'payment_pdf_screen.dart';
|
||||
import 'payment/payment_page.dart';
|
||||
import '../widgets/pdf_screen.dart';
|
||||
|
||||
class InvoiceListRow extends StatefulWidget {
|
||||
class InvoiceListRow extends StatelessWidget {
|
||||
final dateFormatter = new DateFormat('dd MMM yyyy');
|
||||
final Invoice invoice;
|
||||
InvoiceListRow({Key key, this.invoice}) : super(key: key);
|
||||
|
||||
@override
|
||||
_InvoiceListRowState createState() => _InvoiceListRowState();
|
||||
}
|
||||
|
||||
class _InvoiceListRowState extends State<InvoiceListRow> {
|
||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||
final double dotSize = 15.0;
|
||||
Invoice _invoice = new Invoice();
|
||||
String pdfPath = '';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
if (widget.invoice != null) {
|
||||
_invoice = widget.invoice;
|
||||
}
|
||||
|
||||
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 {
|
||||
// To open from assets, you can copy them to the app storage folder, and the access them "locally"
|
||||
Completer<File> completer = Completer();
|
||||
print('asset => $asset');
|
||||
print('assest => ${await rootBundle.load(asset)}');
|
||||
try {
|
||||
var dir = await getApplicationDocumentsDirectory();
|
||||
File file = File("${dir.path}/$filename");
|
||||
var data = await rootBundle.load(asset);
|
||||
print('data => $data');
|
||||
var bytes = data.buffer.asUint8List();
|
||||
await file.writeAsBytes(bytes, flush: true);
|
||||
completer.complete(file);
|
||||
} catch (e) {
|
||||
throw Exception('Error parsing asset file! ===> ' + e.toString());
|
||||
}
|
||||
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var owner = true;
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left: 15, right: 15),
|
||||
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: InkWell(
|
||||
onTap: () {
|
||||
owner
|
||||
? Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => PaymentPDFScreen(
|
||||
url: _invoice.invoiceURL,
|
||||
)))
|
||||
: Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => PaymentPDFScreen(
|
||||
url: _invoice.invoiceURL,
|
||||
)));
|
||||
},
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 5, right: 10),
|
||||
child: Icon(
|
||||
FontAwesomeIcons.fileInvoice,
|
||||
color: primaryColor,
|
||||
size: 30,
|
||||
),
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 5, right: 10),
|
||||
child: Icon(
|
||||
FontAwesomeIcons.fileInvoice,
|
||||
color: primaryColor,
|
||||
size: 30,
|
||||
),
|
||||
new Expanded(
|
||||
),
|
||||
new Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 0),
|
||||
child: new Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
_invoice.invoiceNumber == null
|
||||
? ''
|
||||
: _invoice.invoiceNumber,
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
new Text(
|
||||
invoice.invoiceNumber ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||
child: new Text(
|
||||
dateFormatter.format(_invoice.invoiceDate),
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
new Text(
|
||||
invoice.status ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 13.0, color: primaryColor),
|
||||
),
|
||||
new Text(
|
||||
dateFormatter.format(invoice.invoiceDate),
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(0),
|
||||
// child: getStatus(_invoice.status),
|
||||
// ),
|
||||
_invoice.status == invoice_issued_status
|
||||
invoice.status == invoice_issued_status
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0),
|
||||
child: InkWell(
|
||||
@@ -143,27 +81,29 @@ class _InvoiceListRowState extends State<InvoiceListRow> {
|
||||
color: primaryColor,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Text("Payment"),
|
||||
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)));
|
||||
builder: (context) => PaymentPage(invoice: invoice)));
|
||||
},
|
||||
)),
|
||||
)
|
||||
: Container(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: InkWell(
|
||||
child: Icon(
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
Icons.more_vert,
|
||||
color: primaryColor,
|
||||
),
|
||||
onTap: () {
|
||||
onPressed: () {
|
||||
var act = actionSheet(context);
|
||||
showCupertinoModalPopup(
|
||||
context: context, builder: (BuildContext context) => act);
|
||||
@@ -194,7 +134,7 @@ class _InvoiceListRowState extends State<InvoiceListRow> {
|
||||
//to go invoice info page
|
||||
Navigator.pop(context);
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => InvoiceInfo(invoice: _invoice)));
|
||||
builder: (context) => InvoiceInfo(invoice: invoice)));
|
||||
},
|
||||
)
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user