This commit is contained in:
Sai Naw Wun
2020-10-07 02:33:06 +06:30
parent 01a2798a74
commit 65dda16fe6
475 changed files with 1543 additions and 90780 deletions

View File

@@ -0,0 +1,557 @@
import 'package:fcs/domain/entities/box.dart';
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/shipping_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/shipment_address/model/shipment_address_model.dart';
import 'package:fcs/pages/shipment_address/shipping_address_row.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/my_data_table.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart';
class BoxEditor extends StatefulWidget {
final Box box;
BoxEditor({this.box});
@override
_BoxEditorState createState() => _BoxEditorState();
}
class _BoxEditorState extends State<BoxEditor> {
TextEditingController _addressEditingController = new TextEditingController();
TextEditingController _fromTimeEditingController =
new TextEditingController();
TextEditingController _toTimeEditingController = new TextEditingController();
TextEditingController _noOfPackageEditingController =
new TextEditingController();
TextEditingController _weightEditingController = new TextEditingController();
Box _box;
bool _isLoading = false;
List<String> _images = [
"assets/photos/1.jpg",
"assets/photos/2.jpg",
"assets/photos/3.jpg"
];
bool isNew;
bool isMixBox = false;
ShippingAddress _shippingAddress = new ShippingAddress();
@override
void initState() {
super.initState();
if (widget.box != null) {
_box = widget.box;
_shippingAddress = _box.shippingAddress;
isNew = false;
// _addressEditingController.text = _pickUp.address;
// _fromTimeEditingController.text = _pickUp.fromTime;
// _toTimeEditingController.text = _pickUp.toTime;
// _noOfPackageEditingController.text = _pickUp.numberOfPackage.toString();
// _weightEditingController.text = _pickUp.weight.toString();
} else {
List<Package> packages = [
// PackageModel.packages[0],
// PackageModel.packages[1],
// PackageModel.packages[2]
];
List<Cargo> _cargoTypes = [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
];
var shipmentModel =
Provider.of<ShipmentAddressModel>(context, listen: false);
_shippingAddress = shipmentModel.shippingAddresses[1];
isNew = true;
_box = Box(
rate: 0,
weight: 75,
width: 0,
height: 0,
length: 0,
packages: packages,
cargoTypes: _cargoTypes,
shipmentWeight: 0);
}
}
@override
void dispose() {
super.dispose();
}
final DateFormat dateFormat = DateFormat("d MMM yyyy");
List<TimelineModel> _models() {
// return [];
return _box.shipmentHistory
.map((e) => TimelineModel(
Padding(
padding: const EdgeInsets.all(18.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(e.status,
style: TextStyle(
color: e.done ? primaryColor : Colors.grey,
fontSize: 16,
fontWeight: FontWeight.bold)),
e.status == "Processed"
? Text("(Waiting for payment)",
style: TextStyle(
color: e.done ? primaryColor : Colors.grey,
fontSize: 14,
fontWeight: FontWeight.bold))
: Container(),
Text(dateFormat.format(e.date)),
],
),
),
iconBackground: e.done ? primaryColor : Colors.grey,
icon: Icon(
e.status == "Shipped"
? Ionicons.ios_airplane
: e.status == "Delivered"
? MaterialCommunityIcons.truck_fast
: e.status == "Processed"
? MaterialIcons.check
: Octicons.package,
color: Colors.white,
)))
.toList();
}
@override
Widget build(BuildContext context) {
var mainModel = Provider.of<MainModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("box.edit.title")),
),
body: Card(
child: Column(
children: <Widget>[
widget.box == null
? Center(
child: Container(
padding: EdgeInsets.all(8), child: Text("New Box")))
: Center(child: nameWidget(_box.packageNumber)),
Expanded(
child: ListView(
children: [
ExpansionTile(
title: Text(
'Shipment Information',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: DropdownButtonFormField(
value: _box.shipmentNumber,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'FCS Shipment Number',
icon: Icon(Ionicons.ios_airplane,
color: primaryColor)
// prefixIcon: Icon(Icons.play_arrow)
),
items: ["A102", "A103", "A201", "A202"]
.map((e) =>
DropdownMenuItem(child: Text(e), value: e))
.toList(),
onChanged: (map) => {},
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, right: 20),
child: new Row(
children: <Widget>[
new Checkbox(
value: isMixBox,
activeColor: primaryColor,
onChanged: (bool value) {
setState(() {
isMixBox = value;
});
}),
SizedBox(
width: 5,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
"Mix Box",
style: TextStyle(fontSize: 15.0),
),
],
),
],
),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue:
isNew ? "FCS-0203-390-2" : "FCS-0203-390-2",
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'FCS_ID',
hintText: 'FCS_ID',
filled: true,
icon: Icon(Feather.user, color: primaryColor),
suffixIcon: IconButton(
icon: Icon(Icons.search),
onPressed: () {})),
),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.receiverName,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Customer Name',
filled: true,
icon: Icon(Feather.user, color: Colors.white),
suffixIcon: IconButton(
icon: Icon(Icons.search),
onPressed: () {})),
),
),
SizedBox(
height: 30,
)
],
),
ExpansionTile(
title: Text(
'Cargo Types',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
// Padding(
// padding: const EdgeInsets.only(left: 20.0, right: 20),
// child: DropdownButtonFormField(
// value: _box.packageType,
// decoration: InputDecoration(
// fillColor: Colors.white,
// labelText: 'Cargo Type',
// icon: Icon(Entypo.box, color: primaryColor)),
// items: ["General", "Medicine", "Dangerous"]
// .map((e) =>
// DropdownMenuItem(child: Text(e), value: e))
// .toList(),
// onChanged: (map) => {},
// ),
// ),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.weight.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Actual Weight',
filled: true,
icon: Icon(FontAwesomeIcons.weightHanging,
color: primaryColor),
)),
),
// Padding(
// padding: const EdgeInsets.only(left: 20.0, right: 20),
// child: TextFormField(
// initialValue: _box.rate.toString(),
// textAlign: TextAlign.end,
// decoration: InputDecoration(
// fillColor: Colors.white,
// labelText: 'Rate',
// filled: true,
// icon: Icon(FontAwesomeIcons.tag,
// color: primaryColor),
// )),
// ),
// Padding(
// padding: const EdgeInsets.only(left: 20.0, right: 20),
// child: TextFormField(
// initialValue: _box.amount.toString(),
// textAlign: TextAlign.end,
// decoration: InputDecoration(
// fillColor: Colors.white,
// labelText: 'Total Amount',
// filled: true,
// icon: Icon(FontAwesomeIcons.moneyBill,
// color: primaryColor),
// )),
// ),
Container(
padding: EdgeInsets.only(top: 10),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: MyDataTable(
headingRowHeight: 40,
columnSpacing: 120,
columns: [
MyDataColumn(
label: LocalText(
context,
"cargo.type",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"cargo.weight",
color: Colors.grey,
),
),
],
rows: getCargoRows(context),
),
),
),
true
? Container(
padding: EdgeInsets.only(top: 20),
child: Align(
alignment: Alignment.bottomRight,
child: FloatingActionButton.extended(
icon: Icon(Icons.add),
label: Text("Add Cargo"),
backgroundColor: primaryColor,
onPressed: () {
// Navigator.of(context).push(
// BottomUpPageRoute(PackageAddition()));
},
),
),
)
: Container(),
SizedBox(height: 25),
],
),
ExpansionTile(
title: Text(
'Box Dimension',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: fcsInputReadOnly(
"Shipment Weight", FontAwesomeIcons.weightHanging,
value: _box.shipmentWeight.toString()),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.width.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Width',
filled: true,
icon: Icon(FontAwesomeIcons.arrowCircleRight,
color: primaryColor),
)),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.height.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Height',
filled: true,
icon: Icon(FontAwesomeIcons.arrowAltCircleUp,
color: primaryColor),
)),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.length.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Length',
filled: true,
icon: Icon(FontAwesomeIcons.arrowCircleUp,
color: primaryColor),
)),
),
SizedBox(height: 25),
],
),
ExpansionTile(
title: Text(
'Shipping Address',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
ShippingAddressRow(shippingAddress: _shippingAddress),
Container(
padding:
EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 130,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
onPressed: () {},
icon: Icon(Icons.add),
label: Text(
'Select \nAddress',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
),
SizedBox(height: 25),
],
),
isNew
? Container()
: ExpansionTile(
title: Text(
'Status',
style: TextStyle(
color: primaryColor,
fontWeight: FontWeight.bold),
),
children: <Widget>[
Container(
height: 500,
padding: EdgeInsets.only(left: 20),
child: isNew
? Container()
: Timeline(
children: _models(),
position: TimelinePosition.Left),
),
],
)
],
),
),
widget.box == null
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Create New Box'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Container(
child: Column(
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Complete packing'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
widget.box.status == 'Arrived'
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Deliver'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Container(),
],
)),
],
),
),
),
);
}
List<MyDataRow> getCargoRows(BuildContext context) {
if (_box == null || _box.cargoTypes == null) {
return [];
}
return _box.cargoTypes.map((c) {
return MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
MyDataCell(new Text(
c.type == null ? "" : c.type,
style: textStyle,
)),
MyDataCell(
new Text(c.weight == null ? "0" : c.weight.toString(),
style: textStyle),
),
],
);
}).toList();
}
List<Widget> getAddressList(
BuildContext context, List<ShippingAddress> addresses) {
return addresses.asMap().entries.map((s) {
return InkWell(
onTap: () {},
child: ShippingAddressRow(shippingAddress: s.value, index: s.key),
);
}).toList();
}
}

