fix shipment detail click in noti

This commit is contained in:
Sai Naw Wun
2020-10-19 14:02:34 +06:30
parent 9187d668ea
commit 4acc1d9465
6 changed files with 50 additions and 5 deletions

View File

@@ -9,7 +9,6 @@ import 'package:fcs/pages/widgets/input_date.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/local_button.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/popupmenu.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -256,7 +255,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
try {
await shipmentModel.update(fcsShipment);
Navigator.pop(context);
Navigator.pop(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {

View File

@@ -43,6 +43,10 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
void initState() {
super.initState();
_fcsShipment = widget.fcsShipment;
_load();
}
_load() {
_shipmentNumberController.text = _fcsShipment.shipmentNumber;
_cutoffDateController.text = dateFormatter.format(_fcsShipment.cutoffDate);
_arrivalDateController.text =
@@ -177,11 +181,19 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
}
_edit() async {
await Navigator.push(
bool updated = await Navigator.push<bool>(
context,
CupertinoPageRoute(
builder: (context) => FcsShipmentEditor(shipment: _fcsShipment)),
);
if (updated) {
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
var f = await shipmentModel.getFcsShipment(_fcsShipment.id);
setState(() {
_fcsShipment = f;
});
_load();
}
}
Widget menuPopWidget(BuildContext context) {

View File

@@ -116,6 +116,21 @@ class FcsShipmentModel extends BaseModel {
return fcsShipments;
}
Future<FcsShipment> getFcsShipment(String id) async {
try {
var snap = await Firestore.instance
.collection("/$fcs_shipment_collection")
.document(id)
.get(source: Source.server);
var fcs = FcsShipment.fromMap(snap.data, snap.documentID);
return fcs;
} catch (e) {
log.warning("Error!! $e");
}
return null;
}
void initUser(user) {
super.initUser(user);
}