import 'package:fcs/helpers/theme.dart'; import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart'; import 'package:fcs/pages/widgets/local_app_bar.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:fcs/pagination/paginator_listview.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../domain/entities/fcs_shipment.dart'; import 'fcs_shipment_editor.dart'; import 'fcs_shipment_list_row.dart'; class FcsShipmentList extends StatefulWidget { @override _FcsShipmentListState createState() => _FcsShipmentListState(); } class _FcsShipmentListState extends State { bool _isLoading = false; int _selectedIndex = 1; @override void initState() { super.initState(); _init(); } _init() { var model = context.read(); _selectedIndex = model.selectedIndex; model.loadFcsShipments(_selectedIndex); if (mounted) { setState(() {}); } } @override Widget build(BuildContext context) { var shipmentModel = Provider.of(context); final popupMenu = LocalPopupMenuButton( popmenus: [ LocalPopupMenu( id: 0, text: "All", selected: shipmentModel.selectedIndex == 0), LocalPopupMenu( id: 1, text: "Pending", selected: shipmentModel.selectedIndex == 1), LocalPopupMenu( id: 2, text: "Processing", selected: shipmentModel.selectedIndex == 2), LocalPopupMenu( id: 3, text: "Shipped", selected: shipmentModel.selectedIndex == 3), LocalPopupMenu( id: 4, text: "Arrived", selected: shipmentModel.selectedIndex == 4), LocalPopupMenu( id: 5, text: "Invoiced", selected: shipmentModel.selectedIndex == 5) ], popupMenuCallback: (p) { setState(() { _selectedIndex = p.id; }); context.read().onChanged(_selectedIndex); }, ); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: LocalAppBar( labelKey: "FCSshipment.list.title", actions: [popupMenu]), floatingActionButton: FloatingActionButton.extended( onPressed: () { _newShipment(); }, icon: Icon(Icons.add), label: LocalText(context, "FCSshipment.add", color: Colors.white), backgroundColor: primaryColor), body: PaginatorListView( paginatorListener: shipmentModel.fcsShipments!, rowBuilder: (p) => FcsShipmentListRow(shipment: p), color: primaryColor))); } _newShipment() { Navigator.of(context) .push(CupertinoPageRoute(builder: (context) => FcsShipmentEditor())); } }