137
lib/pages/box/box_list.dart Normal file
View File

@@ -0,0 +1,137 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/box/model/box_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'box_editor.dart';
import 'box_list_row.dart';
class BoxList extends StatefulWidget {
@override
_BoxListState createState() => _BoxListState();
}
class _BoxListState extends State<BoxList> {
bool _isLoading = false;
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return LocalProgress(
inAsyncCall: _isLoading,
child: DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("boxes.title")),
actions: <Widget>[
IconButton(
icon: Icon(
Icons.search,
color: Colors.white,
),
iconSize: 30,
// onPressed: () => showPlacesSearch(context),
),
],
bottom: TabBar(
unselectedLabelColor: Colors.grey,
tabs: [
Tab(
text: "Upcoming",
),
Tab(text: "Delivered"),
],
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
_newPickup();
},
icon: Icon(Icons.add),
label: Text(AppTranslations.of(context).text("boxes.new")),
backgroundColor: primaryColor,
),
body: TabBarView(
children: [
_upComing(),
_completed(),
],
)),
),
);
}
_newPickup() {
Navigator.push(
context,
BottomUpPageRoute(BoxEditor()),
);
}
Widget _upComing() {
var boxModel = Provider.of<BoxModel>(context);
return Column(
children: <Widget>[
Expanded(
child: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: boxModel.upcoming.length,
itemBuilder: (BuildContext context, int index) {
return BoxListRow(
box: boxModel.upcoming[index],
isReadOnly: false,
);
}),
),
],
);
}
Widget _completed() {
var boxModel = Provider.of<BoxModel>(context);
return Column(
children: <Widget>[
Expanded(
child: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: boxModel.completed.length,
itemBuilder: (BuildContext context, int index) {
return BoxListRow(
box: boxModel.completed[index],
isReadOnly: false,
);
}),
),
],
);
}
}

