Files
fcs/lib/pages/shipment/model/shipment_model.dart

381 lines
11 KiB
Dart
Raw Normal View History

2020-05-29 15:54:26 +06:30
import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/pickup.dart';
import 'package:fcs/domain/vo/radio.dart';
import 'package:fcs/pages/main/model/base_model.dart';
2020-05-29 15:54:26 +06:30
import 'package:logging/logging.dart';
2020-10-07 14:42:07 +06:30
class ShipmentModel extends BaseModel {
final log = Logger('ShipmentModel');
2020-05-29 15:54:26 +06:30
StreamSubscription<QuerySnapshot> listener;
2020-07-02 16:16:21 +06:30
List<RadioGroup> radioGroups1 = [
2020-06-30 16:27:56 +06:30
RadioGroup(
text: "FCS Pickup",
index: 1,
),
RadioGroup(
text: "Courier Pickup",
index: 2,
),
RadioGroup(
text: "FCS Drop-off",
index: 3,
),
RadioGroup(
text: "Courier Drop-off",
index: 4,
),
];
2020-07-02 16:16:21 +06:30
List<RadioGroup> get radioGroups {
List<RadioGroup> radioGroups = [
RadioGroup(
text: "Local Pickup",
index: 1,
),
RadioGroup(
text: "Courier Pickup",
index: 2,
),
RadioGroup(
text: "Local Drop-off",
index: 3,
),
RadioGroup(
text: "Courier Drop-off",
index: 4,
),
];
return radioGroups;
}
2020-10-07 14:42:07 +06:30
List<Shipment> get pickups {
List<Shipment> pickups = [
Shipment(
2020-10-07 02:33:06 +06:30
id: "S200412 - 12 Apr 2020",
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: 'Pending',
date: DateTime(2020, 5, 1),
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
isCourier: true,
radioIndex: 2,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-10-07 02:33:06 +06:30
id: "S200125 - 12 May 2020",
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: 'Confirmed',
date: DateTime(2020, 5, 6),
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-10-07 02:33:06 +06:30
id: "S200441 - 13 Apr 2020",
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: "Pickuped",
date: DateTime(2020, 5, 9),
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
radioIndex: 3,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-10-07 02:33:06 +06:30
id: "S200412 - 12 Apr 2020",
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: 'Pickuped',
date: DateTime(2020, 5, 15),
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-10-07 02:33:06 +06:30
id: "S200125 - 12 May 2020",
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: 'Pickuped',
date: DateTime(2020, 5, 20),
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-10-07 02:33:06 +06:30
id: "S200441 - 13 Apr 2020",
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: "Pickuped",
date: DateTime(2020, 5, 21),
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-10-07 02:33:06 +06:30
id: "S200441 - 10 Apr 2020",
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: "Canceled",
date: DateTime(2020, 5, 25),
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-10-07 02:33:06 +06:30
id: "S200441 - 6 Apr 2020",
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: "Canceled",
date: DateTime(2020, 5, 27),
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
];
return pickups;
2020-07-02 16:16:21 +06:30
}
2020-10-07 14:42:07 +06:30
List<Shipment> pickups1 = [
Shipment(
2020-07-02 16:16:21 +06:30
id: "S200412 - 12 Apr 2020",
2020-05-29 15:54:26 +06:30
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
2020-05-31 15:00:11 +06:30
status: 'Pending',
date: DateTime(2020, 5, 1),
2020-06-24 16:06:40 +06:30
address: '154-19 64th Ave.\nFlushing, NY 11367',
2020-07-02 16:16:21 +06:30
handlingFee: 50,
2020-06-30 16:27:56 +06:30
isCourier: true,
2020-07-01 08:12:59 +06:30
radioIndex: 2,
2020-06-25 16:19:23 +06:30
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-07-02 16:16:21 +06:30
id: "S200125 - 12 May 2020",
2020-05-29 15:54:26 +06:30
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
2020-06-26 16:17:40 +06:30
status: 'Confirmed',
2020-05-31 15:00:11 +06:30
date: DateTime(2020, 5, 6),
2020-06-24 16:06:40 +06:30
address: '154-19 64th Ave.\nFlushing, NY 11367',
2020-07-02 16:16:21 +06:30
handlingFee: 50,
2020-06-25 16:19:23 +06:30
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-07-02 16:16:21 +06:30
id: "S200441 - 13 Apr 2020",
2020-05-29 15:54:26 +06:30
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
2020-05-31 15:00:11 +06:30
status: "Pickuped",
date: DateTime(2020, 5, 9),
2020-06-24 16:06:40 +06:30
address: '154-19 64th Ave.\nFlushing, NY 11367',
2020-07-02 16:16:21 +06:30
handlingFee: 50,
2020-07-01 08:12:59 +06:30
radioIndex: 3,
2020-06-25 16:19:23 +06:30
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-07-02 16:16:21 +06:30
id: "S200412 - 12 Apr 2020",
2020-05-31 15:00:11 +06:30
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: 'Pickuped',
date: DateTime(2020, 5, 15),
2020-06-24 16:06:40 +06:30
address: '154-19 64th Ave.\nFlushing, NY 11367',
2020-07-02 16:16:21 +06:30
handlingFee: 50,
2020-06-25 16:19:23 +06:30
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-07-02 16:16:21 +06:30
id: "S200125 - 12 May 2020",
2020-05-31 15:00:11 +06:30
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: 'Pickuped',
date: DateTime(2020, 5, 20),
2020-06-24 16:06:40 +06:30
address: '154-19 64th Ave.\nFlushing, NY 11367',
2020-07-02 16:16:21 +06:30
handlingFee: 50,
2020-06-25 16:19:23 +06:30
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-07-02 16:16:21 +06:30
id: "S200441 - 13 Apr 2020",
2020-05-31 15:00:11 +06:30
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: "Pickuped",
date: DateTime(2020, 5, 21),
2020-06-24 16:06:40 +06:30
address: '154-19 64th Ave.\nFlushing, NY 11367',
2020-07-02 16:16:21 +06:30
handlingFee: 50,
2020-06-25 16:19:23 +06:30
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-07-02 16:16:21 +06:30
id: "S200441 - 10 Apr 2020",
2020-05-31 15:00:11 +06:30
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: "Canceled",
date: DateTime(2020, 5, 25),
2020-06-24 16:06:40 +06:30
address: '154-19 64th Ave.\nFlushing, NY 11367',
2020-07-02 16:16:21 +06:30
handlingFee: 50,
2020-06-25 16:19:23 +06:30
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-10-07 14:42:07 +06:30
Shipment(
2020-07-02 16:16:21 +06:30
id: "S200441 - 6 Apr 2020",
2020-05-31 15:00:11 +06:30
userName: "Ko Kyaw Nyi",
phoneNumber: '+959111111111',
fromTime: '1PM',
toTime: '3PM',
numberOfPackage: 5,
weight: 25,
status: "Canceled",
date: DateTime(2020, 5, 27),
2020-06-24 16:06:40 +06:30
address: '154-19 64th Ave.\nFlushing, NY 11367',
2020-07-02 16:16:21 +06:30
handlingFee: 50,
2020-06-25 16:19:23 +06:30
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-05-29 15:54:26 +06:30
];
2020-10-07 14:42:07 +06:30
List<Shipment> get canceled {
List<Shipment> _p = pickups.where((e) => e.status == "Canceled").toList()
2020-05-31 15:00:11 +06:30
..sort((e1, e2) {
return e2.date.compareTo(e1.date);
});
return _p;
}
2020-10-07 14:42:07 +06:30
List<Shipment> get completed {
2020-05-31 15:00:11 +06:30
return pickups.where((e) => e.status == "Pickuped").toList()
..sort((e1, e2) {
return e2.date.compareTo(e1.date);
});
}
2020-10-07 14:42:07 +06:30
List<Shipment> get upcoming {
2020-05-31 15:00:11 +06:30
return pickups
.where((e) =>
e.status == "Pending" ||
2020-06-26 16:17:40 +06:30
e.status == "Confirmed" ||
2020-05-31 15:00:11 +06:30
e.status == "Processed" ||
e.status == "Rescheduled")
.toList()
..sort((e1, e2) {
return e2.date.compareTo(e1.date);
});
}
2020-05-29 15:54:26 +06:30
void initUser(user) {
super.initUser(user);
}
@override
logout() async {
if (listener != null) await listener.cancel();
2020-07-02 16:16:21 +06:30
// pickups = [];
2020-05-29 15:54:26 +06:30
}
}