add delivery
This commit is contained in:
@@ -38,7 +38,7 @@ class ShipmentModel extends BaseModel {
|
||||
logout();
|
||||
_menuSelectedIndex = 1;
|
||||
_loadShipments(forCustomer, myPickup);
|
||||
_delivered = _getDeliveredExample(forCustomer);
|
||||
_delivered = _getDelivered(forCustomer);
|
||||
_delivered.load();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class ShipmentModel extends BaseModel {
|
||||
user.hasProcessing()))) throw "No privilege";
|
||||
}
|
||||
var pageQuery = Firestore.instance
|
||||
.collection("/$packages_collection")
|
||||
.collection("/$shipments_collection")
|
||||
.where("is_delivered", isEqualTo: true)
|
||||
.where("is_deleted", isEqualTo: false);
|
||||
if (isCustomer) {
|
||||
@@ -90,35 +90,15 @@ class ShipmentModel extends BaseModel {
|
||||
return paginator;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
Paginator _getDeliveredExample(bool onlyFcs) {
|
||||
count = 1;
|
||||
var pageQuery = Firestore.instance
|
||||
.collection(
|
||||
"/users/8OTfsbVvsUOn1SLxy1OrKk7Y_yNKkVoGalPcIlcHnAY/messages")
|
||||
.orderBy("date", descending: true);
|
||||
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
||||
var m = Message.fromMap(data, id);
|
||||
return Shipment(
|
||||
id: m.id,
|
||||
shipmentNumber: m.message,
|
||||
status: m.senderName,
|
||||
pickupDate: m.date,
|
||||
);
|
||||
});
|
||||
return paginator;
|
||||
}
|
||||
|
||||
Future<void> _loadShipments(bool forCustomer, bool myPickup) async {
|
||||
if (user == null) return;
|
||||
if (!forCustomer && !user.hasShipment()) return;
|
||||
String path = "/$shipments_collection";
|
||||
if (listener != null) listener.cancel();
|
||||
_shipments = [];
|
||||
|
||||
try {
|
||||
var q = Firestore.instance
|
||||
.collection("$path")
|
||||
.collection("$shipments_collection")
|
||||
.where("is_delivered", isEqualTo: false)
|
||||
.where("is_canceled", isEqualTo: false)
|
||||
.where("is_deleted", isEqualTo: false);
|
||||
|
||||
@@ -128,7 +128,7 @@ class _ShipmentListState extends State<ShipmentList> {
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ShipmentListRow(
|
||||
key: ValueKey(shipmentModel.shipments[index].id),
|
||||
pickUp: shipmentModel.shipments[index],
|
||||
shipment: shipmentModel.shipments[index],
|
||||
isCustomer: widget.forCustomer,
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -8,9 +8,9 @@ import '../main/util.dart';
|
||||
import 'shipment_info.dart';
|
||||
|
||||
class ShipmentListRow extends StatelessWidget {
|
||||
final Shipment pickUp;
|
||||
final Shipment shipment;
|
||||
final bool isCustomer;
|
||||
const ShipmentListRow({Key key, this.pickUp, this.isCustomer})
|
||||
const ShipmentListRow({Key key, this.shipment, this.isCustomer})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -19,7 +19,7 @@ class ShipmentListRow extends StatelessWidget {
|
||||
onTap: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => ShipmentInfo(
|
||||
shipment: pickUp,
|
||||
shipment: shipment,
|
||||
isCustomer: isCustomer,
|
||||
)));
|
||||
},
|
||||
@@ -45,21 +45,19 @@ class ShipmentListRow extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
pickUp.shipmentNumber,
|
||||
shipment.shipmentNumber ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, top: 3),
|
||||
child: new Text(
|
||||
pickUp.id == null
|
||||
? ''
|
||||
: "Last ${pickUp.last} days",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
)
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 10.0, top: 3),
|
||||
// child: new Text(
|
||||
// "Last ${shipment.last ?? 0} days",
|
||||
// style: new TextStyle(
|
||||
// fontSize: 15.0, color: Colors.grey),
|
||||
// ),
|
||||
// )
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -71,7 +69,7 @@ class ShipmentListRow extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: getStatus(pickUp.status),
|
||||
child: getStatus(shipment.status ?? ""),
|
||||
),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
||||
|
||||
Reference in New Issue
Block a user