modify package list

This commit is contained in:
PhyoThandar
2020-06-24 16:06:15 +06:30
parent 3c147e0ecd
commit 76235bed4b
17 changed files with 52727 additions and 190 deletions

View File

@@ -1,13 +1,22 @@
import 'dart:async';
import 'dart:io';
import 'package:fcs/model/main_model.dart';
import 'package:fcs/pages/invoice/payment_pdf_screen.dart';
import 'package:fcs/theme/theme.dart';
import 'package:fcs/vo/invoice.dart';
import 'package:fcs/widget/bottom_up_page_route.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.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 'package:provider/provider.dart';
import '../util.dart';
import 'invoice_editor.dart';
import 'payment_page.dart';
class InvoiceListRow extends StatefulWidget {
final Invoice invoice;
@@ -21,6 +30,8 @@ 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
void initState() {
@@ -29,16 +40,47 @@ class _InvoiceListRowState extends State<InvoiceListRow> {
if (widget.invoice != null) {
_invoice = widget.invoice;
}
fromAsset('assets/demo.pdf', 'demo.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 = Provider.of<MainModel>(context).isOwner();
return Container(
padding: EdgeInsets.only(left: 15, right: 15),
child: InkWell(
onTap: () {
Navigator.of(context)
.push(BottomUpPageRoute(InvoiceEditor(invoice: _invoice)));
owner
? Navigator.of(context)
.push(BottomUpPageRoute(InvoiceEditor(invoice: _invoice)))
: Navigator.of(context).push(BottomUpPageRoute(PaymentPDFScreen(
path: pdfPath,
)));
},
child: Row(
children: <Widget>[
@@ -88,9 +130,49 @@ class _InvoiceListRowState extends State<InvoiceListRow> {
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);
},
),
),
],
),
),
);
}
actionSheet(BuildContext context) {
return CupertinoActionSheet(
actions: <Widget>[
CupertinoActionSheetAction(
child: Text("Download"),
onPressed: () {
Navigator.pop(context);
},
)
],
);
}
}