130 lines
4.3 KiB
Dart
130 lines
4.3 KiB
Dart
import 'package:fcs/domain/entities/package.dart';
|
|
import 'package:fcs/domain/entities/user.dart';
|
|
import 'package:fcs/helpers/theme.dart';
|
|
import 'package:fcs/localization/app_translations.dart';
|
|
import 'package:fcs/pages/invoice/invoice_shipment_list.dart';
|
|
import 'package:fcs/pages/invoice/model/invoice_model.dart';
|
|
import 'package:fcs/pages/package_search/package_serach.dart';
|
|
import 'package:fcs/pages/shipment/shipment_list.dart';
|
|
import 'package:fcs/pages/user_search/user_serach.dart';
|
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
import 'package:fcs/pages/widgets/local_popup_menu_button.dart';
|
|
import 'package:fcs/pages/widgets/local_popupmenu.dart';
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
|
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;
|
|
|
|
const InvoiceList({Key key, this.onlyFcs}) : super(key: key);
|
|
@override
|
|
_InvoiceListState createState() => _InvoiceListState();
|
|
}
|
|
|
|
class _InvoiceListState extends State<InvoiceList> {
|
|
bool _isLoading = false;
|
|
bool _showPaid = false;
|
|
var _controller = ScrollController();
|
|
|
|
@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();
|
|
// }
|
|
// });
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
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")
|
|
],
|
|
popupMenuCallback: (p) => this.setState(() {
|
|
_showPaid = p.id == 2;
|
|
}),
|
|
);
|
|
|
|
return LocalProgress(
|
|
inAsyncCall: _isLoading,
|
|
child: DefaultTabController(
|
|
length: 2,
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
centerTitle: true,
|
|
leading: new IconButton(
|
|
icon: new Icon(CupertinoIcons.back),
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
),
|
|
backgroundColor: primaryColor,
|
|
title: LocalText(context, 'invoices.title',
|
|
color: Colors.white, fontSize: 20),
|
|
actions: <Widget>[
|
|
IconButton(
|
|
icon: Icon(Icons.search, color: Colors.white),
|
|
onPressed: () {}),
|
|
popupMenu
|
|
],
|
|
),
|
|
floatingActionButton: owner
|
|
? FloatingActionButton.extended(
|
|
onPressed: () {
|
|
_newInvoice();
|
|
},
|
|
icon: Icon(Icons.add),
|
|
label:
|
|
LocalText(context, 'invoices.add', color: Colors.white),
|
|
backgroundColor: primaryColor,
|
|
)
|
|
: null,
|
|
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]);
|
|
}),
|
|
),
|
|
],
|
|
)),
|
|
),
|
|
);
|
|
}
|
|
|
|
_newInvoice() {
|
|
Navigator.of(context)
|
|
.push(CupertinoPageRoute(builder: (context) => InvoiceShipmentList()));
|
|
}
|
|
}
|