add packages, receiving & processing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
@@ -8,6 +9,7 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
||||
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';
|
||||
import 'package:fcs/pages/widgets/status_tree.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@@ -53,8 +55,6 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool isCustomer = Provider.of<MainModel>(context).isCustomer();
|
||||
|
||||
final trackingIdBox = DisplayText(
|
||||
text: _package.trackingID,
|
||||
labelTextKey: "processing.tracking.id",
|
||||
@@ -65,11 +65,6 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
||||
labelTextKey: "processing.name",
|
||||
iconData: Icons.perm_identity,
|
||||
);
|
||||
final statusBox = DisplayText(
|
||||
text: _package.currentStatus,
|
||||
labelTextKey: "processing.status",
|
||||
iconData: AntDesign.exclamationcircleo,
|
||||
);
|
||||
final marketBox = DisplayText(
|
||||
text: _package.market ?? "-",
|
||||
labelTextKey: "processing.market",
|
||||
@@ -109,12 +104,14 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
||||
color: primaryColor,
|
||||
),
|
||||
actions: <Widget>[
|
||||
isCustomer
|
||||
? Container()
|
||||
: IconButton(
|
||||
icon: Icon(Icons.edit, color: primaryColor),
|
||||
onPressed: _gotoEditor,
|
||||
)
|
||||
IconButton(
|
||||
icon: Icon(Icons.delete, color: primaryColor),
|
||||
onPressed: _delete,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.edit, color: primaryColor),
|
||||
onPressed: _gotoEditor,
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Card(
|
||||
@@ -127,27 +124,12 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
||||
trackingIdBox,
|
||||
customerNameBox,
|
||||
marketBox,
|
||||
statusBox,
|
||||
_package.photoUrls.length == 0 ? Container() : img,
|
||||
descBox,
|
||||
remarkBox,
|
||||
ExpansionTile(
|
||||
initiallyExpanded: true,
|
||||
title: Text(
|
||||
'Status',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 20),
|
||||
height: 400,
|
||||
child: Timeline(
|
||||
children: _models(),
|
||||
position: TimelinePosition.Left),
|
||||
),
|
||||
],
|
||||
),
|
||||
StatusTree(
|
||||
shipmentHistory: _package.shipmentHistory,
|
||||
currentStatus: _package.currentStatus),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
@@ -160,36 +142,26 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
||||
);
|
||||
}
|
||||
|
||||
List<TimelineModel> _models() {
|
||||
if (_package.shipmentHistory == null) return [];
|
||||
return _package.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)),
|
||||
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();
|
||||
_delete() {
|
||||
showConfirmDialog(context, "processing.delete.confirm", _deletePackage);
|
||||
}
|
||||
|
||||
_deletePackage() async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
PackageModel packageModel =
|
||||
Provider.of<PackageModel>(context, listen: false);
|
||||
try {
|
||||
await packageModel.deleteProcessing(_package);
|
||||
Navigator.pop<bool>(context, true);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_gotoEditor() async {
|
||||
|
||||
Reference in New Issue
Block a user