add delivery
This commit is contained in:
@@ -295,6 +295,8 @@
|
|||||||
"delivery.info.title":"Delivery",
|
"delivery.info.title":"Delivery",
|
||||||
"delivery.popupmenu.active":"Active cartons",
|
"delivery.popupmenu.active":"Active cartons",
|
||||||
"delivery.popupmenu.delivered":"Delivered cartons",
|
"delivery.popupmenu.delivered":"Delivered cartons",
|
||||||
|
"delivery.deliver.btn":"Complete delivery",
|
||||||
|
"delivery.deliver.confirm":"Complete delivery?",
|
||||||
"Delivery End ================================================================":"",
|
"Delivery End ================================================================":"",
|
||||||
|
|
||||||
"FCS Shipment Start ================================================================":"",
|
"FCS Shipment Start ================================================================":"",
|
||||||
@@ -321,7 +323,7 @@
|
|||||||
"FCSshipment.ship.btn":"Ship",
|
"FCSshipment.ship.btn":"Ship",
|
||||||
"FCSshipment.ship.confirm":"Confirm ship?",
|
"FCSshipment.ship.confirm":"Confirm ship?",
|
||||||
"FCSshipment.popupmenu.active":"Active FCS shipments",
|
"FCSshipment.popupmenu.active":"Active FCS shipments",
|
||||||
"FCSshipment.popupmenu.delivered":"Delivered FCS shipments",
|
"FCSshipment.popupmenu.shipped":"Shipped FCS shipments",
|
||||||
"FCS Shipment End ================================================================":"",
|
"FCS Shipment End ================================================================":"",
|
||||||
|
|
||||||
"Shipment Start ================================================================":"",
|
"Shipment Start ================================================================":"",
|
||||||
|
|||||||
@@ -295,6 +295,8 @@
|
|||||||
"delivery.info.title":"ပေးပို့ရန်",
|
"delivery.info.title":"ပေးပို့ရန်",
|
||||||
"delivery.popupmenu.active":"လာမည့် သေတ္တာများ",
|
"delivery.popupmenu.active":"လာမည့် သေတ္တာများ",
|
||||||
"delivery.popupmenu.delivered":"ပို့ပြီးသော သေတ္တာများ",
|
"delivery.popupmenu.delivered":"ပို့ပြီးသော သေတ္တာများ",
|
||||||
|
"delivery.deliver.btn":"ပို့ခြင်း ပြီးဆုံးမည်",
|
||||||
|
"delivery.deliver.confirm":"ပို့ခြင်း ပြီးဆုံးမလား?",
|
||||||
"Delivery End ================================================================":"",
|
"Delivery End ================================================================":"",
|
||||||
|
|
||||||
"FCS Shipment Start ================================================================":"",
|
"FCS Shipment Start ================================================================":"",
|
||||||
@@ -320,6 +322,8 @@
|
|||||||
"FCSshipment.update":"FCS တင်ပို့ခြင်းပြုပြင်မည်",
|
"FCSshipment.update":"FCS တင်ပို့ခြင်းပြုပြင်မည်",
|
||||||
"FCSshipment.ship.btn":"Ship",
|
"FCSshipment.ship.btn":"Ship",
|
||||||
"FCSshipment.ship.confirm":"Confirm ship?",
|
"FCSshipment.ship.confirm":"Confirm ship?",
|
||||||
|
"FCSshipment.popupmenu.active":"Active FCS shipments",
|
||||||
|
"FCSshipment.popupmenu.shipped":"Shipped FCS shipments",
|
||||||
"FCS Shipment End ================================================================":"",
|
"FCS Shipment End ================================================================":"",
|
||||||
|
|
||||||
"Shipment Start ================================================================":"",
|
"Shipment Start ================================================================":"",
|
||||||
|
|||||||
@@ -25,4 +25,9 @@ class CartonDataProvider {
|
|||||||
return await requestAPI("/cartons", "DELETE",
|
return await requestAPI("/cartons", "DELETE",
|
||||||
payload: carton.toMap(), token: await getToken());
|
payload: carton.toMap(), token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> deliver(Carton carton) async {
|
||||||
|
return await requestAPI("/cartons/deliver", "PUT",
|
||||||
|
payload: carton.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,4 +28,9 @@ class CartonServiceImp implements CartonService {
|
|||||||
Future<void> updateCarton(Carton carton) {
|
Future<void> updateCarton(Carton carton) {
|
||||||
return cartonDataProvider.updateCarton(carton);
|
return cartonDataProvider.updateCarton(carton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deliver(Carton carton) {
|
||||||
|
return cartonDataProvider.deliver(carton);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ abstract class CartonService {
|
|||||||
Future<void> createCarton(Carton carton);
|
Future<void> createCarton(Carton carton);
|
||||||
Future<void> updateCarton(Carton carton);
|
Future<void> updateCarton(Carton carton);
|
||||||
Future<void> deleteCarton(Carton carton);
|
Future<void> deleteCarton(Carton carton);
|
||||||
|
Future<void> deliver(Carton carton);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,33 +79,10 @@ class CartonModel extends BaseModel {
|
|||||||
_loadBoxes();
|
_loadBoxes();
|
||||||
|
|
||||||
if (_delivered != null) _delivered.close();
|
if (_delivered != null) _delivered.close();
|
||||||
// _delivered = _getDelivered();
|
_delivered = _getDelivered();
|
||||||
_delivered = _getDeliveredExample();
|
|
||||||
_delivered.load();
|
_delivered.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
Paginator _getDeliveredExample() {
|
|
||||||
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 Carton(
|
|
||||||
id: m.id,
|
|
||||||
shipmentNumber: m.message,
|
|
||||||
boxNumber: "1",
|
|
||||||
receiverNumber: "3",
|
|
||||||
rate: 0,
|
|
||||||
weight: 0,
|
|
||||||
arrivedDate: m.date,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
return paginator;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadBoxes() async {
|
Future<void> _loadBoxes() async {
|
||||||
if (user == null || !user.hasCarton()) return;
|
if (user == null || !user.hasCarton()) return;
|
||||||
String path = "/$cartons_collection/";
|
String path = "/$cartons_collection/";
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import 'package:fcs/domain/entities/carton.dart';
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/carton/carton_package_table.dart';
|
||||||
|
import 'package:fcs/pages/carton/model/carton_model.dart';
|
||||||
import 'package:fcs/pages/carton/widgets.dart';
|
import 'package:fcs/pages/carton/widgets.dart';
|
||||||
import 'package:fcs/pages/delivery/model/delivery_model.dart';
|
import 'package:fcs/pages/delivery/model/delivery_model.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
@@ -12,6 +15,8 @@ import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
|||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||||
import 'package:fcs/pages/widgets/length_picker.dart';
|
import 'package:fcs/pages/widgets/length_picker.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_button.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/local_title.dart';
|
import 'package:fcs/pages/widgets/local_title.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
@@ -20,8 +25,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:timeline_list/timeline.dart';
|
|
||||||
import 'package:timeline_list/timeline_model.dart';
|
|
||||||
|
|
||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
|
|
||||||
@@ -37,7 +40,6 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
|||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
Carton _box;
|
Carton _box;
|
||||||
String _selectedCartonType;
|
String _selectedCartonType;
|
||||||
String _shipmentNumber;
|
|
||||||
List<Package> _packages = [];
|
List<Package> _packages = [];
|
||||||
List<Carton> _mixBoxes = [];
|
List<Carton> _mixBoxes = [];
|
||||||
Carton _selectedShipmentBox = new Carton();
|
Carton _selectedShipmentBox = new Carton();
|
||||||
@@ -49,35 +51,17 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
|||||||
double volumetricRatio = 0;
|
double volumetricRatio = 0;
|
||||||
double shipmentWeight = 0;
|
double shipmentWeight = 0;
|
||||||
|
|
||||||
|
bool isMixBox;
|
||||||
|
bool isFromShipments;
|
||||||
|
bool isFromPackages;
|
||||||
|
bool isSmallBag;
|
||||||
|
bool isEdiable;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_box = widget.box;
|
_box = widget.box;
|
||||||
_shipmentNumber = _box.shipmentNumber;
|
|
||||||
_selectedCartonType = _box.cartonType;
|
_selectedCartonType = _box.cartonType;
|
||||||
// for packages
|
|
||||||
var packageModel = Provider.of<PackageModel>(context, listen: false);
|
|
||||||
_packages = [
|
|
||||||
// packageModel.packages[0],
|
|
||||||
// packageModel.packages[1],
|
|
||||||
];
|
|
||||||
_packages.forEach((p) {
|
|
||||||
p.isChecked = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
//for shipment boxes
|
|
||||||
var deliveryModel = Provider.of<DeliveryModel>(context, listen: false);
|
|
||||||
_selectedShipmentBox = deliveryModel.cartonList[0];
|
|
||||||
|
|
||||||
//for mix carton
|
|
||||||
_mixBoxes = [
|
|
||||||
deliveryModel.cartonList[0],
|
|
||||||
deliveryModel.cartonList[1],
|
|
||||||
deliveryModel.cartonList[2]
|
|
||||||
];
|
|
||||||
_mixBoxes.forEach((b) {
|
|
||||||
b.isChecked = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
//for shipment weight
|
//for shipment weight
|
||||||
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||||
@@ -87,12 +71,44 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
|||||||
_widthController.addListener(_calShipmentWeight);
|
_widthController.addListener(_calShipmentWeight);
|
||||||
_heightController.addListener(_calShipmentWeight);
|
_heightController.addListener(_calShipmentWeight);
|
||||||
|
|
||||||
|
_updateBoxData();
|
||||||
|
_loadPackages();
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateBoxData() {
|
||||||
_widthController.text = _box.width.toString();
|
_widthController.text = _box.width.toString();
|
||||||
_heightController.text = _box.height.toString();
|
_heightController.text = _box.height.toString();
|
||||||
_lengthController.text = _box.length.toString();
|
_lengthController.text = _box.length.toString();
|
||||||
|
|
||||||
_cargoTypes = _box.cargoTypes;
|
_cargoTypes = _box.cargoTypes;
|
||||||
_deliveryAddress = _box.deliveryAddress;
|
_deliveryAddress = _box.deliveryAddress;
|
||||||
|
isMixBox = _box.cartonType == carton_mix_box;
|
||||||
|
isFromShipments = _box.cartonType == carton_from_shipments;
|
||||||
|
isFromPackages = _box.cartonType == carton_from_packages;
|
||||||
|
isSmallBag = _box.cartonType == carton_small_bag;
|
||||||
|
isEdiable = !isMixBox &&
|
||||||
|
(isFromPackages || isSmallBag) &&
|
||||||
|
_box.status == carton_packed_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
_loadPackages() async {
|
||||||
|
if (!isFromPackages && !isSmallBag) return;
|
||||||
|
|
||||||
|
if (_box.cartonType == carton_from_packages && _box.userID == null) return;
|
||||||
|
PackageModel packageModel =
|
||||||
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
|
List<Package> packages = await packageModel.getPackages(_box.userID, [
|
||||||
|
package_processed_status,
|
||||||
|
package_packed_status,
|
||||||
|
package_shipped_status
|
||||||
|
]);
|
||||||
|
packages = packages.where((p) => _box.packageIDs.contains(p.id)).toList();
|
||||||
|
packages.forEach((p) {
|
||||||
|
p.isChecked = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_box.packages = packages;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_calShipmentWeight() {
|
_calShipmentWeight() {
|
||||||
@@ -110,64 +126,18 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
List<TimelineModel> _models() {
|
|
||||||
if (_box.shipmentHistory == null) return [];
|
|
||||||
// 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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cargoType = Container(
|
var cartonModel = Provider.of<CartonModel>(context);
|
||||||
height: 30,
|
|
||||||
padding: EdgeInsets.only(left: 15),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(Icons.check_circle, color: primaryColor),
|
|
||||||
SizedBox(
|
|
||||||
width: 10,
|
|
||||||
),
|
|
||||||
Text(_selectedCartonType ?? ""),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
|
final cartonTypeBox = LocalRadioButtons(
|
||||||
|
readOnly: true,
|
||||||
|
values: cartonModel.cartonTypesInfo,
|
||||||
|
selectedValue:
|
||||||
|
_box.isShipmentCarton ? carton_from_shipments : _box.cartonType);
|
||||||
final shipmentBox = DisplayText(
|
final shipmentBox = DisplayText(
|
||||||
text: _shipmentNumber == null ? "" : _shipmentNumber,
|
text: _box.fcsShipmentNumber,
|
||||||
labelTextKey: "box.fcs_shipment_num",
|
labelTextKey: "box.fcs_shipment_num",
|
||||||
iconData: Ionicons.ios_airplane,
|
iconData: Ionicons.ios_airplane,
|
||||||
);
|
);
|
||||||
@@ -183,60 +153,6 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
|||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
);
|
);
|
||||||
|
|
||||||
final packageTitle = Container(
|
|
||||||
padding: EdgeInsets.only(left: 15, right: 10.0, top: 20),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: LocalText(context, 'box.tracking.id', color: Colors.grey),
|
|
||||||
),
|
|
||||||
LocalText(context, 'box.package.desc', color: Colors.grey),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
List<Widget> getPackageRowList() {
|
|
||||||
return _packages.asMap().entries.map((p) {
|
|
||||||
return Container(
|
|
||||||
color: Colors.grey[50].withOpacity(0.2),
|
|
||||||
child: Container(
|
|
||||||
padding:
|
|
||||||
EdgeInsets.only(left: 15.0, right: 10.0, top: 5.0, bottom: 5.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border(
|
|
||||||
bottom: BorderSide(
|
|
||||||
color: p.key == _packages.length - 1
|
|
||||||
? Colors.white
|
|
||||||
: Colors.grey[350],
|
|
||||||
width: 1),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: new Text(
|
|
||||||
p.value.trackingID,
|
|
||||||
style: textStyle,
|
|
||||||
)),
|
|
||||||
new Column(
|
|
||||||
children: [
|
|
||||||
new Text(
|
|
||||||
p.value.desc == null ? "" : p.value.desc,
|
|
||||||
style: textStyle,
|
|
||||||
),
|
|
||||||
new Text(
|
|
||||||
"(${p.value.market == null ? "" : p.value.market})",
|
|
||||||
style: textStyle,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
final shipmentBoxTitle = Container(
|
final shipmentBoxTitle = Container(
|
||||||
padding: EdgeInsets.only(left: 15, right: 10.0, top: 20),
|
padding: EdgeInsets.only(left: 15, right: 10.0, top: 20),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -269,139 +185,6 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final mixBoxTitle = Container(
|
|
||||||
padding: EdgeInsets.only(left: 15, right: 10.0, top: 20),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: LocalText(context, 'box.mix.number', color: Colors.grey),
|
|
||||||
),
|
|
||||||
LocalText(context, 'box.mix.desc', color: Colors.grey),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
List<Widget> getMixBoxRowList() {
|
|
||||||
return _mixBoxes.asMap().entries.map((b) {
|
|
||||||
return Container(
|
|
||||||
color: Colors.grey[50].withOpacity(0.2),
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
left: 15.0, right: 10.0, top: 13.0, bottom: 13.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border(
|
|
||||||
bottom: BorderSide(
|
|
||||||
color: b.key == _mixBoxes.length - 1
|
|
||||||
? Colors.white
|
|
||||||
: Colors.grey[350],
|
|
||||||
width: 1),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: new Text(
|
|
||||||
b.value.packageNumber,
|
|
||||||
style: textStyle,
|
|
||||||
)),
|
|
||||||
new Text(
|
|
||||||
b.value.desc == null ? "" : b.value.desc,
|
|
||||||
style: textStyle,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
final cargoTitle = Container(
|
|
||||||
padding: EdgeInsets.only(left: 15, right: 0.0, top: 20),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: LocalText(context, 'cargo.type', color: Colors.grey),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.only(right: 10),
|
|
||||||
child: LocalText(context, 'cargo.weight', color: Colors.grey)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
List<Widget> getCargoRowList() {
|
|
||||||
if (_cargoTypes == null) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
double total = 0;
|
|
||||||
|
|
||||||
var rows = _cargoTypes.asMap().entries.map((c) {
|
|
||||||
total += c.value.weight;
|
|
||||||
return InkWell(
|
|
||||||
onTap: () {},
|
|
||||||
child: Container(
|
|
||||||
color: Colors.grey[50].withOpacity(0.2),
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
left: 15.0, right: 10.0, top: 13.0, bottom: 13.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border(
|
|
||||||
bottom: BorderSide(color: Colors.grey[350], width: 1),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: new Text(
|
|
||||||
c.value.name,
|
|
||||||
style: textStyle,
|
|
||||||
)),
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.only(right: 10),
|
|
||||||
child: new Text(
|
|
||||||
c.value.weight == null ? "0" : c.value.weight.toString(),
|
|
||||||
style: textStyle,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
var totalRow = InkWell(
|
|
||||||
child: Container(
|
|
||||||
color: Colors.grey[50].withOpacity(0.2),
|
|
||||||
child: Container(
|
|
||||||
padding:
|
|
||||||
EdgeInsets.only(left: 15.0, right: 10.0, top: 15.0, bottom: 15.0),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: new Text(
|
|
||||||
"Total Weight",
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
)),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: new Text(
|
|
||||||
total.toString(),
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
|
|
||||||
rows.add(totalRow);
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
final lengthBox = LengthPicker(
|
final lengthBox = LengthPicker(
|
||||||
controller: _lengthController,
|
controller: _lengthController,
|
||||||
lableKey: "box.length",
|
lableKey: "box.length",
|
||||||
@@ -436,6 +219,15 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
|||||||
labelTextKey: "box.shipment_weight",
|
labelTextKey: "box.shipment_weight",
|
||||||
iconData: MaterialCommunityIcons.weight,
|
iconData: MaterialCommunityIcons.weight,
|
||||||
);
|
);
|
||||||
|
final mixCartonNumberBox = DisplayText(
|
||||||
|
text: _box.mixCartonNumber,
|
||||||
|
labelTextKey: "box.mix.carton",
|
||||||
|
iconData: MaterialCommunityIcons.package,
|
||||||
|
);
|
||||||
|
final deliverBtn = LocalButton(
|
||||||
|
textKey: "delivery.deliver.btn",
|
||||||
|
callBack: _deliver,
|
||||||
|
);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
@@ -454,83 +246,38 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
|||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
// actions: <Widget>[
|
|
||||||
// IconButton(
|
|
||||||
// icon: Icon(Icons.edit, color: primaryColor),
|
|
||||||
// onPressed: _gotoEditor,
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: ListView(children: <Widget>[
|
child: ListView(children: <Widget>[
|
||||||
Center(child: getCartonNumberStatus(context, _box)),
|
Center(child: getCartonNumberStatus(context, _box)),
|
||||||
LocalTitle(textKey: "box.type.title"),
|
LocalTitle(textKey: "box.type.title"),
|
||||||
cargoType,
|
cartonTypeBox,
|
||||||
LocalTitle(textKey: "box.shipment_info"),
|
LocalTitle(textKey: "box.shipment_info"),
|
||||||
shipmentBox,
|
shipmentBox,
|
||||||
fcsIDBox,
|
isSmallBag ? mixCartonNumberBox : Container(),
|
||||||
customerNameBox,
|
isMixBox ? Container() : fcsIDBox,
|
||||||
_selectedCartonType == "From packages"
|
isMixBox ? Container() : customerNameBox,
|
||||||
? Column(
|
isFromPackages || isSmallBag
|
||||||
children: [
|
? CartonPackageTable(
|
||||||
LocalTitle(textKey: "box.packages"),
|
packages: _box.packages,
|
||||||
packageTitle,
|
|
||||||
Divider(
|
|
||||||
color: Colors.grey[400],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: getPackageRowList(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
: _selectedCartonType == "From shipments"
|
: Container(),
|
||||||
? Column(
|
isMixBox
|
||||||
children: [
|
? Container()
|
||||||
LocalTitle(textKey: "box.shipment.boxes"),
|
: LocalTitle(textKey: "box.delivery_address"),
|
||||||
shipmentBoxTitle,
|
isMixBox
|
||||||
Divider(
|
? Container()
|
||||||
color: Colors.grey[400],
|
: DefaultDeliveryAddress(
|
||||||
),
|
deliveryAddress: _deliveryAddress,
|
||||||
shipmentBoxRow
|
labelKey: "box.delivery_address",
|
||||||
],
|
),
|
||||||
)
|
SizedBox(
|
||||||
: _selectedCartonType == "Mix carton"
|
height: 20,
|
||||||
? Column(
|
|
||||||
children: [
|
|
||||||
LocalTitle(textKey: "box.shipment.boxes"),
|
|
||||||
mixBoxTitle,
|
|
||||||
Divider(
|
|
||||||
color: Colors.grey[400],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: getMixBoxRowList(),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: Container(),
|
|
||||||
LocalTitle(textKey: "box.cargo_type"),
|
|
||||||
cargoTitle,
|
|
||||||
Divider(
|
|
||||||
color: Colors.grey[400],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: getCargoRowList(),
|
|
||||||
),
|
|
||||||
LocalTitle(textKey: "box.dimension"),
|
|
||||||
dimBox,
|
|
||||||
shipmentWeightBox,
|
|
||||||
LocalTitle(textKey: "box.delivery_address"),
|
|
||||||
DefaultDeliveryAddress(
|
|
||||||
deliveryAddress: _deliveryAddress,
|
|
||||||
labelKey: "box.delivery_address",
|
|
||||||
),
|
|
||||||
LocalTitle(textKey: "box.status"),
|
|
||||||
Container(
|
|
||||||
height: 230,
|
|
||||||
child: Timeline(
|
|
||||||
children: _models(), position: TimelinePosition.Left),
|
|
||||||
),
|
),
|
||||||
|
!isMixBox && _box.status == carton_shipped_status
|
||||||
|
? deliverBtn
|
||||||
|
: Container(),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
)
|
)
|
||||||
@@ -540,5 +287,26 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_gotoEditor() async {}
|
_deliver() {
|
||||||
|
showConfirmDialog(context, "delivery.deliver.confirm", () {
|
||||||
|
_deliverCarton();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_deliverCarton() async {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
var deliveryModel = Provider.of<DeliveryModel>(context, listen: false);
|
||||||
|
await deliveryModel.deliver(widget.box);
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,295 +1,24 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:fcs/data/services/services.dart';
|
||||||
import 'package:fcs/domain/constants.dart';
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/carton.dart';
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
|
||||||
import 'package:fcs/domain/entities/package.dart';
|
|
||||||
import 'package:fcs/domain/vo/message.dart';
|
import 'package:fcs/domain/vo/message.dart';
|
||||||
import 'package:fcs/domain/vo/shipment_status.dart';
|
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
|
||||||
import 'package:fcs/helpers/paginator.dart';
|
import 'package:fcs/helpers/paginator.dart';
|
||||||
import 'package:fcs/pages/main/model/base_model.dart';
|
import 'package:fcs/pages/main/model/base_model.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
class DeliveryModel extends BaseModel {
|
class DeliveryModel extends BaseModel {
|
||||||
List<Carton> _cartons = [];
|
final log = Logger('DeliveryModel');
|
||||||
final log = Logger('BoxModel');
|
|
||||||
List<Carton> get cartons =>
|
List<Carton> get cartons =>
|
||||||
_selectedIndex == 1 ? _cartons : List<Carton>.from(_delivered.values);
|
_selectedIndex == 1 ? _cartons : List<Carton>.from(_delivered.values);
|
||||||
|
|
||||||
Paginator _delivered;
|
Paginator _delivered;
|
||||||
int _selectedIndex = 1;
|
int _selectedIndex = 1;
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
|
List<Carton> _cartons = [];
|
||||||
StreamSubscription<QuerySnapshot> listener;
|
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<Carton> cartonList = [
|
|
||||||
Carton(
|
|
||||||
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",
|
|
||||||
desc: "Desc 1",
|
|
||||||
cartonType: carton_from_packages,
|
|
||||||
arrivedDate: DateTime(2020, 6, 1),
|
|
||||||
width: 10,
|
|
||||||
height: 10,
|
|
||||||
length: 10,
|
|
||||||
shipmentWeight: 6,
|
|
||||||
packages: packages,
|
|
||||||
shipmentHistory: statusHistory,
|
|
||||||
deliveryAddress: DeliveryAddress(
|
|
||||||
fullName: 'U Nyi Nyi',
|
|
||||||
addressLine1: '154-19 64th Ave.',
|
|
||||||
addressLine2: 'Flushing',
|
|
||||||
city: 'NY',
|
|
||||||
state: 'NY',
|
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous', weight: 30)
|
|
||||||
]),
|
|
||||||
Carton(
|
|
||||||
shipmentNumber: "A203",
|
|
||||||
receiverNumber: "3",
|
|
||||||
receiverName: "Ko Myo Min",
|
|
||||||
boxNumber: "2",
|
|
||||||
rate: 7,
|
|
||||||
packageType: "General",
|
|
||||||
weight: 75,
|
|
||||||
status: "Packed",
|
|
||||||
cargoDesc: "Clothes",
|
|
||||||
desc: "Desc 2",
|
|
||||||
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',
|
|
||||||
cartonType: carton_from_shipments,
|
|
||||||
deliveryAddress: DeliveryAddress(
|
|
||||||
fullName: 'Mg Myo',
|
|
||||||
addressLine1: '153-154 5th Thitsar.',
|
|
||||||
addressLine2: 'South Okkalapa Township',
|
|
||||||
city: 'Yangon',
|
|
||||||
state: 'Myanmar',
|
|
||||||
phoneNumber: '+09 95724 8750'),
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous', weight: 30)
|
|
||||||
]),
|
|
||||||
Carton(
|
|
||||||
shipmentNumber: "A204",
|
|
||||||
receiverNumber: "3",
|
|
||||||
receiverName: "Ko Myo Min",
|
|
||||||
boxNumber: "3",
|
|
||||||
rate: 7,
|
|
||||||
packageType: "General",
|
|
||||||
weight: 75,
|
|
||||||
cargoDesc: "Shoes",
|
|
||||||
status: "Packed",
|
|
||||||
desc: "Desc 3",
|
|
||||||
cartonType: carton_mix_box,
|
|
||||||
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',
|
|
||||||
deliveryAddress: DeliveryAddress(
|
|
||||||
fullName: 'Mg Myo',
|
|
||||||
addressLine1: '153-154 5th Thitsar.',
|
|
||||||
addressLine2: 'South Okkalapa Township',
|
|
||||||
city: 'Yangon',
|
|
||||||
state: 'Myanmar',
|
|
||||||
phoneNumber: '+09 95724 8750'),
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous', weight: 30)
|
|
||||||
]),
|
|
||||||
Carton(
|
|
||||||
shipmentNumber: "A202",
|
|
||||||
receiverNumber: "2",
|
|
||||||
receiverName: "Ma Aye",
|
|
||||||
boxNumber: "1",
|
|
||||||
rate: 8,
|
|
||||||
packageType: "Medicine",
|
|
||||||
weight: 75,
|
|
||||||
status: "Packed",
|
|
||||||
cargoDesc: "Dietary supplement",
|
|
||||||
desc: "Desc 4",
|
|
||||||
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',
|
|
||||||
deliveryAddress: DeliveryAddress(
|
|
||||||
fullName: 'U Nyi Nyi',
|
|
||||||
addressLine1: '154-19 64th Ave.',
|
|
||||||
addressLine2: 'Flushing',
|
|
||||||
city: 'NY',
|
|
||||||
state: 'NY',
|
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous', weight: 30)
|
|
||||||
]),
|
|
||||||
Carton(
|
|
||||||
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',
|
|
||||||
deliveryAddress: DeliveryAddress(
|
|
||||||
fullName: 'U Nyi Nyi',
|
|
||||||
addressLine1: '154-19 64th Ave.',
|
|
||||||
addressLine2: 'Flushing',
|
|
||||||
city: 'NY',
|
|
||||||
state: 'NY',
|
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous', weight: 30)
|
|
||||||
]),
|
|
||||||
Carton(
|
|
||||||
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',
|
|
||||||
deliveryAddress: DeliveryAddress(
|
|
||||||
fullName: 'U Nyi Nyi',
|
|
||||||
addressLine1: '154-19 64th Ave.',
|
|
||||||
addressLine2: 'Flushing',
|
|
||||||
city: 'NY',
|
|
||||||
state: 'NY',
|
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous', weight: 30)
|
|
||||||
]),
|
|
||||||
Carton(
|
|
||||||
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',
|
|
||||||
deliveryAddress: DeliveryAddress(
|
|
||||||
fullName: 'U Nyi Nyi',
|
|
||||||
addressLine1: '154-19 64th Ave.',
|
|
||||||
addressLine2: 'Flushing',
|
|
||||||
city: 'NY',
|
|
||||||
state: 'NY',
|
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous', weight: 30)
|
|
||||||
]),
|
|
||||||
Carton(
|
|
||||||
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',
|
|
||||||
deliveryAddress: DeliveryAddress(
|
|
||||||
fullName: 'U Nyi Nyi',
|
|
||||||
addressLine1: '154-19 64th Ave.',
|
|
||||||
addressLine2: 'Flushing',
|
|
||||||
city: 'NY',
|
|
||||||
state: 'NY',
|
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous', weight: 30)
|
|
||||||
]),
|
|
||||||
];
|
|
||||||
|
|
||||||
List<String> cartonTypes = [
|
|
||||||
carton_from_packages,
|
|
||||||
carton_from_shipments,
|
|
||||||
carton_mix_box
|
|
||||||
];
|
|
||||||
|
|
||||||
set selectedIndex(int index) {
|
set selectedIndex(int index) {
|
||||||
_selectedIndex = index;
|
_selectedIndex = index;
|
||||||
@@ -300,37 +29,14 @@ class DeliveryModel extends BaseModel {
|
|||||||
|
|
||||||
initData() {
|
initData() {
|
||||||
_selectedIndex = 1;
|
_selectedIndex = 1;
|
||||||
_loadBoxes();
|
_loadCartons();
|
||||||
|
|
||||||
if (_delivered != null) _delivered.close();
|
if (_delivered != null) _delivered.close();
|
||||||
// _delivered = _getDelivered();
|
_delivered = _getDelivered();
|
||||||
_delivered = _getDeliveredExample();
|
|
||||||
_delivered.load();
|
_delivered.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
Future<void> _loadCartons() async {
|
||||||
Paginator _getDeliveredExample() {
|
|
||||||
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 Carton(
|
|
||||||
id: m.id,
|
|
||||||
shipmentNumber: m.message,
|
|
||||||
boxNumber: "1",
|
|
||||||
receiverNumber: "3",
|
|
||||||
rate: 0,
|
|
||||||
weight: 0,
|
|
||||||
arrivedDate: m.date,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
return paginator;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadBoxes() async {
|
|
||||||
if (user == null || !user.hasDeliveries()) return;
|
if (user == null || !user.hasDeliveries()) return;
|
||||||
String path = "/$cartons_collection/";
|
String path = "/$cartons_collection/";
|
||||||
if (listener != null) listener.cancel();
|
if (listener != null) listener.cancel();
|
||||||
@@ -338,16 +44,24 @@ class DeliveryModel extends BaseModel {
|
|||||||
try {
|
try {
|
||||||
listener = Firestore.instance
|
listener = Firestore.instance
|
||||||
.collection("$path")
|
.collection("$path")
|
||||||
|
.where("status", isEqualTo: carton_shipped_status)
|
||||||
|
.where("carton_type", whereIn: [
|
||||||
|
carton_from_packages,
|
||||||
|
carton_from_shipments,
|
||||||
|
carton_small_bag
|
||||||
|
])
|
||||||
|
.where("is_deleted", isEqualTo: false)
|
||||||
|
.orderBy("carton_number", descending: false)
|
||||||
.snapshots()
|
.snapshots()
|
||||||
.listen((QuerySnapshot snapshot) {
|
.listen((QuerySnapshot snapshot) {
|
||||||
_cartons.clear();
|
_cartons.clear();
|
||||||
_cartons = snapshot.documents.map((documentSnapshot) {
|
_cartons = snapshot.documents.map((documentSnapshot) {
|
||||||
var s = Carton.fromMap(
|
var s = Carton.fromMap(
|
||||||
documentSnapshot.data, documentSnapshot.documentID);
|
documentSnapshot.data, documentSnapshot.documentID);
|
||||||
return s;
|
return s;
|
||||||
}).toList();
|
}).toList();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.warning("Error!! $e");
|
log.warning("Error!! $e");
|
||||||
}
|
}
|
||||||
@@ -359,7 +73,8 @@ class DeliveryModel extends BaseModel {
|
|||||||
var pageQuery = Firestore.instance
|
var pageQuery = Firestore.instance
|
||||||
.collection("/$cartons_collection")
|
.collection("/$cartons_collection")
|
||||||
.where("is_delivered", isEqualTo: true)
|
.where("is_delivered", isEqualTo: true)
|
||||||
.where("is_deleted", isEqualTo: false);
|
.where("status", whereIn: [carton_delivered_status]).where("is_deleted",
|
||||||
|
isEqualTo: false);
|
||||||
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
||||||
return Carton.fromMap(data, id);
|
return Carton.fromMap(data, id);
|
||||||
});
|
});
|
||||||
@@ -367,7 +82,7 @@ class DeliveryModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadMore() async {
|
Future<void> loadMore() async {
|
||||||
if (_delivered.ended) return;
|
if (_delivered.ended || _selectedIndex == 1) return;
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await _delivered.load(onFinished: () {
|
await _delivered.load(onFinished: () {
|
||||||
@@ -377,6 +92,8 @@ class DeliveryModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> refresh() async {
|
Future<void> refresh() async {
|
||||||
|
if (_selectedIndex == 1) return;
|
||||||
|
|
||||||
await _delivered.refresh(onFinished: () {
|
await _delivered.refresh(onFinished: () {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
@@ -392,4 +109,8 @@ class DeliveryModel extends BaseModel {
|
|||||||
if (_delivered != null) _delivered.close();
|
if (_delivered != null) _delivered.close();
|
||||||
_cartons = [];
|
_cartons = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> deliver(Carton carton) {
|
||||||
|
return Services.instance.cartonService.deliver(carton);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class _FcsShipmentListState extends State<FcsShipmentList> {
|
|||||||
selected: shipmentModel.selectedIndex == 1),
|
selected: shipmentModel.selectedIndex == 1),
|
||||||
LocalPopupMenu(
|
LocalPopupMenu(
|
||||||
id: 2,
|
id: 2,
|
||||||
textKey: "FCSshipment.popupmenu.delivered",
|
textKey: "FCSshipment.popupmenu.shipped",
|
||||||
selected: shipmentModel.selectedIndex == 2)
|
selected: shipmentModel.selectedIndex == 2)
|
||||||
],
|
],
|
||||||
popupMenuCallback: (p) => this.setState(() {
|
popupMenuCallback: (p) => this.setState(() {
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ class FcsShipmentModel extends BaseModel {
|
|||||||
List<FcsShipment> _fcsShipments = [];
|
List<FcsShipment> _fcsShipments = [];
|
||||||
List<FcsShipment> get fcsShipments => _selectedIndex == 1
|
List<FcsShipment> get fcsShipments => _selectedIndex == 1
|
||||||
? _fcsShipments
|
? _fcsShipments
|
||||||
: List<FcsShipment>.from(_delivered.values);
|
: List<FcsShipment>.from(_shipped.values);
|
||||||
|
|
||||||
Paginator _delivered;
|
Paginator _shipped;
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
int _selectedIndex = 1;
|
int _selectedIndex = 1;
|
||||||
set selectedIndex(int index) {
|
set selectedIndex(int index) {
|
||||||
@@ -32,16 +32,16 @@ class FcsShipmentModel extends BaseModel {
|
|||||||
super.privilegeChanged();
|
super.privilegeChanged();
|
||||||
_loadFcsShipments();
|
_loadFcsShipments();
|
||||||
|
|
||||||
if (_delivered != null) _delivered.close();
|
if (_shipped != null) _shipped.close();
|
||||||
_delivered = _getDelivered();
|
_shipped = _getShipped();
|
||||||
}
|
}
|
||||||
|
|
||||||
initData() {
|
initData() {
|
||||||
_selectedIndex = 1;
|
_selectedIndex = 1;
|
||||||
_loadFcsShipments();
|
_loadFcsShipments();
|
||||||
|
|
||||||
if (_delivered != null) _delivered.close();
|
if (_shipped != null) _shipped.close();
|
||||||
_delivered = _getDelivered();
|
_shipped = _getShipped();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadFcsShipments() async {
|
Future<void> _loadFcsShipments() async {
|
||||||
@@ -53,6 +53,7 @@ class FcsShipmentModel extends BaseModel {
|
|||||||
listener = Firestore.instance
|
listener = Firestore.instance
|
||||||
.collection("$path")
|
.collection("$path")
|
||||||
.orderBy("shipment_number", descending: true)
|
.orderBy("shipment_number", descending: true)
|
||||||
|
.where("status", isEqualTo: fcs_shipment_confirmed_status)
|
||||||
.snapshots()
|
.snapshots()
|
||||||
.listen((QuerySnapshot snapshot) {
|
.listen((QuerySnapshot snapshot) {
|
||||||
_fcsShipments.clear();
|
_fcsShipments.clear();
|
||||||
@@ -68,12 +69,12 @@ class FcsShipmentModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Paginator _getDelivered() {
|
Paginator _getShipped() {
|
||||||
if (user == null || !user.hasFcsShipments()) return null;
|
if (user == null || !user.hasFcsShipments()) return null;
|
||||||
|
|
||||||
var pageQuery = Firestore.instance
|
var pageQuery = Firestore.instance
|
||||||
.collection("/$fcs_shipment_collection")
|
.collection("/$fcs_shipment_collection")
|
||||||
.where("is_delivered", isEqualTo: true)
|
.where("status", isEqualTo: fcs_shipment_shipped_status)
|
||||||
.where("is_deleted", isEqualTo: false)
|
.where("is_deleted", isEqualTo: false)
|
||||||
.orderBy("status_date", descending: true);
|
.orderBy("status_date", descending: true);
|
||||||
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
||||||
@@ -83,17 +84,18 @@ class FcsShipmentModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadMore() async {
|
Future<void> loadMore() async {
|
||||||
if (_delivered.ended) return;
|
if (_shipped.ended && _selectedIndex == 1) return;
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await _delivered.load(onFinished: () {
|
await _shipped.load(onFinished: () {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> refresh() async {
|
Future<void> refresh() async {
|
||||||
await _delivered.refresh(onFinished: () {
|
if (_selectedIndex == 1) return;
|
||||||
|
await _shipped.refresh(onFinished: () {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -138,7 +140,7 @@ class FcsShipmentModel extends BaseModel {
|
|||||||
@override
|
@override
|
||||||
logout() async {
|
logout() async {
|
||||||
if (listener != null) await listener.cancel();
|
if (listener != null) await listener.cancel();
|
||||||
if (_delivered != null) _delivered.close();
|
if (_shipped != null) _shipped.close();
|
||||||
_fcsShipments = [];
|
_fcsShipments = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class PackageModel extends BaseModel {
|
|||||||
logout();
|
logout();
|
||||||
_menuSelectedIndex = 1;
|
_menuSelectedIndex = 1;
|
||||||
_loadPackages(forCustomer);
|
_loadPackages(forCustomer);
|
||||||
_delivered = _getDeliveredExample(forCustomer);
|
_delivered = _getDelivered(forCustomer);
|
||||||
_delivered.load();
|
_delivered.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,9 +52,8 @@ class PackageModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadMore({bool isCustomer}) async {
|
Future<void> loadMore({bool isCustomer}) async {
|
||||||
if (menuSelectedIndex == 1)
|
if (_delivered.ended || menuSelectedIndex == 1)
|
||||||
return; // when delivered menu is not selected return
|
return; // when delivered menu is not selected return
|
||||||
if (_delivered.ended) return;
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await _delivered.load(onFinished: () {
|
await _delivered.load(onFinished: () {
|
||||||
@@ -92,24 +91,6 @@ class PackageModel extends BaseModel {
|
|||||||
return paginator;
|
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 Package(
|
|
||||||
id: m.id,
|
|
||||||
status: package_delivered_status,
|
|
||||||
trackingID: (count++).toString(),
|
|
||||||
market: m.message);
|
|
||||||
});
|
|
||||||
return paginator;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadPackages(bool forCustomer) async {
|
Future<void> _loadPackages(bool forCustomer) async {
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (!forCustomer &&
|
if (!forCustomer &&
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class ShipmentModel extends BaseModel {
|
|||||||
logout();
|
logout();
|
||||||
_menuSelectedIndex = 1;
|
_menuSelectedIndex = 1;
|
||||||
_loadShipments(forCustomer, myPickup);
|
_loadShipments(forCustomer, myPickup);
|
||||||
_delivered = _getDeliveredExample(forCustomer);
|
_delivered = _getDelivered(forCustomer);
|
||||||
_delivered.load();
|
_delivered.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ class ShipmentModel extends BaseModel {
|
|||||||
user.hasProcessing()))) throw "No privilege";
|
user.hasProcessing()))) throw "No privilege";
|
||||||
}
|
}
|
||||||
var pageQuery = Firestore.instance
|
var pageQuery = Firestore.instance
|
||||||
.collection("/$packages_collection")
|
.collection("/$shipments_collection")
|
||||||
.where("is_delivered", isEqualTo: true)
|
.where("is_delivered", isEqualTo: true)
|
||||||
.where("is_deleted", isEqualTo: false);
|
.where("is_deleted", isEqualTo: false);
|
||||||
if (isCustomer) {
|
if (isCustomer) {
|
||||||
@@ -90,35 +90,15 @@ class ShipmentModel extends BaseModel {
|
|||||||
return paginator;
|
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 {
|
Future<void> _loadShipments(bool forCustomer, bool myPickup) async {
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (!forCustomer && !user.hasShipment()) return;
|
if (!forCustomer && !user.hasShipment()) return;
|
||||||
String path = "/$shipments_collection";
|
|
||||||
if (listener != null) listener.cancel();
|
if (listener != null) listener.cancel();
|
||||||
_shipments = [];
|
_shipments = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var q = Firestore.instance
|
var q = Firestore.instance
|
||||||
.collection("$path")
|
.collection("$shipments_collection")
|
||||||
.where("is_delivered", isEqualTo: false)
|
.where("is_delivered", isEqualTo: false)
|
||||||
.where("is_canceled", isEqualTo: false)
|
.where("is_canceled", isEqualTo: false)
|
||||||
.where("is_deleted", isEqualTo: false);
|
.where("is_deleted", isEqualTo: false);
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class _ShipmentListState extends State<ShipmentList> {
|
|||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return ShipmentListRow(
|
return ShipmentListRow(
|
||||||
key: ValueKey(shipmentModel.shipments[index].id),
|
key: ValueKey(shipmentModel.shipments[index].id),
|
||||||
pickUp: shipmentModel.shipments[index],
|
shipment: shipmentModel.shipments[index],
|
||||||
isCustomer: widget.forCustomer,
|
isCustomer: widget.forCustomer,
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import '../main/util.dart';
|
|||||||
import 'shipment_info.dart';
|
import 'shipment_info.dart';
|
||||||
|
|
||||||
class ShipmentListRow extends StatelessWidget {
|
class ShipmentListRow extends StatelessWidget {
|
||||||
final Shipment pickUp;
|
final Shipment shipment;
|
||||||
final bool isCustomer;
|
final bool isCustomer;
|
||||||
const ShipmentListRow({Key key, this.pickUp, this.isCustomer})
|
const ShipmentListRow({Key key, this.shipment, this.isCustomer})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -19,7 +19,7 @@ class ShipmentListRow extends StatelessWidget {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).push(CupertinoPageRoute(
|
Navigator.of(context).push(CupertinoPageRoute(
|
||||||
builder: (context) => ShipmentInfo(
|
builder: (context) => ShipmentInfo(
|
||||||
shipment: pickUp,
|
shipment: shipment,
|
||||||
isCustomer: isCustomer,
|
isCustomer: isCustomer,
|
||||||
)));
|
)));
|
||||||
},
|
},
|
||||||
@@ -45,21 +45,19 @@ class ShipmentListRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
pickUp.shipmentNumber,
|
shipment.shipmentNumber ?? "",
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
// Padding(
|
||||||
padding: const EdgeInsets.only(left: 10.0, top: 3),
|
// padding: const EdgeInsets.only(left: 10.0, top: 3),
|
||||||
child: new Text(
|
// child: new Text(
|
||||||
pickUp.id == null
|
// "Last ${shipment.last ?? 0} days",
|
||||||
? ''
|
// style: new TextStyle(
|
||||||
: "Last ${pickUp.last} days",
|
// fontSize: 15.0, color: Colors.grey),
|
||||||
style: new TextStyle(
|
// ),
|
||||||
fontSize: 15.0, color: Colors.grey),
|
// )
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -71,7 +69,7 @@ class ShipmentListRow extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
child: getStatus(pickUp.status),
|
child: getStatus(shipment.status ?? ""),
|
||||||
),
|
),
|
||||||
// Padding(
|
// Padding(
|
||||||
// padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
// padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
||||||
|
|||||||
Reference in New Issue
Block a user