merge
This commit is contained in:
@@ -10,7 +10,6 @@ import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/carton/carton_package_table.dart';
|
||||
import 'package:fcs/pages/carton_search/carton_search.dart';
|
||||
import 'package:fcs/pages/carton_size/carton_size_list.dart';
|
||||
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/package/model/package_model.dart';
|
||||
@@ -40,8 +39,8 @@ import 'package_carton_editor.dart';
|
||||
import 'widgets.dart';
|
||||
|
||||
class CartonEditor extends StatefulWidget {
|
||||
final Carton? box;
|
||||
CartonEditor({this.box});
|
||||
final Carton? carton;
|
||||
CartonEditor({this.carton});
|
||||
|
||||
@override
|
||||
_CartonEditorState createState() => _CartonEditorState();
|
||||
@@ -63,7 +62,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
double volumetricRatio = 0;
|
||||
double shipmentWeight = 0;
|
||||
FcsShipment? _fcsShipment;
|
||||
List<FcsShipment>? _fcsShipments;
|
||||
List<FcsShipment> _fcsShipments = [];
|
||||
List<Carton> _cartons = [];
|
||||
CartonSize? selectedCatonSize;
|
||||
|
||||
@@ -90,8 +89,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_widthController.addListener(_calShipmentWeight);
|
||||
_heightController.addListener(_calShipmentWeight);
|
||||
|
||||
if (widget.box != null) {
|
||||
_carton = widget.box;
|
||||
if (widget.carton != null) {
|
||||
_carton = widget.carton;
|
||||
_deliveryAddress = _carton!.deliveryAddress;
|
||||
_widthController.text = _carton!.width.toString();
|
||||
_heightController.text = _carton!.height.toString();
|
||||
@@ -138,11 +137,13 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
FcsShipmentModel fcsShipmentModel =
|
||||
Provider.of<FcsShipmentModel>(context, listen: false);
|
||||
var fcsShipments = await fcsShipmentModel.getActiveFcsShipments();
|
||||
var fcsShipment =
|
||||
fcsShipments.firstWhere((e) => e.id == _carton!.fcsShipmentID);
|
||||
|
||||
// var fcsShipment =
|
||||
// fcsShipments.firstWhere((e) => e.id == _carton?.fcsShipmentID);
|
||||
|
||||
setState(() {
|
||||
_fcsShipments = fcsShipments;
|
||||
_fcsShipment = fcsShipment;
|
||||
// _fcsShipment = fcsShipment;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -195,9 +196,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
// }
|
||||
|
||||
_calShipmentWeight() {
|
||||
double l = double.parse(_lengthController.text);
|
||||
double w = double.parse(_widthController.text);
|
||||
double h = double.parse(_heightController.text);
|
||||
double l = double.tryParse(_lengthController.text) ?? 0;
|
||||
double w = double.tryParse(_widthController.text) ?? 0;
|
||||
double h = double.tryParse(_heightController.text) ?? 0;
|
||||
setState(() {
|
||||
shipmentWeight = l * w * h / volumetricRatio;
|
||||
});
|
||||
@@ -248,8 +249,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
labelKey: "shipment.pack.fcs.shipment",
|
||||
iconData: Ionicons.ios_airplane,
|
||||
display: (u) => u.shipmentNumber,
|
||||
selectedValue: _fcsShipment!,
|
||||
values: _fcsShipments!,
|
||||
selectedValue: _fcsShipment,
|
||||
values: _fcsShipments,
|
||||
));
|
||||
|
||||
final fcsIDBox = Container(
|
||||
|
||||
@@ -144,9 +144,9 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
}
|
||||
|
||||
_calShipmentWeight() {
|
||||
double l = double.parse(_lengthController.text);
|
||||
double w = double.parse(_widthController.text);
|
||||
double h = double.parse(_heightController.text);
|
||||
double l = double.tryParse(_lengthController.text) ?? 0;
|
||||
double w = double.tryParse(_widthController.text) ?? 0;
|
||||
double h = double.tryParse(_heightController.text) ?? 0;
|
||||
setState(() {
|
||||
shipmentWeight = l * w * h / volumetricRatio;
|
||||
});
|
||||
@@ -412,7 +412,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
_box!.mixCartons = _box!.mixCartons;
|
||||
bool? updated = await Navigator.push<bool>(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => CartonEditor(box: _box)),
|
||||
CupertinoPageRoute(builder: (context) => CartonEditor(carton: _box)),
|
||||
);
|
||||
if (updated ?? false) {
|
||||
var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||
|
||||
@@ -12,8 +12,8 @@ class CustomerModel extends BaseModel {
|
||||
|
||||
List<User> customers = [];
|
||||
List<User> invitations = [];
|
||||
late StreamSubscription<QuerySnapshot>? customerListener;
|
||||
late StreamSubscription<QuerySnapshot>? invitationListener;
|
||||
StreamSubscription<QuerySnapshot>? customerListener;
|
||||
StreamSubscription<QuerySnapshot>? invitationListener;
|
||||
|
||||
@override
|
||||
void privilegeChanged() {
|
||||
|
||||
@@ -95,9 +95,8 @@ class DeliveryAddressModel extends BaseModel {
|
||||
.collection("$path")
|
||||
.orderBy("full_name")
|
||||
.get();
|
||||
return querySnap.docs
|
||||
.map((e) =>
|
||||
DeliveryAddress.fromMap(e.data as Map<String, dynamic>, e.id))
|
||||
return querySnap.docs
|
||||
.map((e) => DeliveryAddress.fromMap(e.data(), e.id))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ class FcsShipmentModel extends BaseModel {
|
||||
.where("status", isEqualTo: fcs_shipment_confirmed_status)
|
||||
.get(const GetOptions(source: Source.server));
|
||||
fcsShipments = snaps.docs.map((documentSnapshot) {
|
||||
var fcs = FcsShipment.fromMap(
|
||||
documentSnapshot.data as Map<String, dynamic>, documentSnapshot.id);
|
||||
var fcs =
|
||||
FcsShipment.fromMap(documentSnapshot.data(), documentSnapshot.id);
|
||||
return fcs;
|
||||
}).toList();
|
||||
} catch (e) {
|
||||
|
||||
@@ -70,10 +70,11 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
_fromTimeEditingController.text = "${timeFormatter.format(now)}";
|
||||
_toTimeEditingController.text = "${timeFormatter.format(now)}";
|
||||
// _shipment = Shipment(boxes: []);
|
||||
var shipmentModel =
|
||||
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||
_shipment!.pickupAddress = shipmentModel.defalutAddress;
|
||||
_shipment!.boxes = [];
|
||||
|
||||
Shipment _s = Shipment(
|
||||
pickupAddress: context.read<DeliveryAddressModel>().defalutAddress,
|
||||
boxes: []);
|
||||
_shipment = _s;
|
||||
_pickupDate.text = dateFormatter.format(now);
|
||||
}
|
||||
}
|
||||
@@ -87,12 +88,12 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
Widget build(BuildContext context) {
|
||||
MainModel mainModel = Provider.of<MainModel>(context);
|
||||
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
|
||||
final shipmentNumberBox = getShipmentNumberStatus(context, _shipment!);
|
||||
final shipmentNumberBox = getShipmentNumberStatus(context, _shipment);
|
||||
bool isLocalPickup = _selectedShipmentType == shipment_local_pickup;
|
||||
bool isCourierPickup = _selectedShipmentType == shipment_courier_pickup;
|
||||
bool isLocalDropoff = _selectedShipmentType == shipment_local_dropoff;
|
||||
bool isCourierDropoff = _selectedShipmentType == shipment_courier_dropoff;
|
||||
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
||||
|
||||
final fromTimeBox = InputTime(
|
||||
labelTextKey: 'shipment.from',
|
||||
iconData: Icons.timer,
|
||||
@@ -122,7 +123,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
backgroundColor: Colors.white,
|
||||
));
|
||||
final pickupAddressBox = DefaultDeliveryAddress(
|
||||
deliveryAddress: _shipment!.pickupAddress,
|
||||
deliveryAddress: _shipment?.pickupAddress,
|
||||
iconData: Icons.location_on,
|
||||
labelKey: "shipment.location",
|
||||
onTap: () async {
|
||||
@@ -130,12 +131,15 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => DeliveryAddressSelection(
|
||||
deliveryAddress: _shipment!.pickupAddress,
|
||||
deliveryAddress: _shipment?.pickupAddress,
|
||||
user: mainModel.user)),
|
||||
);
|
||||
|
||||
if (address == null) return;
|
||||
|
||||
setState(() {
|
||||
_shipment!.pickupAddress = address;
|
||||
Shipment _s = Shipment(pickupAddress: address);
|
||||
_shipment = _s;
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -230,17 +234,18 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
Carton box = await Navigator.push(
|
||||
Carton? box = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => ShipmentBoxEditor()),
|
||||
);
|
||||
if (box == null) return;
|
||||
_addBox(box);
|
||||
},
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: getBoxList(context, _shipment!.boxes),
|
||||
children: getBoxList(context, _shipment?.boxes ?? []),
|
||||
),
|
||||
_isNew ? createBtn : updateBtn,
|
||||
],
|
||||
@@ -324,6 +329,6 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
}
|
||||
|
||||
isDataChanged() {
|
||||
return _shipment!.boxes.isNotEmpty;
|
||||
return _shipment?.boxes.isNotEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,21 +3,21 @@ import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Widget getShipmentNumberStatus(BuildContext context, Shipment shipment) {
|
||||
Widget getShipmentNumberStatus(BuildContext context, Shipment? shipment) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
LocalText(
|
||||
context,
|
||||
'',
|
||||
text: shipment.shipmentNumber ?? "",
|
||||
text: shipment?.shipmentNumber ?? "",
|
||||
color: primaryColor,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Chip(label: Text(shipment.status ?? "")),
|
||||
child: Chip(label: Text(shipment?.status ?? "")),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -64,8 +64,7 @@ class _DeliveryAddressSelectionState extends State<DeliveryAddressSelection> {
|
||||
bool? updated = await Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
DeliveryAddressEditor(user: widget.user)));
|
||||
if (updated == null) return;
|
||||
if (updated) {
|
||||
if (updated ?? false) {
|
||||
_getDeliverAddresses();
|
||||
}
|
||||
},
|
||||
@@ -115,10 +114,10 @@ class _DeliveryAddressSelectionState extends State<DeliveryAddressSelection> {
|
||||
}
|
||||
|
||||
_edit(BuildContext context, DeliveryAddress deliveryAddress) async {
|
||||
bool updated = await Navigator.of(context).push(CupertinoPageRoute(
|
||||
bool? updated = await Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => DeliveryAddressEditor(
|
||||
user: widget.user, deliveryAddress: deliveryAddress)));
|
||||
if (updated) {
|
||||
if (updated ?? false) {
|
||||
_getDeliverAddresses();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user