Files
fcs/lib/model/pickup_model.dart

202 lines
5.9 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-06-25 16:19:23 +06:30
import 'package:fcs/vo/cargo.dart';
2020-05-29 15:54:26 +06:30
import 'package:fcs/vo/fcs_profile.dart';
import 'package:fcs/vo/pickup.dart';
import 'package:logging/logging.dart';
import 'base_model.dart';
class PickUpModel extends BaseModel {
final log = Logger('PickUpModel');
StreamSubscription<QuerySnapshot> listener;
var profile = FCSProfile(
id: '1',
2020-06-01 14:42:42 +06:30
usaAddress: '154-19 64th Ave.\nFlushing, NY 11367',
2020-05-29 15:54:26 +06:30
mmAddress: 'FCS Trading Myanmar\nRoom 333, Yangon',
usaContactNumber: '1 (929) 215-2247',
mmContactNumber: '+95 9 700224723',
mail: 'admin@fcs.com',
facebook: 'https://facebook.com/fcs');
List<PickUp> pickups = [
PickUp(
id: "P200412 - 12 Apr 2020",
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-06-25 16:19:23 +06:30
handlingFee: 5000,
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
PickUp(
id: "P200125 - 12 May 2020",
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-06-25 16:19:23 +06:30
handlingFee: 5000,
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
PickUp(
id: "P200441 - 13 Apr 2020",
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-06-25 16:19:23 +06:30
handlingFee: 5000,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-05-31 15:00:11 +06:30
PickUp(
id: "P200412 - 12 Apr 2020",
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-06-25 16:19:23 +06:30
handlingFee: 5000,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-05-31 15:00:11 +06:30
PickUp(
id: "P200125 - 12 May 2020",
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-06-25 16:19:23 +06:30
handlingFee: 5000,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-05-31 15:00:11 +06:30
PickUp(
id: "P200441 - 13 Apr 2020",
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-06-25 16:19:23 +06:30
handlingFee: 5000,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-05-31 15:00:11 +06:30
PickUp(
id: "P200441 - 10 Apr 2020",
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-06-25 16:19:23 +06:30
handlingFee: 5000,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
2020-05-31 15:00:11 +06:30
PickUp(
id: "P200441 - 6 Apr 2020",
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-06-25 16:19:23 +06:30
handlingFee: 5000,
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-05-31 15:00:11 +06:30
List<PickUp> get canceled {
List<PickUp> _p = pickups.where((e) => e.status == "Canceled").toList()
..sort((e1, e2) {
return e2.date.compareTo(e1.date);
});
return _p;
}
List<PickUp> get completed {
return pickups.where((e) => e.status == "Pickuped").toList()
..sort((e1, e2) {
return e2.date.compareTo(e1.date);
});
}
List<PickUp> get upcoming {
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();
pickups = [];
}
}