View File

@@ -0,0 +1,115 @@
import 'package:fcs/domain/entities/box.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'box_editor.dart';
class BoxListRow extends StatefulWidget {
final bool isReadOnly;
final Box box;
const BoxListRow({this.box, this.isReadOnly});
@override
_BoxListRowState createState() => _BoxListRowState();
}
class _BoxListRowState extends State<BoxListRow> {
final double dotSize = 15.0;
Box _box = new Box();
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
@override
void initState() {
super.initState();
_box = widget.box;
}
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(left: 15, right: 15),
child: InkWell(
onTap: () {
if (widget.isReadOnly) {
// Navigator.push(
// context,
// BottomUpPageRoute(PackageInfo(package: _box)),
// );
} else {
Navigator.push(
context,
BottomUpPageRoute(BoxEditor(box: _box)),
);
}
},
child: Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: new Row(
children: <Widget>[
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
_box.packageNumber == null
? ''
: _box.packageNumber,
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
),
Padding(
padding: const EdgeInsets.only(left: 10.0, top: 10),
child: new Text(
dateFormat.format(_box.arrivedDate),
style: new TextStyle(
fontSize: 15.0, color: Colors.grey),
),
)
],
),
),
],
),
),
),
Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(0),
child: getStatus(_box.status),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
child: Row(
children: <Widget>[
new Text(
_box.weight == null
? ''
: _box.weight.toString() + 'lb - ',
style:
new TextStyle(fontSize: 15.0, color: Colors.grey),
),
new Text(
_box.price == null ? "" : "\$ " + _box.price.toString(),
style:
new TextStyle(fontSize: 15.0, color: Colors.grey),
),
],
),
),
],
)
],
),
),
);
}
}

