modify package list
This commit is contained in:
112
lib/pages/barcode_screen_page.dart
Normal file
112
lib/pages/barcode_screen_page.dart
Normal file
@@ -0,0 +1,112 @@
|
||||
import 'package:barcode_scan/barcode_scan.dart';
|
||||
import 'package:barcode_scan/model/scan_result.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:fcs/model/product_model.dart';
|
||||
import 'package:fcs/theme/theme.dart';
|
||||
import 'package:fcs/vo/buyer.dart';
|
||||
import 'package:fcs/vo/product.dart';
|
||||
import 'package:fcs/widget/progress.dart';
|
||||
|
||||
class BarcodeScreenPage extends StatefulWidget {
|
||||
final BuyerProduct buyerProduct;
|
||||
const BarcodeScreenPage({Key key, this.buyerProduct}) : super(key: key);
|
||||
@override
|
||||
_BarcodeScreenPageState createState() => _BarcodeScreenPageState();
|
||||
}
|
||||
|
||||
class _BarcodeScreenPageState extends State<BarcodeScreenPage> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
bool _isLoading = false;
|
||||
ScanResult scanResult;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Widget showProducts(BuildContext context, ProductModel productModel) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
FontAwesomeIcons.tag,
|
||||
color: primaryColor,
|
||||
size: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
new Flexible(
|
||||
child: Container(
|
||||
width: 170.0,
|
||||
child: DropdownButton<String>(
|
||||
// value: currentProductID,
|
||||
isExpanded: true,
|
||||
hint: Text(
|
||||
'Select Product',
|
||||
style: labelStyle,
|
||||
),
|
||||
onChanged: changedProduct,
|
||||
items: productModel.products
|
||||
.map<DropdownMenuItem<String>>((Product product) {
|
||||
return new DropdownMenuItem<String>(
|
||||
value: product.id,
|
||||
child: new Text(product.name, style: textStyle),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void changedProduct(selected) {
|
||||
setState(() {
|
||||
// currentProductID = selected;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: primaryColor,
|
||||
title: Text("Bar Code Scranner"),
|
||||
),
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
child: Icon(Icons.scanner),
|
||||
onPressed: () async {
|
||||
await scan();
|
||||
},
|
||||
)
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Future scan() async {
|
||||
var result = await BarcodeScanner.scan();
|
||||
print("ScanResult => $result");
|
||||
setState(() => scanResult = result);
|
||||
}
|
||||
|
||||
// _save() {
|
||||
// if (currentProductID == null) return;
|
||||
// this.buyerProduct.productID = currentProductID;
|
||||
// var productName =
|
||||
// Provider.of<ProductModel>(context).getProductName(currentProductID);
|
||||
// this.buyerProduct.productName = productName;
|
||||
// this.buyerProduct.storageCapacityQty = int.parse(_storage.text);
|
||||
// this.buyerProduct.dailySaleQty = int.parse(_sales.text);
|
||||
// Navigator.pop<BuyerProduct>(context, this.buyerProduct);
|
||||
// }
|
||||
}
|
||||
@@ -249,7 +249,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text('Box Information'),
|
||||
title: Text('Package Information'),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: SingleChildScrollView(
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
202
lib/pages/invoice/payment_page.dart
Normal file
202
lib/pages/invoice/payment_page.dart
Normal file
@@ -0,0 +1,202 @@
|
||||
import 'package:fcs/model/main_model.dart';
|
||||
import 'package:fcs/pages/util.dart';
|
||||
import 'package:fcs/theme/theme.dart';
|
||||
import 'package:fcs/vo/invoice.dart';
|
||||
import 'package:fcs/vo/package.dart';
|
||||
import 'package:fcs/widget/local_text.dart';
|
||||
import 'package:fcs/widget/localization/app_translations.dart';
|
||||
import 'package:fcs/widget/multi_img_controller.dart';
|
||||
import 'package:fcs/widget/multi_img_file.dart';
|
||||
import 'package:fcs/widget/my_data_table.dart';
|
||||
import 'package:fcs/widget/number_cell.dart';
|
||||
import 'package:fcs/widget/progress.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
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;
|
||||
PaymentPage({this.invoice});
|
||||
|
||||
@override
|
||||
_PaymentPageState createState() => _PaymentPageState();
|
||||
}
|
||||
|
||||
class _PaymentPageState extends State<PaymentPage> {
|
||||
TextEditingController _addressEditingController = new TextEditingController();
|
||||
TextEditingController _fromTimeEditingController =
|
||||
new TextEditingController();
|
||||
TextEditingController _toTimeEditingController = new TextEditingController();
|
||||
TextEditingController _noOfPackageEditingController =
|
||||
new TextEditingController();
|
||||
TextEditingController _weightEditingController = new TextEditingController();
|
||||
MultiImgController multiImgController = MultiImgController();
|
||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||
|
||||
Invoice _invoice = new Invoice();
|
||||
bool _isLoading = false;
|
||||
List<String> _receipts = [
|
||||
"assets/photos/1.jpg",
|
||||
"assets/photos/2.jpg",
|
||||
"assets/photos/3.jpg"
|
||||
];
|
||||
bool isNew;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (widget.invoice != null) {
|
||||
_invoice = widget.invoice;
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var owner = Provider.of<MainModel>(context).isOwner();
|
||||
|
||||
// var images = isNew ? [] : _images;
|
||||
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("payment.title")),
|
||||
),
|
||||
body: Card(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Container(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Remaining Balance : ',
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
Text(
|
||||
'${_invoice.amount}',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold),
|
||||
)
|
||||
],
|
||||
)),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
ExpansionTile(
|
||||
title: Text('Payment Attachment'),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 20),
|
||||
child: Row(children: <Widget>[
|
||||
LocalText(
|
||||
context,
|
||||
"invoice.payment",
|
||||
color: Colors.grey,
|
||||
fontSize: 14,
|
||||
),
|
||||
MultiImageFile(
|
||||
enabled: true,
|
||||
controller: multiImgController,
|
||||
title: "Receipt File",
|
||||
)
|
||||
])),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text('Receipt'),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columnSpacing: 20,
|
||||
columns: [
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"payment.date",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"payment.amount",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
rows: getPackageRow(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
owner
|
||||
? Container(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: FloatingActionButton.extended(
|
||||
icon: Icon(Icons.add),
|
||||
label: Text(AppTranslations.of(context)
|
||||
.text("invoice.add_box")),
|
||||
backgroundColor: primaryColor,
|
||||
onPressed: () {
|
||||
// Navigator.of(context)
|
||||
// .push(BottomUpPageRoute(PackageAddition()));
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
SizedBox(height: 25),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<MyDataRow> getPackageRow(BuildContext context) {
|
||||
return _invoice.receipts.map((r) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (bool selected) {},
|
||||
cells: [
|
||||
MyDataCell(
|
||||
new Text(dateFormatter.format(r.date), style: textStyle),
|
||||
),
|
||||
MyDataCell(NumberCell(r.amount))
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
113
lib/pages/invoice/payment_pdf_screen.dart
Normal file
113
lib/pages/invoice/payment_pdf_screen.dart
Normal file
@@ -0,0 +1,113 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fcs/theme/theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pdfview/flutter_pdfview.dart';
|
||||
|
||||
class PaymentPDFScreen extends StatefulWidget {
|
||||
final String path;
|
||||
|
||||
PaymentPDFScreen({Key key, this.path}) : super(key: key);
|
||||
|
||||
_PaymentPDFScreenState createState() => _PaymentPDFScreenState();
|
||||
}
|
||||
|
||||
class _PaymentPDFScreenState extends State<PaymentPDFScreen>
|
||||
with WidgetsBindingObserver {
|
||||
final Completer<PDFViewController> _controller =
|
||||
Completer<PDFViewController>();
|
||||
int pages = 0;
|
||||
int currentPage = 0;
|
||||
bool isReady = false;
|
||||
String errorMessage = '';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print(' widget.path => ${widget.path}');
|
||||
print(' pages => ${pages}');
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: primaryColor,
|
||||
title: Text("Document"),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.share),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Stack(
|
||||
children: <Widget>[
|
||||
PDFView(
|
||||
filePath: widget.path,
|
||||
enableSwipe: true,
|
||||
swipeHorizontal: true,
|
||||
autoSpacing: false,
|
||||
pageFling: true,
|
||||
pageSnap: true,
|
||||
defaultPage: currentPage,
|
||||
fitPolicy: FitPolicy.BOTH,
|
||||
preventLinkNavigation:
|
||||
false, // if set to true the link is handled in flutter
|
||||
onRender: (_pages) {
|
||||
print(('pages => $pages'));
|
||||
setState(() {
|
||||
pages = _pages;
|
||||
isReady = true;
|
||||
});
|
||||
},
|
||||
// onError: (error) {
|
||||
// setState(() {
|
||||
// errorMessage = error.toString();
|
||||
// });
|
||||
// print(error.toString());
|
||||
// },
|
||||
// onPageError: (page, error) {
|
||||
// setState(() {
|
||||
// errorMessage = '$page: ${error.toString()}';
|
||||
// });
|
||||
// print('$page: ${error.toString()}');
|
||||
// },
|
||||
onViewCreated: (PDFViewController pdfViewController) {
|
||||
_controller.complete(pdfViewController);
|
||||
},
|
||||
onLinkHandler: (String uri) {
|
||||
print('goto uri: $uri');
|
||||
},
|
||||
onPageChanged: (int page, int total) {
|
||||
print('page change: $page/$total');
|
||||
setState(() {
|
||||
currentPage = page;
|
||||
});
|
||||
},
|
||||
),
|
||||
// errorMessage.isEmpty
|
||||
// ? !isReady
|
||||
// ? Center(
|
||||
// child: CircularProgressIndicator(),
|
||||
// )
|
||||
// : Container()
|
||||
// : Center(
|
||||
// child: Text(errorMessage),
|
||||
// )
|
||||
],
|
||||
),
|
||||
floatingActionButton: FutureBuilder<PDFViewController>(
|
||||
future: _controller.future,
|
||||
builder: (context, AsyncSnapshot<PDFViewController> snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return FloatingActionButton.extended(
|
||||
label: Text("Go to ${pages ~/ 2}"),
|
||||
onPressed: () async {
|
||||
await snapshot.data.setPage(pages ~/ 2);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user