add delivery
This commit is contained in:
@@ -79,33 +79,10 @@ class CartonModel extends BaseModel {
|
||||
_loadBoxes();
|
||||
|
||||
if (_delivered != null) _delivered.close();
|
||||
// _delivered = _getDelivered();
|
||||
_delivered = _getDeliveredExample();
|
||||
_delivered = _getDelivered();
|
||||
_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 {
|
||||
if (user == null || !user.hasCarton()) return;
|
||||
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/carton.dart';
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.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/delivery/model/delivery_model.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/fcs_id_icon.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_title.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:intl/intl.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");
|
||||
|
||||
@@ -37,7 +40,6 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
bool _isLoading = false;
|
||||
Carton _box;
|
||||
String _selectedCartonType;
|
||||
String _shipmentNumber;
|
||||
List<Package> _packages = [];
|
||||
List<Carton> _mixBoxes = [];
|
||||
Carton _selectedShipmentBox = new Carton();
|
||||
@@ -49,35 +51,17 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
double volumetricRatio = 0;
|
||||
double shipmentWeight = 0;
|
||||
|
||||
bool isMixBox;
|
||||
bool isFromShipments;
|
||||
bool isFromPackages;
|
||||
bool isSmallBag;
|
||||
bool isEdiable;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_box = widget.box;
|
||||
_shipmentNumber = _box.shipmentNumber;
|
||||
_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
|
||||
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||
@@ -87,12 +71,44 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
_widthController.addListener(_calShipmentWeight);
|
||||
_heightController.addListener(_calShipmentWeight);
|
||||
|
||||
_updateBoxData();
|
||||
_loadPackages();
|
||||
}
|
||||
|
||||
_updateBoxData() {
|
||||
_widthController.text = _box.width.toString();
|
||||
_heightController.text = _box.height.toString();
|
||||
_lengthController.text = _box.length.toString();
|
||||
|
||||
_cargoTypes = _box.cargoTypes;
|
||||
_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() {
|
||||
@@ -110,64 +126,18 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
}
|
||||
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
final cargoType = Container(
|
||||
height: 30,
|
||||
padding: EdgeInsets.only(left: 15),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.check_circle, color: primaryColor),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(_selectedCartonType ?? ""),
|
||||
],
|
||||
),
|
||||
);
|
||||
var cartonModel = Provider.of<CartonModel>(context);
|
||||
|
||||
final cartonTypeBox = LocalRadioButtons(
|
||||
readOnly: true,
|
||||
values: cartonModel.cartonTypesInfo,
|
||||
selectedValue:
|
||||
_box.isShipmentCarton ? carton_from_shipments : _box.cartonType);
|
||||
final shipmentBox = DisplayText(
|
||||
text: _shipmentNumber == null ? "" : _shipmentNumber,
|
||||
text: _box.fcsShipmentNumber,
|
||||
labelTextKey: "box.fcs_shipment_num",
|
||||
iconData: Ionicons.ios_airplane,
|
||||
);
|
||||
@@ -183,60 +153,6 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
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(
|
||||
padding: EdgeInsets.only(left: 15, right: 10.0, top: 20),
|
||||
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(
|
||||
controller: _lengthController,
|
||||
lableKey: "box.length",
|
||||
@@ -436,6 +219,15 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
labelTextKey: "box.shipment_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(
|
||||
inAsyncCall: _isLoading,
|
||||
@@ -454,83 +246,38 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
fontSize: 20,
|
||||
color: primaryColor,
|
||||
),
|
||||
// actions: <Widget>[
|
||||
// IconButton(
|
||||
// icon: Icon(Icons.edit, color: primaryColor),
|
||||
// onPressed: _gotoEditor,
|
||||
// ),
|
||||
// ],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(children: <Widget>[
|
||||
Center(child: getCartonNumberStatus(context, _box)),
|
||||
LocalTitle(textKey: "box.type.title"),
|
||||
cargoType,
|
||||
cartonTypeBox,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
shipmentBox,
|
||||
fcsIDBox,
|
||||
customerNameBox,
|
||||
_selectedCartonType == "From packages"
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.packages"),
|
||||
packageTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
Column(
|
||||
children: getPackageRowList(),
|
||||
),
|
||||
],
|
||||
isSmallBag ? mixCartonNumberBox : Container(),
|
||||
isMixBox ? Container() : fcsIDBox,
|
||||
isMixBox ? Container() : customerNameBox,
|
||||
isFromPackages || isSmallBag
|
||||
? CartonPackageTable(
|
||||
packages: _box.packages,
|
||||
)
|
||||
: _selectedCartonType == "From shipments"
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.shipment.boxes"),
|
||||
shipmentBoxTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
shipmentBoxRow
|
||||
],
|
||||
)
|
||||
: _selectedCartonType == "Mix carton"
|
||||
? 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),
|
||||
: Container(),
|
||||
isMixBox
|
||||
? Container()
|
||||
: LocalTitle(textKey: "box.delivery_address"),
|
||||
isMixBox
|
||||
? Container()
|
||||
: DefaultDeliveryAddress(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
labelKey: "box.delivery_address",
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
!isMixBox && _box.status == carton_shipped_status
|
||||
? deliverBtn
|
||||
: Container(),
|
||||
SizedBox(
|
||||
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 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:fcs/data/services/services.dart';
|
||||
import 'package:fcs/domain/constants.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/shipment_status.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
import 'package:fcs/helpers/paginator.dart';
|
||||
import 'package:fcs/pages/main/model/base_model.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
class DeliveryModel extends BaseModel {
|
||||
List<Carton> _cartons = [];
|
||||
final log = Logger('BoxModel');
|
||||
final log = Logger('DeliveryModel');
|
||||
List<Carton> get cartons =>
|
||||
_selectedIndex == 1 ? _cartons : List<Carton>.from(_delivered.values);
|
||||
|
||||
Paginator _delivered;
|
||||
int _selectedIndex = 1;
|
||||
bool isLoading = false;
|
||||
|
||||
List<Carton> _cartons = [];
|
||||
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) {
|
||||
_selectedIndex = index;
|
||||
@@ -300,37 +29,14 @@ class DeliveryModel extends BaseModel {
|
||||
|
||||
initData() {
|
||||
_selectedIndex = 1;
|
||||
_loadBoxes();
|
||||
_loadCartons();
|
||||
|
||||
if (_delivered != null) _delivered.close();
|
||||
// _delivered = _getDelivered();
|
||||
_delivered = _getDeliveredExample();
|
||||
_delivered = _getDelivered();
|
||||
_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> _loadCartons() async {
|
||||
if (user == null || !user.hasDeliveries()) return;
|
||||
String path = "/$cartons_collection/";
|
||||
if (listener != null) listener.cancel();
|
||||
@@ -338,16 +44,24 @@ class DeliveryModel extends BaseModel {
|
||||
try {
|
||||
listener = Firestore.instance
|
||||
.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()
|
||||
.listen((QuerySnapshot snapshot) {
|
||||
_cartons.clear();
|
||||
_cartons = snapshot.documents.map((documentSnapshot) {
|
||||
var s = Carton.fromMap(
|
||||
documentSnapshot.data, documentSnapshot.documentID);
|
||||
return s;
|
||||
}).toList();
|
||||
notifyListeners();
|
||||
});
|
||||
_cartons.clear();
|
||||
_cartons = snapshot.documents.map((documentSnapshot) {
|
||||
var s = Carton.fromMap(
|
||||
documentSnapshot.data, documentSnapshot.documentID);
|
||||
return s;
|
||||
}).toList();
|
||||
notifyListeners();
|
||||
});
|
||||
} catch (e) {
|
||||
log.warning("Error!! $e");
|
||||
}
|
||||
@@ -359,7 +73,8 @@ class DeliveryModel extends BaseModel {
|
||||
var pageQuery = Firestore.instance
|
||||
.collection("/$cartons_collection")
|
||||
.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) {
|
||||
return Carton.fromMap(data, id);
|
||||
});
|
||||
@@ -367,7 +82,7 @@ class DeliveryModel extends BaseModel {
|
||||
}
|
||||
|
||||
Future<void> loadMore() async {
|
||||
if (_delivered.ended) return;
|
||||
if (_delivered.ended || _selectedIndex == 1) return;
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
await _delivered.load(onFinished: () {
|
||||
@@ -377,6 +92,8 @@ class DeliveryModel extends BaseModel {
|
||||
}
|
||||
|
||||
Future<void> refresh() async {
|
||||
if (_selectedIndex == 1) return;
|
||||
|
||||
await _delivered.refresh(onFinished: () {
|
||||
notifyListeners();
|
||||
});
|
||||
@@ -392,4 +109,8 @@ class DeliveryModel extends BaseModel {
|
||||
if (_delivered != null) _delivered.close();
|
||||
_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),
|
||||
LocalPopupMenu(
|
||||
id: 2,
|
||||
textKey: "FCSshipment.popupmenu.delivered",
|
||||
textKey: "FCSshipment.popupmenu.shipped",
|
||||
selected: shipmentModel.selectedIndex == 2)
|
||||
],
|
||||
popupMenuCallback: (p) => this.setState(() {
|
||||
|
||||
@@ -15,9 +15,9 @@ class FcsShipmentModel extends BaseModel {
|
||||
List<FcsShipment> _fcsShipments = [];
|
||||
List<FcsShipment> get fcsShipments => _selectedIndex == 1
|
||||
? _fcsShipments
|
||||
: List<FcsShipment>.from(_delivered.values);
|
||||
: List<FcsShipment>.from(_shipped.values);
|
||||
|
||||
Paginator _delivered;
|
||||
Paginator _shipped;
|
||||
bool isLoading = false;
|
||||
int _selectedIndex = 1;
|
||||
set selectedIndex(int index) {
|
||||
@@ -32,16 +32,16 @@ class FcsShipmentModel extends BaseModel {
|
||||
super.privilegeChanged();
|
||||
_loadFcsShipments();
|
||||
|
||||
if (_delivered != null) _delivered.close();
|
||||
_delivered = _getDelivered();
|
||||
if (_shipped != null) _shipped.close();
|
||||
_shipped = _getShipped();
|
||||
}
|
||||
|
||||
initData() {
|
||||
_selectedIndex = 1;
|
||||
_loadFcsShipments();
|
||||
|
||||
if (_delivered != null) _delivered.close();
|
||||
_delivered = _getDelivered();
|
||||
if (_shipped != null) _shipped.close();
|
||||
_shipped = _getShipped();
|
||||
}
|
||||
|
||||
Future<void> _loadFcsShipments() async {
|
||||
@@ -53,6 +53,7 @@ class FcsShipmentModel extends BaseModel {
|
||||
listener = Firestore.instance
|
||||
.collection("$path")
|
||||
.orderBy("shipment_number", descending: true)
|
||||
.where("status", isEqualTo: fcs_shipment_confirmed_status)
|
||||
.snapshots()
|
||||
.listen((QuerySnapshot snapshot) {
|
||||
_fcsShipments.clear();
|
||||
@@ -68,12 +69,12 @@ class FcsShipmentModel extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
Paginator _getDelivered() {
|
||||
Paginator _getShipped() {
|
||||
if (user == null || !user.hasFcsShipments()) return null;
|
||||
|
||||
var pageQuery = Firestore.instance
|
||||
.collection("/$fcs_shipment_collection")
|
||||
.where("is_delivered", isEqualTo: true)
|
||||
.where("status", isEqualTo: fcs_shipment_shipped_status)
|
||||
.where("is_deleted", isEqualTo: false)
|
||||
.orderBy("status_date", descending: true);
|
||||
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
||||
@@ -83,17 +84,18 @@ class FcsShipmentModel extends BaseModel {
|
||||
}
|
||||
|
||||
Future<void> loadMore() async {
|
||||
if (_delivered.ended) return;
|
||||
if (_shipped.ended && _selectedIndex == 1) return;
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
await _delivered.load(onFinished: () {
|
||||
await _shipped.load(onFinished: () {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> refresh() async {
|
||||
await _delivered.refresh(onFinished: () {
|
||||
if (_selectedIndex == 1) return;
|
||||
await _shipped.refresh(onFinished: () {
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
@@ -138,7 +140,7 @@ class FcsShipmentModel extends BaseModel {
|
||||
@override
|
||||
logout() async {
|
||||
if (listener != null) await listener.cancel();
|
||||
if (_delivered != null) _delivered.close();
|
||||
if (_shipped != null) _shipped.close();
|
||||
_fcsShipments = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class PackageModel extends BaseModel {
|
||||
logout();
|
||||
_menuSelectedIndex = 1;
|
||||
_loadPackages(forCustomer);
|
||||
_delivered = _getDeliveredExample(forCustomer);
|
||||
_delivered = _getDelivered(forCustomer);
|
||||
_delivered.load();
|
||||
}
|
||||
|
||||
@@ -52,9 +52,8 @@ class PackageModel extends BaseModel {
|
||||
}
|
||||
|
||||
Future<void> loadMore({bool isCustomer}) async {
|
||||
if (menuSelectedIndex == 1)
|
||||
if (_delivered.ended || menuSelectedIndex == 1)
|
||||
return; // when delivered menu is not selected return
|
||||
if (_delivered.ended) return;
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
await _delivered.load(onFinished: () {
|
||||
@@ -92,24 +91,6 @@ class PackageModel extends BaseModel {
|
||||
return paginator;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
Paginator _getDeliveredExample(bool onlyFcs) {
|
||||
count = 1;
|
||||
var pageQuery = Firestore.instance
|
||||
.collection(
|
||||
"/users/8OTfsbVvsUOn1SLxy1OrKk7Y_yNKkVoGalPcIlcHnAY/messages")
|
||||
.orderBy("date", descending: true);
|
||||
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
||||
var m = Message.fromMap(data, id);
|
||||
return Package(
|
||||
id: m.id,
|
||||
status: package_delivered_status,
|
||||
trackingID: (count++).toString(),
|
||||
market: m.message);
|
||||
});
|
||||
return paginator;
|
||||
}
|
||||
|
||||
Future<void> _loadPackages(bool forCustomer) async {
|
||||
if (user == null) return;
|
||||
if (!forCustomer &&
|
||||
|
||||
@@ -38,7 +38,7 @@ class ShipmentModel extends BaseModel {
|
||||
logout();
|
||||
_menuSelectedIndex = 1;
|
||||
_loadShipments(forCustomer, myPickup);
|
||||
_delivered = _getDeliveredExample(forCustomer);
|
||||
_delivered = _getDelivered(forCustomer);
|
||||
_delivered.load();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class ShipmentModel extends BaseModel {
|
||||
user.hasProcessing()))) throw "No privilege";
|
||||
}
|
||||
var pageQuery = Firestore.instance
|
||||
.collection("/$packages_collection")
|
||||
.collection("/$shipments_collection")
|
||||
.where("is_delivered", isEqualTo: true)
|
||||
.where("is_deleted", isEqualTo: false);
|
||||
if (isCustomer) {
|
||||
@@ -90,35 +90,15 @@ class ShipmentModel extends BaseModel {
|
||||
return paginator;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
Paginator _getDeliveredExample(bool onlyFcs) {
|
||||
count = 1;
|
||||
var pageQuery = Firestore.instance
|
||||
.collection(
|
||||
"/users/8OTfsbVvsUOn1SLxy1OrKk7Y_yNKkVoGalPcIlcHnAY/messages")
|
||||
.orderBy("date", descending: true);
|
||||
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
||||
var m = Message.fromMap(data, id);
|
||||
return Shipment(
|
||||
id: m.id,
|
||||
shipmentNumber: m.message,
|
||||
status: m.senderName,
|
||||
pickupDate: m.date,
|
||||
);
|
||||
});
|
||||
return paginator;
|
||||
}
|
||||
|
||||
Future<void> _loadShipments(bool forCustomer, bool myPickup) async {
|
||||
if (user == null) return;
|
||||
if (!forCustomer && !user.hasShipment()) return;
|
||||
String path = "/$shipments_collection";
|
||||
if (listener != null) listener.cancel();
|
||||
_shipments = [];
|
||||
|
||||
try {
|
||||
var q = Firestore.instance
|
||||
.collection("$path")
|
||||
.collection("$shipments_collection")
|
||||
.where("is_delivered", isEqualTo: false)
|
||||
.where("is_canceled", isEqualTo: false)
|
||||
.where("is_deleted", isEqualTo: false);
|
||||
|
||||
@@ -128,7 +128,7 @@ class _ShipmentListState extends State<ShipmentList> {
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ShipmentListRow(
|
||||
key: ValueKey(shipmentModel.shipments[index].id),
|
||||
pickUp: shipmentModel.shipments[index],
|
||||
shipment: shipmentModel.shipments[index],
|
||||
isCustomer: widget.forCustomer,
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -8,9 +8,9 @@ import '../main/util.dart';
|
||||
import 'shipment_info.dart';
|
||||
|
||||
class ShipmentListRow extends StatelessWidget {
|
||||
final Shipment pickUp;
|
||||
final Shipment shipment;
|
||||
final bool isCustomer;
|
||||
const ShipmentListRow({Key key, this.pickUp, this.isCustomer})
|
||||
const ShipmentListRow({Key key, this.shipment, this.isCustomer})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -19,7 +19,7 @@ class ShipmentListRow extends StatelessWidget {
|
||||
onTap: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => ShipmentInfo(
|
||||
shipment: pickUp,
|
||||
shipment: shipment,
|
||||
isCustomer: isCustomer,
|
||||
)));
|
||||
},
|
||||
@@ -45,21 +45,19 @@ class ShipmentListRow extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
pickUp.shipmentNumber,
|
||||
shipment.shipmentNumber ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, top: 3),
|
||||
child: new Text(
|
||||
pickUp.id == null
|
||||
? ''
|
||||
: "Last ${pickUp.last} days",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
)
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 10.0, top: 3),
|
||||
// child: new Text(
|
||||
// "Last ${shipment.last ?? 0} days",
|
||||
// style: new TextStyle(
|
||||
// fontSize: 15.0, color: Colors.grey),
|
||||
// ),
|
||||
// )
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -71,7 +69,7 @@ class ShipmentListRow extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: getStatus(pickUp.status),
|
||||
child: getStatus(shipment.status ?? ""),
|
||||
),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
||||
|
||||
Reference in New Issue
Block a user