update processing
This commit is contained in:
@@ -1,12 +1,8 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/entities/processing.dart';
|
||||
import 'package:fcs/domain/entities/user.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/carton/carton_package_table.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||
@@ -50,13 +46,6 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
name: processing.shipperName,
|
||||
phoneNumber: processing.shipperPhoneNumber);
|
||||
packages = processing.packages;
|
||||
} else {
|
||||
packages = [
|
||||
Package(trackingID: "REC 4", market: "New Market"),
|
||||
Package(trackingID: "REC 3", market: "Macy"),
|
||||
Package(trackingID: "REC 2", market: "New Market"),
|
||||
Package(trackingID: "REC 1", market: "New Market")
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,10 +146,12 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
Navigator.push(
|
||||
Package _package = await Navigator.push<Package>(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => PackageEditor()),
|
||||
);
|
||||
_addPackage(_package);
|
||||
// _savePackage(_package);
|
||||
}),
|
||||
],
|
||||
),
|
||||
@@ -172,12 +163,6 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
callack: _save,
|
||||
);
|
||||
|
||||
final updateButton = fcsButton(
|
||||
context,
|
||||
getLocalString(context, 'processing.edit.complete.btn'),
|
||||
callack: _save,
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
@@ -219,7 +204,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
_isNew ? createButton : updateButton,
|
||||
createButton,
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
@@ -238,9 +223,14 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => PackageEditor(package: p)));
|
||||
onTap: () async {
|
||||
Package _package = await Navigator.of(context).push<Package>(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => PackageEditor(package: p)));
|
||||
// setState(() {
|
||||
// _savePackage(_package);
|
||||
// });
|
||||
_savePackage(_package);
|
||||
},
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
@@ -276,7 +266,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.remove, color: primaryColor),
|
||||
onPressed: () => _remove(p),
|
||||
onPressed: () => _removePackage(p),
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -289,30 +279,22 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
_remove(Package package) {
|
||||
if (package == null) {
|
||||
showMsgDialog(context, "Esrror", "Invalid package!");
|
||||
return;
|
||||
}
|
||||
showConfirmDialog(context, "processing.package.delete_confirm",
|
||||
() => _removePackage(package));
|
||||
_addPackage(Package package) {
|
||||
if (package == null) return;
|
||||
|
||||
this.packages.add(package);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_removePackage(Package package) async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
ProcessingModel processingModel =
|
||||
Provider.of<ProcessingModel>(context, listen: false);
|
||||
try {
|
||||
await processingModel.deletePackage(package.id);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
_savePackage(Package package) {
|
||||
if (package == null) return;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_removePackage(Package package) {
|
||||
if (package == null) return;
|
||||
this.packages.removeWhere((p) => p.trackingID == package.trackingID);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_save() async {
|
||||
|
||||
Reference in New Issue
Block a user