add shipments
This commit is contained in:
@@ -25,10 +25,12 @@ class ShipmentList extends StatefulWidget {
|
||||
class _ShipmentListState extends State<ShipmentList> {
|
||||
bool _isLoading = false;
|
||||
var _controller = ScrollController();
|
||||
bool _forCustomer = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_forCustomer = widget.forCustomer;
|
||||
_controller.addListener(() async {
|
||||
if (_controller.position.pixels == _controller.position.maxScrollExtent) {
|
||||
Provider.of<ShipmentModel>(context, listen: false)
|
||||
@@ -36,7 +38,8 @@ class _ShipmentListState extends State<ShipmentList> {
|
||||
}
|
||||
});
|
||||
|
||||
Provider.of<ShipmentModel>(context, listen: false).initData(false);
|
||||
Provider.of<ShipmentModel>(context, listen: false)
|
||||
.initData(widget.forCustomer);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -48,13 +51,27 @@ class _ShipmentListState extends State<ShipmentList> {
|
||||
Widget build(BuildContext context) {
|
||||
ShipmentModel shipmentModel = Provider.of<ShipmentModel>(context);
|
||||
final popupMenu = LocalPopupMenuButton(
|
||||
popmenus: [
|
||||
LocalPopupMenu(
|
||||
id: 1, textKey: "shipment.popupmenu.active", selected: true),
|
||||
LocalPopupMenu(id: 2, textKey: "shipment.popupmenu.delivered")
|
||||
],
|
||||
popmenus: _forCustomer
|
||||
? [
|
||||
LocalPopupMenu(
|
||||
id: 1, textKey: "shipment.popupmenu.active", selected: true),
|
||||
LocalPopupMenu(id: 2, textKey: "shipment.popupmenu.delivered"),
|
||||
]
|
||||
: [
|
||||
LocalPopupMenu(
|
||||
id: 1, textKey: "shipment.popupmenu.active", selected: true),
|
||||
LocalPopupMenu(id: 2, textKey: "shipment.popupmenu.delivered"),
|
||||
LocalPopupMenu(id: 3, textKey: "shipment.popupmenu.mypickup"),
|
||||
],
|
||||
popupMenuCallback: (p) => this.setState(() {
|
||||
shipmentModel.menuSelectedIndex = p.id;
|
||||
if (p.id == 3) {
|
||||
Provider.of<ShipmentModel>(context, listen: false)
|
||||
.initData(widget.forCustomer, myPickup: true);
|
||||
} else if (p.id == 1) {
|
||||
Provider.of<ShipmentModel>(context, listen: false)
|
||||
.initData(widget.forCustomer);
|
||||
}
|
||||
}),
|
||||
);
|
||||
return LocalProgress(
|
||||
@@ -72,18 +89,20 @@ class _ShipmentListState extends State<ShipmentList> {
|
||||
title: LocalText(context, "shipment",
|
||||
fontSize: 18, color: Colors.white),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.search,
|
||||
color: Colors.white,
|
||||
),
|
||||
iconSize: 30,
|
||||
// onPressed: () => showPlacesSearch(context),
|
||||
),
|
||||
widget.forCustomer
|
||||
? Container()
|
||||
: IconButton(
|
||||
icon: Icon(
|
||||
Icons.search,
|
||||
color: Colors.white,
|
||||
),
|
||||
iconSize: 30,
|
||||
// onPressed: () => showPlacesSearch(context),
|
||||
),
|
||||
popupMenu
|
||||
],
|
||||
),
|
||||
floatingActionButton: shipmentModel.menuSelectedIndex == 1
|
||||
floatingActionButton: widget.forCustomer
|
||||
? FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
_newPickup();
|
||||
@@ -108,8 +127,10 @@ class _ShipmentListState extends State<ShipmentList> {
|
||||
itemCount: shipmentModel.shipments.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ShipmentListRow(
|
||||
key: ValueKey(shipmentModel.shipments[index].id),
|
||||
pickUp: shipmentModel.shipments[index]);
|
||||
key: ValueKey(shipmentModel.shipments[index].id),
|
||||
pickUp: shipmentModel.shipments[index],
|
||||
isCustomer: widget.forCustomer,
|
||||
);
|
||||
}),
|
||||
onRefresh: () =>
|
||||
shipmentModel.refresh(isCustomer: widget.forCustomer),
|
||||
|
||||
Reference in New Issue
Block a user