2020-10-11 02:17:23 +06:30
|
|
|
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/package/package_editor.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/display_text.dart';
|
2020-10-14 01:51:53 +06:30
|
|
|
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
2020-10-11 02:17:23 +06:30
|
|
|
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';
|
2020-10-14 13:54:42 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-10-11 02:17:23 +06:30
|
|
|
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';
|
|
|
|
|
|
2020-10-12 03:34:05 +06:30
|
|
|
import 'receiving_editor.dart';
|
|
|
|
|
|
2020-10-11 02:17:23 +06:30
|
|
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
|
|
|
|
|
|
|
|
|
class ReceivingInfo extends StatefulWidget {
|
|
|
|
|
final Package package;
|
|
|
|
|
ReceivingInfo({this.package});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ReceivingInfoState createState() => _ReceivingInfoState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ReceivingInfoState extends State<ReceivingInfo> {
|
|
|
|
|
Package _package;
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
MultiImgController multiImgController = MultiImgController();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
initPackage(widget.package);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initPackage(Package package) {
|
2020-10-12 03:34:05 +06:30
|
|
|
multiImgController.setImageUrls = package.photoUrls;
|
2020-10-11 02:17:23 +06:30
|
|
|
setState(() {
|
|
|
|
|
_package = package;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
bool isCustomer = Provider.of<MainModel>(context).isCustomer();
|
|
|
|
|
|
|
|
|
|
final trackingIdBox = DisplayText(
|
|
|
|
|
text: _package.trackingID,
|
|
|
|
|
labelTextKey: "package.tracking.id",
|
|
|
|
|
iconData: MaterialCommunityIcons.barcode_scan,
|
|
|
|
|
);
|
2020-10-14 01:51:53 +06:30
|
|
|
var fcsIDBox = DisplayText(
|
|
|
|
|
text: _package.fcsID,
|
|
|
|
|
labelTextKey: "processing.fcs.id",
|
|
|
|
|
icon: FcsIDIcon(),
|
|
|
|
|
);
|
2020-10-11 02:17:23 +06:30
|
|
|
final customerNameBox = DisplayText(
|
|
|
|
|
text: _package.userName,
|
|
|
|
|
labelTextKey: "package.create.name",
|
|
|
|
|
iconData: Icons.perm_identity,
|
|
|
|
|
);
|
|
|
|
|
final remarkBox = DisplayText(
|
|
|
|
|
text: _package.remark ?? "-",
|
|
|
|
|
labelTextKey: "package.edit.remark",
|
|
|
|
|
iconData: Entypo.new_message,
|
|
|
|
|
);
|
|
|
|
|
final img = MultiImageFile(
|
|
|
|
|
enabled: false,
|
|
|
|
|
controller: multiImgController,
|
|
|
|
|
title: "Receipt File",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
leading: new IconButton(
|
2020-10-14 13:54:42 +06:30
|
|
|
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
2020-10-11 02:17:23 +06:30
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
|
|
|
|
shadowColor: Colors.transparent,
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
title: LocalText(
|
|
|
|
|
context,
|
2020-10-12 03:34:05 +06:30
|
|
|
"receiving.info",
|
2020-10-11 02:17:23 +06:30
|
|
|
fontSize: 20,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
2020-10-12 03:34:05 +06:30
|
|
|
actions: isCustomer
|
|
|
|
|
? null
|
|
|
|
|
: <Widget>[
|
|
|
|
|
IconButton(
|
2020-10-11 02:17:23 +06:30
|
|
|
icon: Icon(Icons.delete, color: primaryColor),
|
|
|
|
|
onPressed: _delete,
|
2020-10-12 03:34:05 +06:30
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.edit, color: primaryColor),
|
|
|
|
|
onPressed: _edit,
|
2020-10-11 02:17:23 +06:30
|
|
|
)
|
2020-10-12 03:34:05 +06:30
|
|
|
],
|
2020-10-11 02:17:23 +06:30
|
|
|
),
|
|
|
|
|
body: Card(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(10.0),
|
|
|
|
|
child: ListView(children: <Widget>[
|
|
|
|
|
trackingIdBox,
|
2020-10-14 01:51:53 +06:30
|
|
|
fcsIDBox,
|
|
|
|
|
customerNameBox,
|
2020-10-11 02:17:23 +06:30
|
|
|
remarkBox,
|
2020-10-14 01:51:53 +06:30
|
|
|
_package.photoUrls.length == 0 ? Container() : img,
|
2020-10-12 03:34:05 +06:30
|
|
|
StatusTree(
|
|
|
|
|
shipmentHistory: _package.shipmentHistory,
|
|
|
|
|
currentStatus: _package.currentStatus),
|
2020-10-11 02:17:23 +06:30
|
|
|
SizedBox(
|
|
|
|
|
height: 20,
|
|
|
|
|
)
|
|
|
|
|
]),
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-12 03:34:05 +06:30
|
|
|
_edit() async {
|
|
|
|
|
await Navigator.push(
|
|
|
|
|
context,
|
2020-10-14 13:54:42 +06:30
|
|
|
CupertinoPageRoute(
|
|
|
|
|
builder: (context) => ReceivingEditor(
|
|
|
|
|
package: widget.package,
|
|
|
|
|
)),
|
2020-10-12 03:34:05 +06:30
|
|
|
);
|
|
|
|
|
PackageModel packageModel =
|
|
|
|
|
Provider.of<PackageModel>(context, listen: false);
|
|
|
|
|
var pkg = await packageModel.getPackage(widget.package.id);
|
|
|
|
|
initPackage(pkg);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-11 02:17:23 +06:30
|
|
|
_delete() {
|
|
|
|
|
showConfirmDialog(context, "receiving.delete.confirm", _deleteReceiving);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_deleteReceiving() async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
try {
|
|
|
|
|
PackageModel packageModel =
|
|
|
|
|
Provider.of<PackageModel>(context, listen: false);
|
2020-10-12 03:34:05 +06:30
|
|
|
await packageModel.deleteReceiving(_package);
|
2020-10-11 02:17:23 +06:30
|
|
|
Navigator.pop(context);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|