2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/helpers/theme.dart';
|
2020-10-14 20:56:46 +06:30
|
|
|
import 'package:fcs/pages/invoice/invoice_shipment_list.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/invoice/model/invoice_model.dart';
|
2024-01-26 16:56:20 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
2020-10-15 15:49:02 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_popup_menu_button.dart';
|
2024-02-07 17:26:29 +06:30
|
|
|
import 'package:fcs/domain/vo/local_popupmenu.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-10-12 03:34:05 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-10-19 05:13:49 +06:30
|
|
|
import 'package:flutter/material.dart';
|
2020-06-02 14:56:51 +06:30
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
2024-01-26 16:56:20 +06:30
|
|
|
import '../../domain/entities/invoice.dart';
|
|
|
|
|
import '../../pagination/paginator_listview.dart';
|
2020-06-02 14:56:51 +06:30
|
|
|
import 'invoice_list_row.dart';
|
|
|
|
|
|
|
|
|
|
class InvoiceList extends StatefulWidget {
|
2024-01-26 16:56:20 +06:30
|
|
|
final bool forCustomer;
|
2020-10-16 13:46:02 +06:30
|
|
|
|
2024-01-26 16:56:20 +06:30
|
|
|
const InvoiceList({Key? key, required this.forCustomer}) : super(key: key);
|
2020-06-02 14:56:51 +06:30
|
|
|
@override
|
|
|
|
|
_InvoiceListState createState() => _InvoiceListState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _InvoiceListState extends State<InvoiceList> {
|
|
|
|
|
bool _isLoading = false;
|
2024-01-26 16:56:20 +06:30
|
|
|
int _selectedIndex = 1;
|
2020-06-02 14:56:51 +06:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
2024-01-26 16:56:20 +06:30
|
|
|
_init();
|
2020-06-02 14:56:51 +06:30
|
|
|
}
|
|
|
|
|
|
2024-01-26 16:56:20 +06:30
|
|
|
_init() {
|
|
|
|
|
var model = context.read<InvoiceModel>();
|
|
|
|
|
_selectedIndex = model.selectedIndex;
|
|
|
|
|
model.loadPaginationInvoices(_selectedIndex, widget.forCustomer);
|
|
|
|
|
if (mounted) {
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
2020-06-02 14:56:51 +06:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2020-10-09 19:00:39 +06:30
|
|
|
var invoiceModel = Provider.of<InvoiceModel>(context);
|
2020-07-02 16:16:21 +06:30
|
|
|
|
2020-10-15 15:49:02 +06:30
|
|
|
final popupMenu = LocalPopupMenuButton(
|
2024-01-26 16:56:20 +06:30
|
|
|
popmenus: [
|
|
|
|
|
LocalPopupMenu(
|
|
|
|
|
id: 1,
|
|
|
|
|
textKey: "invoice.popupmenu.issused",
|
|
|
|
|
selected: invoiceModel.selectedIndex == 1),
|
|
|
|
|
LocalPopupMenu(
|
|
|
|
|
id: 2,
|
|
|
|
|
textKey: "invoice.popupmenu.paid",
|
|
|
|
|
selected: invoiceModel.selectedIndex == 2),
|
|
|
|
|
LocalPopupMenu(
|
|
|
|
|
id: 3,
|
|
|
|
|
textKey: "invoice.popupmenu.cancel",
|
|
|
|
|
selected: invoiceModel.selectedIndex == 3)
|
|
|
|
|
],
|
|
|
|
|
popupMenuCallback: (p) {
|
|
|
|
|
this.setState(() {
|
|
|
|
|
_selectedIndex = p.id;
|
|
|
|
|
});
|
|
|
|
|
context
|
|
|
|
|
.read<InvoiceModel>()
|
|
|
|
|
.onChanged(_selectedIndex, widget.forCustomer);
|
|
|
|
|
});
|
2020-10-15 15:49:02 +06:30
|
|
|
|
2020-06-02 14:56:51 +06:30
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
2024-01-26 16:56:20 +06:30
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: LocalAppBar(
|
|
|
|
|
labelKey: 'invoices.title', actions: <Widget>[popupMenu]),
|
|
|
|
|
floatingActionButton: (widget.forCustomer)
|
|
|
|
|
? null
|
|
|
|
|
: FloatingActionButton.extended(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
_newInvoice();
|
|
|
|
|
},
|
|
|
|
|
icon: Icon(Icons.add),
|
|
|
|
|
label:
|
|
|
|
|
LocalText(context, 'invoices.add', color: Colors.white),
|
|
|
|
|
backgroundColor: primaryColor,
|
2020-10-09 19:00:39 +06:30
|
|
|
),
|
2024-01-26 16:56:20 +06:30
|
|
|
body: PaginatorListView<Invoice>(
|
|
|
|
|
paginatorListener: invoiceModel.getInvoices!,
|
|
|
|
|
rowBuilder: (p) =>
|
|
|
|
|
InvoiceListRow(invoice: p, isCustomer: widget.forCustomer),
|
|
|
|
|
color: primaryColor)),
|
2020-06-02 14:56:51 +06:30
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-26 04:41:24 +06:30
|
|
|
_newInvoice() async {
|
2020-10-14 13:54:42 +06:30
|
|
|
Navigator.of(context)
|
2020-10-14 20:56:46 +06:30
|
|
|
.push(CupertinoPageRoute(builder: (context) => InvoiceShipmentList()));
|
2020-06-02 14:56:51 +06:30
|
|
|
}
|
|
|
|
|
}
|