update invoice
This commit is contained in:
@@ -16,13 +16,12 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'invoice_editor.dart';
|
||||
import 'invoice_list_row.dart';
|
||||
|
||||
class InvoiceList extends StatefulWidget {
|
||||
final bool onlyFcs;
|
||||
final bool forCustomer;
|
||||
|
||||
const InvoiceList({Key key, this.onlyFcs}) : super(key: key);
|
||||
const InvoiceList({Key key, this.forCustomer}) : super(key: key);
|
||||
@override
|
||||
_InvoiceListState createState() => _InvoiceListState();
|
||||
}
|
||||
@@ -35,14 +34,13 @@ class _InvoiceListState extends State<InvoiceList> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Provider.of<InvoiceModel>(context, listen: false).initPaidInvoice(true);
|
||||
// _controller.addListener(() {
|
||||
// if (_showPaid &&
|
||||
// _controller.position.pixels == _controller.position.maxScrollExtent) {
|
||||
// Provider.of<InvoiceModel>(context, listen: false)
|
||||
// .loadMorePaidInvoices();
|
||||
// }
|
||||
// });
|
||||
_controller.addListener(() async {
|
||||
if (_controller.position.pixels == _controller.position.maxScrollExtent) {
|
||||
Provider.of<InvoiceModel>(context, listen: false).loadMore(isCustomer: widget.forCustomer);
|
||||
}
|
||||
});
|
||||
|
||||
Provider.of<InvoiceModel>(context, listen: false).initData(false);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -54,15 +52,17 @@ class _InvoiceListState extends State<InvoiceList> {
|
||||
Widget build(BuildContext context) {
|
||||
var owner = true;
|
||||
var invoiceModel = Provider.of<InvoiceModel>(context);
|
||||
bool onlyFcs = widget.onlyFcs;
|
||||
var invoices =
|
||||
_showPaid ? invoiceModel.paidInvoices : invoiceModel.invoices;
|
||||
|
||||
final popupMenu = LocalPopupMenuButton(
|
||||
popmenus: [
|
||||
LocalPopupMenu(
|
||||
id: 1, textKey: "invoice.popupmenu.pending", selected: true),
|
||||
LocalPopupMenu(id: 2, textKey: "invoice.popupmenu.paid")
|
||||
id: 1,
|
||||
textKey: "invoice.popupmenu.pending",
|
||||
selected: invoiceModel.selectedIndex == 1),
|
||||
LocalPopupMenu(
|
||||
id: 2,
|
||||
textKey: "invoice.popupmenu.paid",
|
||||
selected: invoiceModel.selectedIndex == 2)
|
||||
],
|
||||
popupMenuCallback: (p) => this.setState(() {
|
||||
_showPaid = p.id == 2;
|
||||
@@ -104,18 +104,38 @@ class _InvoiceListState extends State<InvoiceList> {
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new ListView.separated(
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: Colors.black,
|
||||
),
|
||||
scrollDirection: Axis.vertical,
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
shrinkWrap: true,
|
||||
itemCount: invoices.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return InvoiceListRow(invoice: invoices[index]);
|
||||
}),
|
||||
child: RefreshIndicator(
|
||||
child: ListView.separated(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
controller: _controller,
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: Colors.black,
|
||||
),
|
||||
scrollDirection: Axis.vertical,
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
shrinkWrap: true,
|
||||
itemCount: invoiceModel.invoices.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return InvoiceListRow(
|
||||
key: ValueKey(invoiceModel.invoices[index].id),
|
||||
invoice: invoiceModel.invoices[index]);
|
||||
}),
|
||||
onRefresh: () => invoiceModel.refresh(),
|
||||
),
|
||||
),
|
||||
invoiceModel.isLoading
|
||||
? Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
color: primaryColor,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("Loading...",
|
||||
style: TextStyle(color: Colors.white)),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
)),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user