add shipments
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/fcs_shipment.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/display_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';
|
||||
@@ -9,6 +13,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'fcs_shipment_editor.dart';
|
||||
|
||||
@@ -110,6 +115,11 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
iconData: Icons.av_timer,
|
||||
);
|
||||
|
||||
final shipBtn = LocalButton(
|
||||
textKey: "FCSshipment.ship.btn",
|
||||
callBack: _ship,
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
@@ -151,6 +161,9 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
portBox,
|
||||
destinationBox,
|
||||
statusBox,
|
||||
_fcsShipment.status == fcs_shipment_confirmed_status
|
||||
? shipBtn
|
||||
: Container(),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
@@ -203,4 +216,28 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
}).toList();
|
||||
});
|
||||
}
|
||||
|
||||
_ship() {
|
||||
showConfirmDialog(context, "FCSshipment.ship.confirm", () {
|
||||
_shipFcsShipment();
|
||||
});
|
||||
}
|
||||
|
||||
_shipFcsShipment() async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
FcsShipmentModel fcsShipmentModel =
|
||||
Provider.of<FcsShipmentModel>(context, listen: false);
|
||||
await fcsShipmentModel.ship(_fcsShipment);
|
||||
Navigator.pop(context, true);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ class _FcsShipmentListState extends State<FcsShipmentList> {
|
||||
popmenus: [
|
||||
LocalPopupMenu(
|
||||
id: 1,
|
||||
textKey: "package.popupmenu.active",
|
||||
textKey: "FCSshipment.popupmenu.active",
|
||||
selected: shipmentModel.selectedIndex == 1),
|
||||
LocalPopupMenu(
|
||||
id: 2,
|
||||
textKey: "package.popupmenu.delivered",
|
||||
textKey: "FCSshipment.popupmenu.delivered",
|
||||
selected: shipmentModel.selectedIndex == 2)
|
||||
],
|
||||
popupMenuCallback: (p) => this.setState(() {
|
||||
@@ -83,9 +83,9 @@ class _FcsShipmentListState extends State<FcsShipmentList> {
|
||||
controller: _controller,
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: Colors.black,
|
||||
height: 1,
|
||||
),
|
||||
scrollDirection: Axis.vertical,
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
shrinkWrap: true,
|
||||
itemCount: shipmentModel.fcsShipments.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
|
||||
@@ -14,13 +14,13 @@ class FcsShipmentListRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left: 15, right: 15),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => FcsShipmentInfo(fcsShipment: shipment)));
|
||||
},
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => FcsShipmentInfo(fcsShipment: shipment)));
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: 15, right: 15),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
|
||||
@@ -75,7 +75,7 @@ class FcsShipmentModel extends BaseModel {
|
||||
.collection("/$fcs_shipment_collection")
|
||||
.where("is_delivered", isEqualTo: true)
|
||||
.where("is_deleted", isEqualTo: false)
|
||||
.orderBy("current_status_date", descending: true);
|
||||
.orderBy("status_date", descending: true);
|
||||
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
||||
return FcsShipment.fromMap(data, id);
|
||||
});
|
||||
@@ -98,6 +98,24 @@ class FcsShipmentModel extends BaseModel {
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<FcsShipment>> getActiveFcsShipments() async {
|
||||
List<FcsShipment> fcsShipments = [];
|
||||
try {
|
||||
var snaps = await Firestore.instance
|
||||
.collection("/$fcs_shipment_collection")
|
||||
.where("status", isEqualTo: fcs_shipment_confirmed_status)
|
||||
.getDocuments(source: Source.server);
|
||||
fcsShipments = snaps.documents.map((documentSnapshot) {
|
||||
var fcs = FcsShipment.fromMap(
|
||||
documentSnapshot.data, documentSnapshot.documentID);
|
||||
return fcs;
|
||||
}).toList();
|
||||
} catch (e) {
|
||||
log.warning("Error!! $e");
|
||||
}
|
||||
return fcsShipments;
|
||||
}
|
||||
|
||||
void initUser(user) {
|
||||
super.initUser(user);
|
||||
}
|
||||
@@ -116,4 +134,8 @@ class FcsShipmentModel extends BaseModel {
|
||||
Future<void> update(FcsShipment fcsShipment) {
|
||||
return Services.instance.fcsShipmentService.updateFcsShipment(fcsShipment);
|
||||
}
|
||||
|
||||
Future<void> ship(FcsShipment fcsShipment) {
|
||||
return Services.instance.fcsShipmentService.ship(fcsShipment);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user