add shipment in processing, update package, processing and receiving
This commit is contained in:
@@ -163,33 +163,28 @@ class PackageModel extends BaseModel {
|
||||
|
||||
try {
|
||||
var qsnap = await FirebaseFirestore.instance
|
||||
.collection("$path")
|
||||
.collection(path)
|
||||
.where("tracking_id", isEqualTo: trackingID)
|
||||
.where("has_user_id", isEqualTo: false)
|
||||
.where("is_deleted", isEqualTo: false)
|
||||
.get(const GetOptions(source: Source.server));
|
||||
if (qsnap.docs.length > 0) {
|
||||
var snap = qsnap.docs[0];
|
||||
if (snap.exists) {
|
||||
var package =
|
||||
Package.fromMap(snap.data as Map<String, dynamic>, snap.id);
|
||||
return package;
|
||||
}
|
||||
|
||||
if (qsnap.docs.isNotEmpty) {
|
||||
var snap = qsnap.docs.first;
|
||||
var package = Package.fromMap(snap.data(), snap.id);
|
||||
return package;
|
||||
}
|
||||
|
||||
qsnap = await FirebaseFirestore.instance
|
||||
.collection("$path")
|
||||
.collection(path)
|
||||
.where("tracking_id", isEqualTo: trackingID)
|
||||
.where("user_id", isEqualTo: user!.id)
|
||||
.where("is_deleted", isEqualTo: false)
|
||||
.get(const GetOptions(source: Source.server));
|
||||
if (qsnap.docs.length > 0) {
|
||||
var snap = qsnap.docs[0];
|
||||
if (snap.exists) {
|
||||
var package =
|
||||
Package.fromMap(snap.data as Map<String, dynamic>, snap.id);
|
||||
return package;
|
||||
}
|
||||
if (qsnap.docs.isNotEmpty) {
|
||||
var snap = qsnap.docs.first;
|
||||
var package = Package.fromMap(snap.data(), snap.id);
|
||||
return package;
|
||||
}
|
||||
} catch (e) {
|
||||
log.warning("Error!! $e");
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:fcs/pages/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
||||
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||
import 'package:fcs/pages/widgets/local_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
||||
@@ -22,15 +21,19 @@ import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||
import '../../domain/entities/fcs_shipment.dart';
|
||||
import '../fcs_shipment/model/fcs_shipment_model.dart';
|
||||
|
||||
class PackageInfo extends StatefulWidget {
|
||||
final isCustomer;
|
||||
final isSearchResult;
|
||||
final Package? package;
|
||||
final bool isCustomer;
|
||||
final bool isSearchResult;
|
||||
final Package package;
|
||||
|
||||
PackageInfo(
|
||||
{this.package, this.isSearchResult = false, this.isCustomer = false});
|
||||
const PackageInfo(
|
||||
{super.key,
|
||||
required this.package,
|
||||
this.isSearchResult = false,
|
||||
this.isCustomer = false});
|
||||
|
||||
@override
|
||||
_PackageInfoState createState() => _PackageInfoState();
|
||||
@@ -41,14 +44,16 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
Package? _package = Package();
|
||||
bool _isLoading = false;
|
||||
MultiImgController multiImgController = MultiImgController();
|
||||
FcsShipment? _shipment;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
initPackage(widget.package!);
|
||||
_initPackage(widget.package);
|
||||
_loadShipment();
|
||||
}
|
||||
|
||||
initPackage(Package? pkg) async {
|
||||
_initPackage(Package? pkg) async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
@@ -64,6 +69,17 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
});
|
||||
}
|
||||
|
||||
_loadShipment() async {
|
||||
if (widget.package.shipmentId == null) return;
|
||||
var s = await context
|
||||
.read<FcsShipmentModel>()
|
||||
.getFcsShipment(widget.package.shipmentId!);
|
||||
_shipment = s;
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
@@ -83,41 +99,51 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
labelTextKey: "package.tracking.id",
|
||||
iconData: MaterialCommunityIcons.barcode_scan,
|
||||
);
|
||||
var fcsIDBox = DisplayText(
|
||||
text: _package?.fcsID ?? "",
|
||||
labelTextKey: "processing.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
);
|
||||
final customerNameBox = DisplayText(
|
||||
text: _package?.userName ?? "",
|
||||
labelTextKey: "package.create.name",
|
||||
iconData: Icons.perm_identity,
|
||||
);
|
||||
|
||||
final consigneeBox = userDisplayBox(context,
|
||||
lableKey: "box.consignee.title",
|
||||
icon: MaterialCommunityIcons.account_arrow_left,
|
||||
name: _package?.userName ?? "",
|
||||
fcsID: _package?.fcsID ?? "");
|
||||
|
||||
final senderBox = userDisplayBox(context,
|
||||
lableKey: "box.sender.title",
|
||||
icon: MaterialCommunityIcons.account_arrow_right,
|
||||
name: _package?.senderName ?? "",
|
||||
fcsID: _package?.senderFCSID ?? "");
|
||||
|
||||
final marketBox = DisplayText(
|
||||
text: _package?.market ?? "-",
|
||||
labelTextKey: "package.create.market",
|
||||
iconData: Icons.store,
|
||||
);
|
||||
|
||||
final descBox = DisplayText(
|
||||
text: _package?.desc ?? "-",
|
||||
labelTextKey: "package.edit.desc",
|
||||
iconData: MaterialCommunityIcons.message_text_outline,
|
||||
);
|
||||
|
||||
final remarkBox = DisplayText(
|
||||
text: _package?.remark ?? "-",
|
||||
labelTextKey: "package.edit.remark",
|
||||
iconData: Entypo.new_message,
|
||||
);
|
||||
|
||||
final img = MultiImageFile(
|
||||
enabled: false,
|
||||
controller: multiImgController,
|
||||
title: "Receipt File",
|
||||
);
|
||||
|
||||
final returnButton = LocalButton(
|
||||
textKey: "receiving.return.btn",
|
||||
callBack: _return,
|
||||
final returnButton = Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: LocalButton(
|
||||
textKey: "receiving.return.btn",
|
||||
callBack: _return,
|
||||
),
|
||||
);
|
||||
|
||||
final deliveryAddressBox = DefaultDeliveryAddress(
|
||||
deliveryAddress: _package!.deliveryAddress,
|
||||
labelKey: "package.delivery.address",
|
||||
@@ -136,13 +162,72 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
: null,
|
||||
);
|
||||
|
||||
final shipmentBox = Padding(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
LocalText(context, "package.shipment.title",
|
||||
color: primaryColor, fontSize: 17, fontWeight: FontWeight.normal),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: DisplayText(
|
||||
text: _shipment?.shipmentNumber ?? '',
|
||||
labelTextKey: "FCSshipment.number",
|
||||
iconData: Ionicons.ios_airplane,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: DisplayText(
|
||||
text: _shipment != null
|
||||
? _shipment!.processingDate != null
|
||||
? dateFormatter.format(_shipment!.processingDate!)
|
||||
: ""
|
||||
: "",
|
||||
labelTextKey: "package.processing.date",
|
||||
iconData: Icons.date_range,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: DisplayText(
|
||||
text: _shipment != null
|
||||
? _shipment!.cutoffDate != null
|
||||
? dateFormatter.format(_shipment!.cutoffDate!)
|
||||
: ""
|
||||
: "",
|
||||
labelTextKey: "FCSshipment.cutoff_date",
|
||||
iconData: Icons.date_range,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: DisplayText(
|
||||
text: _shipment != null
|
||||
? _shipment!.etaDate != null
|
||||
? dateFormatter.format(_shipment!.etaDate!)
|
||||
: ""
|
||||
: "",
|
||||
labelTextKey: "FCSshipment.ETA",
|
||||
iconData: Icons.date_range,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||
leading: IconButton(
|
||||
icon: Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
shadowColor: Colors.transparent,
|
||||
@@ -163,30 +248,34 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(children: <Widget>[
|
||||
trackingIdBox,
|
||||
widget.isSearchResult ? Container() : fcsIDBox,
|
||||
widget.isSearchResult ? Container() : customerNameBox,
|
||||
widget.isSearchResult ? Container() : marketBox,
|
||||
_package == null || _package!.photoUrls.length == 0
|
||||
? Container()
|
||||
: img,
|
||||
Row(
|
||||
children: [
|
||||
Flexible(child: consigneeBox),
|
||||
Flexible(child: senderBox)
|
||||
],
|
||||
),
|
||||
marketBox,
|
||||
widget.isSearchResult ? Container() : descBox,
|
||||
remarkBox,
|
||||
_package?.status == package_received_status &&
|
||||
widget.isCustomer
|
||||
? returnButton
|
||||
: Container(),
|
||||
widget.isSearchResult ? Container() : deliveryAddressBox,
|
||||
widget.isSearchResult
|
||||
_package == null || _package!.photoUrls.isEmpty
|
||||
? Container()
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
child: StatusTree(
|
||||
shipmentHistory: _package!.shipmentHistory,
|
||||
currentStatus: _package!.status),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
padding: const EdgeInsets.only(top: 12), child: img),
|
||||
shipmentBox,
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
child: StatusTree(
|
||||
shipmentHistory: _package!.shipmentHistory,
|
||||
currentStatus: _package!.status),
|
||||
),
|
||||
_package?.status == package_received_status &&
|
||||
widget.isCustomer
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
child: returnButton)
|
||||
: Container(),
|
||||
SizedBox(height: 20)
|
||||
]),
|
||||
)),
|
||||
],
|
||||
|
||||
@@ -33,10 +33,8 @@ class PackageListRow extends StatelessWidget {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => PackageInfo(
|
||||
package: package,
|
||||
isCustomer: isCustomer,
|
||||
)),
|
||||
builder: (context) =>
|
||||
PackageInfo(package: package, isCustomer: isCustomer)),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
|
||||
Reference in New Issue
Block a user