2025-03-06 17:59:15 +06:30
|
|
|
import 'package:fcs/domain/entities/fcs_shipment.dart';
|
2020-10-08 16:53:43 +06:30
|
|
|
import 'package:fcs/domain/entities/package.dart';
|
|
|
|
|
import 'package:fcs/helpers/theme.dart';
|
2020-10-12 03:34:05 +06:30
|
|
|
import 'package:fcs/pages/main/util.dart';
|
2020-10-08 16:53:43 +06:30
|
|
|
import 'package:fcs/pages/package/model/package_model.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/display_text.dart';
|
2024-01-25 17:40:35 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
2025-03-06 17:59:15 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
2020-10-08 16:53:43 +06:30
|
|
|
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/multi_img_file.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-10-12 03:34:05 +06:30
|
|
|
import 'package:fcs/pages/widgets/status_tree.dart';
|
2020-10-14 13:54:42 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-10-08 16:53:43 +06:30
|
|
|
import 'package:flutter/material.dart';
|
2021-09-10 12:00:08 +06:30
|
|
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
2020-10-08 16:53:43 +06:30
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
2025-03-06 17:59:15 +06:30
|
|
|
import '../fcs_shipment/model/fcs_shipment_model.dart';
|
2020-12-02 20:55:00 +06:30
|
|
|
import 'processing_edit_editor.dart';
|
2020-10-08 16:53:43 +06:30
|
|
|
|
|
|
|
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
|
|
|
|
|
|
|
|
|
class ProcessingInfo extends StatefulWidget {
|
2025-03-06 17:59:15 +06:30
|
|
|
final Package package;
|
|
|
|
|
const ProcessingInfo({super.key, required this.package});
|
2020-10-08 16:53:43 +06:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ProcessingInfoState createState() => _ProcessingInfoState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ProcessingInfoState extends State<ProcessingInfo> {
|
|
|
|
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
2021-09-10 12:00:08 +06:30
|
|
|
Package? _package;
|
2020-10-08 16:53:43 +06:30
|
|
|
bool _isLoading = false;
|
|
|
|
|
MultiImgController multiImgController = MultiImgController();
|
2025-03-06 17:59:15 +06:30
|
|
|
FcsShipment? _shipment;
|
2020-10-08 16:53:43 +06:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
2025-03-06 17:59:15 +06:30
|
|
|
_initPackage(widget.package);
|
2020-10-08 16:53:43 +06:30
|
|
|
}
|
|
|
|
|
|
2025-03-06 17:59:15 +06:30
|
|
|
_initPackage(Package package) {
|
2025-03-21 18:19:52 +06:30
|
|
|
_loadShipment();
|
2020-10-08 16:53:43 +06:30
|
|
|
setState(() {
|
|
|
|
|
_package = package;
|
|
|
|
|
multiImgController.setImageUrls = package.photoUrls;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-06 17:59:15 +06:30
|
|
|
_loadShipment() async {
|
2025-03-21 18:19:52 +06:30
|
|
|
if (widget.package.fcsShipmentId == null) return;
|
2025-03-06 17:59:15 +06:30
|
|
|
var s = await context
|
|
|
|
|
.read<FcsShipmentModel>()
|
2025-03-21 18:19:52 +06:30
|
|
|
.getFcsShipment(widget.package.fcsShipmentId!);
|
2025-03-06 17:59:15 +06:30
|
|
|
_shipment = s;
|
|
|
|
|
if (mounted) {
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-08 16:53:43 +06:30
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final trackingIdBox = DisplayText(
|
2021-09-10 12:00:08 +06:30
|
|
|
text: _package != null ? _package!.trackingID : '',
|
2020-10-08 16:53:43 +06:30
|
|
|
labelTextKey: "processing.tracking.id",
|
|
|
|
|
iconData: MaterialCommunityIcons.barcode_scan,
|
|
|
|
|
);
|
2025-03-06 17:59:15 +06:30
|
|
|
|
2020-10-08 16:53:43 +06:30
|
|
|
final marketBox = DisplayText(
|
2021-09-13 09:53:27 +06:30
|
|
|
text: _package != null ? _package!.market : "-",
|
2020-10-08 16:53:43 +06:30
|
|
|
labelTextKey: "processing.market",
|
|
|
|
|
iconData: Icons.store,
|
|
|
|
|
);
|
|
|
|
|
final descBox = DisplayText(
|
2021-09-13 09:53:27 +06:30
|
|
|
text: _package != null ? _package!.desc : "-",
|
2020-10-08 16:53:43 +06:30
|
|
|
labelTextKey: "processing.desc",
|
|
|
|
|
iconData: MaterialCommunityIcons.message_text_outline,
|
|
|
|
|
);
|
|
|
|
|
final remarkBox = DisplayText(
|
2021-09-13 09:53:27 +06:30
|
|
|
text: _package != null ? _package!.remark : "-",
|
2020-10-08 16:53:43 +06:30
|
|
|
labelTextKey: "processing.remark",
|
|
|
|
|
iconData: Entypo.new_message,
|
|
|
|
|
);
|
|
|
|
|
final img = MultiImageFile(
|
|
|
|
|
enabled: false,
|
|
|
|
|
controller: multiImgController,
|
|
|
|
|
title: "Receipt File",
|
|
|
|
|
);
|
|
|
|
|
|
2025-03-06 17:59:15 +06:30
|
|
|
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 shipmentBox = Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 15),
|
2021-01-25 16:09:41 +06:30
|
|
|
child: Column(
|
2025-03-06 17:59:15 +06:30
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2021-01-25 16:09:41 +06:30
|
|
|
children: [
|
2025-03-06 17:59:15 +06:30
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
2025-03-21 18:19:52 +06:30
|
|
|
// Flexible(
|
|
|
|
|
// child: DisplayText(
|
|
|
|
|
// text: _shipment != null
|
|
|
|
|
// ? _shipment!.processingDate != null
|
|
|
|
|
// ? dateFormatter.format(_shipment!.processingDate!)
|
|
|
|
|
// : ""
|
|
|
|
|
// : "",
|
|
|
|
|
// labelTextKey: "package.processing.date",
|
|
|
|
|
// iconData: Icons.date_range,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
2025-03-06 17:59:15 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
2021-01-25 16:09:41 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
2025-03-06 17:59:15 +06:30
|
|
|
|
2020-10-08 16:53:43 +06:30
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
2024-01-25 17:40:35 +06:30
|
|
|
appBar: LocalAppBar(
|
|
|
|
|
labelKey: "processing.info.title",
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
labelColor: primaryColor,
|
|
|
|
|
arrowColor: primaryColor,
|
|
|
|
|
actions: [
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.delete, color: primaryColor),
|
|
|
|
|
onPressed: _delete,
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.edit, color: primaryColor),
|
|
|
|
|
onPressed: _gotoEditor,
|
|
|
|
|
),
|
|
|
|
|
]),
|
2020-10-08 16:53:43 +06:30
|
|
|
body: Card(
|
2024-01-25 17:40:35 +06:30
|
|
|
elevation: 0,
|
2025-03-06 17:59:15 +06:30
|
|
|
child:
|
|
|
|
|
ListView(padding: const EdgeInsets.all(10.0), children: <Widget>[
|
|
|
|
|
trackingIdBox,
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Flexible(child: consigneeBox),
|
|
|
|
|
Flexible(
|
|
|
|
|
child: _package?.senderFCSID != null &&
|
|
|
|
|
_package?.senderFCSID != ""
|
|
|
|
|
? senderBox
|
|
|
|
|
: const SizedBox())
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
marketBox,
|
|
|
|
|
descBox,
|
|
|
|
|
remarkBox,
|
|
|
|
|
_package!.photoUrls.isEmpty ? Container() : img,
|
|
|
|
|
shipmentBox,
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 15),
|
|
|
|
|
child: StatusTree(
|
|
|
|
|
shipmentHistory: _package!.shipmentHistory,
|
|
|
|
|
currentStatus: _package!.status ?? ""),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 20)
|
|
|
|
|
]),
|
2020-10-08 16:53:43 +06:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-12 03:34:05 +06:30
|
|
|
_delete() {
|
|
|
|
|
showConfirmDialog(context, "processing.delete.confirm", _deletePackage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_deletePackage() async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
PackageModel packageModel =
|
|
|
|
|
Provider.of<PackageModel>(context, listen: false);
|
|
|
|
|
try {
|
2021-09-10 12:00:08 +06:30
|
|
|
await packageModel.deleteProcessing(_package!);
|
2020-10-12 03:34:05 +06:30
|
|
|
Navigator.pop<bool>(context, true);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-10-08 16:53:43 +06:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_gotoEditor() async {
|
2025-03-06 17:59:15 +06:30
|
|
|
if (_package == null) return;
|
2025-03-21 18:19:52 +06:30
|
|
|
bool? updated = await Navigator.push<bool>(
|
2020-10-08 16:53:43 +06:30
|
|
|
context,
|
2020-10-14 13:54:42 +06:30
|
|
|
CupertinoPageRoute(
|
2025-03-06 17:59:15 +06:30
|
|
|
builder: (context) => ProcessingEditEditor(package: _package!)));
|
2025-03-21 18:19:52 +06:30
|
|
|
if (updated ?? false) {
|
2020-10-08 16:53:43 +06:30
|
|
|
PackageModel packageModel =
|
|
|
|
|
Provider.of<PackageModel>(context, listen: false);
|
2021-09-10 16:48:21 +06:30
|
|
|
Package? p = await packageModel.getPackage(_package!.id!);
|
2024-01-25 17:40:35 +06:30
|
|
|
if (p == null) return;
|
2025-03-06 17:59:15 +06:30
|
|
|
_initPackage(p);
|
2020-10-08 16:53:43 +06:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|