View File

@@ -0,0 +1,307 @@
import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/domain/entities/box.dart';
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/shipment_status.dart';
import 'package:fcs/domain/vo/shipping_address.dart';
import 'package:fcs/pages/main/model/base_model.dart';
import 'package:logging/logging.dart';
class BoxModel extends BaseModel {
final log = Logger('BoxModel');
StreamSubscription<QuerySnapshot> listener;
static List<ShipmentStatus> statusHistory = [
ShipmentStatus(status: "Packed", date: DateTime(2020, 6, 1), done: true),
ShipmentStatus(status: "Shipped", date: DateTime(2020, 6, 5), done: false),
ShipmentStatus(
status: "Delivered", date: DateTime(2020, 6, 15), done: false)
];
static List<Package> packages = [
// PackageModel.packages[0],
// PackageModel.packages[1],
// PackageModel.packages[2]
];
List<Box> boxes = [
Box(
shipmentNumber: "A202",
receiverNumber: "3",
receiverName: "Ko Myo Min",
boxNumber: "1",
rate: 7,
packageType: "General",
weight: 75,
status: "Packed",
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
cargoDesc: "Clothes",
arrivedDate: DateTime(2020, 6, 1),
width: 10,
height: 10,
length: 10,
shipmentWeight: 6,
packages: packages,
shipmentHistory: statusHistory,
shippingAddress: ShippingAddress(
fullName: 'U Nyi Nyi',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247'),
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
Box(
shipmentNumber: "A202",
receiverNumber: "3",
receiverName: "Ko Myo Min",
boxNumber: "2",
rate: 7,
packageType: "General",
weight: 75,
status: "Packed",
cargoDesc: "Clothes",
arrivedDate: DateTime(2020, 6, 1),
width: 10,
height: 20,
length: 30,
shipmentWeight: 36,
shipmentHistory: statusHistory,
packages: packages,
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
shippingAddress: ShippingAddress(
fullName: 'Mg Myo',
addressLine1: '153-154 5th Thitsar.',
addressLine2: 'South Okkalapa Township',
city: 'Yangon',
state: 'Myanmar',
phoneNumber: '+09 95724 8750'),
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
Box(
shipmentNumber: "A202",
receiverNumber: "3",
receiverName: "Ko Myo Min",
boxNumber: "3",
rate: 7,
packageType: "General",
weight: 75,
cargoDesc: "Shoes",
status: "Packed",
arrivedDate: DateTime(2020, 6, 1),
width: 10,
height: 10,
length: 10,
shipmentWeight: 6,
shipmentHistory: statusHistory,
packages: packages,
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
shippingAddress: ShippingAddress(
fullName: 'Mg Myo',
addressLine1: '153-154 5th Thitsar.',
addressLine2: 'South Okkalapa Township',
city: 'Yangon',
state: 'Myanmar',
phoneNumber: '+09 95724 8750'),
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
Box(
shipmentNumber: "A202",
receiverNumber: "2",
receiverName: "Ma Aye",
boxNumber: "1",
rate: 8,
packageType: "Medicine",
weight: 75,
status: "Packed",
cargoDesc: "Dietary supplement",
arrivedDate: DateTime(2020, 6, 1),
width: 10,
height: 10,
length: 10,
shipmentWeight: 6,
shipmentHistory: statusHistory,
packages: packages,
receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon',
shippingAddress: ShippingAddress(
fullName: 'U Nyi Nyi',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247'),
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
Box(
shipmentNumber: "A202",
receiverNumber: "2",
receiverName: "Ma Aye",
boxNumber: "3",
rate: 7,
packageType: "General",
cargoDesc: "Handbags",
weight: 75,
status: "Arrived",
arrivedDate: DateTime(2020, 6, 1),
width: 10,
height: 10,
length: 10,
shipmentWeight: 6,
shipmentHistory: statusHistory,
packages: packages,
receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon',
shippingAddress: ShippingAddress(
fullName: 'U Nyi Nyi',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247'),
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
Box(
shipmentNumber: "A202",
receiverNumber: "2",
receiverName: "Ma Aye",
boxNumber: "2",
rate: 7,
packageType: "General",
cargoDesc: "Handbags",
weight: 75,
status: "Shipped",
arrivedDate: DateTime(2020, 6, 1),
width: 10,
height: 10,
length: 10,
shipmentWeight: 6,
shipmentHistory: statusHistory,
packages: packages,
receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon',
shippingAddress: ShippingAddress(
fullName: 'U Nyi Nyi',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247'),
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
Box(
shipmentNumber: "A201",
receiverNumber: "1",
receiverName: "Ko Wai",
boxNumber: "1",
rate: 9,
packageType: "Dangerous",
cargoDesc: "Phones and Scooters",
weight: 75,
status: "Delivered",
arrivedDate: DateTime(2020, 5, 21),
width: 10,
height: 10,
length: 10,
shipmentWeight: 6,
shipmentHistory: statusHistory,
packages: packages,
receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon',
shippingAddress: ShippingAddress(
fullName: 'U Nyi Nyi',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247'),
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
Box(
shipmentNumber: "A201",
receiverNumber: "1",
receiverName: "Ko Wai",
boxNumber: "2",
rate: 7,
packageType: "General",
cargoDesc: "Construction tools",
weight: 75,
status: "Delivered",
arrivedDate: DateTime(2020, 5, 21),
width: 10,
height: 10,
length: 10,
shipmentWeight: 6,
shipmentHistory: statusHistory,
packages: packages,
receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon',
shippingAddress: ShippingAddress(
fullName: 'U Nyi Nyi',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247'),
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
]),
];
List<Box> get completed {
return boxes.where((e) => e.status == "Delivered").toList()
..sort((e1, e2) {
return e2.packageNumber.compareTo(e1.packageNumber);
});
}
List<Box> get processed {
return boxes.where((e) => e.status == "Packed").toList()
..sort((e1, e2) {
return e2.packageNumber.compareTo(e1.packageNumber);
});
}
List<Box> get upcoming {
return boxes
.where((e) =>
e.status == "Packed" ||
// e.status == "Received" ||
e.status == "Shipped" ||
e.status == "Arrived")
.toList()
..sort((e1, e2) {
return e2.packageNumber.compareTo(e1.packageNumber);
});
}
void initUser(user) {
super.initUser(user);
}
@override
logout() async {
if (listener != null) await listener.cancel();
boxes = [];
}
}