add mix carton
This commit is contained in:
@@ -74,6 +74,7 @@ const shipment_courier_dropoff = "Courier drop off";
|
||||
const carton_from_packages = "From packages";
|
||||
const carton_from_shipments = "From shipments";
|
||||
const carton_mix_box = "Mix carton";
|
||||
const carton_small_bag = "Small bag";
|
||||
|
||||
//Carton status
|
||||
const carton_packed_status = "packed";
|
||||
|
||||
@@ -32,6 +32,8 @@ class Carton {
|
||||
String userID;
|
||||
String fcsShipmentID;
|
||||
String fcsShipmentNumber;
|
||||
String mixCartonID;
|
||||
String mixCartonNumber;
|
||||
|
||||
int rate;
|
||||
int weight;
|
||||
@@ -134,12 +136,15 @@ class Carton {
|
||||
this.fcsShipmentNumber,
|
||||
this.cartons,
|
||||
this.packageIDs,
|
||||
this.mixCartonID,
|
||||
this.mixCartonNumber,
|
||||
this.isShipmentCarton = false,
|
||||
this.deliveryAddress});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
List _cargoTypes = cargoTypes.map((c) => c.toMap()).toList();
|
||||
List _packages = packages?.map((c) => c.toJson())?.toList();
|
||||
List _cartons = cartons?.map((c) => c.toMap())?.toList() ?? [];
|
||||
return {
|
||||
"id": id,
|
||||
'fcs_shipment_id': fcsShipmentID,
|
||||
@@ -151,6 +156,8 @@ class Carton {
|
||||
'height': height,
|
||||
'delivery_address': deliveryAddress.toMap(),
|
||||
'carton_type': cartonType,
|
||||
'cartons': _cartons,
|
||||
'mix_carton_id': mixCartonID
|
||||
};
|
||||
}
|
||||
|
||||
@@ -158,7 +165,8 @@ class Carton {
|
||||
var _arrivedDate = (map['arrived_date'] as Timestamp);
|
||||
var da = map['delivery_address'];
|
||||
var _da = da != null ? DeliveryAddress.fromMap(da, da["id"]) : null;
|
||||
var cargoTypesMaps = List<Map<String, dynamic>>.from(map['cargo_types']);
|
||||
var cargoTypesMaps =
|
||||
List<Map<String, dynamic>>.from(map['cargo_types'] ?? []);
|
||||
var cargoTypes =
|
||||
cargoTypesMaps.map((e) => CargoType.fromMap(e, e["id"])).toList();
|
||||
return Carton(
|
||||
@@ -178,6 +186,8 @@ class Carton {
|
||||
fcsShipmentID: map['fcs_shipment_id'],
|
||||
fcsShipmentNumber: map['fcs_shipment_number'],
|
||||
isShipmentCarton: map['is_shipment_carton'],
|
||||
mixCartonID: map['mix_carton_id'],
|
||||
mixCartonNumber: map['mix_carton_number'],
|
||||
status: map['status'],
|
||||
packageIDs: List<String>.from(map['package_ids'] ?? []),
|
||||
deliveryAddress: _da,
|
||||
|
||||
@@ -123,6 +123,12 @@ class Package {
|
||||
currentStatusDate: DateTime.parse(json['status_date']));
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => other is Package && other.id == id;
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Package{id: $id, status: $status, market:$market, trackingID: $trackingID,}';
|
||||
|
||||
@@ -100,7 +100,8 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
||||
)),
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(18),
|
||||
child: Column(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
cargoTypeBox,
|
||||
rateBox,
|
||||
|
||||
@@ -63,6 +63,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
double shipmentWeight = 0;
|
||||
FcsShipment _fcsShipment;
|
||||
List<FcsShipment> _fcsShipments;
|
||||
Carton _mixCarton;
|
||||
List<Carton> _mixCartons;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -85,6 +87,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_selectedCartonType = _carton.cartonType;
|
||||
_isNew = false;
|
||||
_user = User(fcsID: _carton.fcsID, name: _carton.userName);
|
||||
_loadPackages();
|
||||
} else {
|
||||
_carton = Carton(cargoTypes: [], packages: [], cartons: []);
|
||||
_lengthController.text = "12";
|
||||
@@ -93,6 +96,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_isNew = true;
|
||||
_selectedCartonType = carton_from_packages;
|
||||
_loadFcsShipments();
|
||||
_loadMixCartons();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,25 +112,46 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
});
|
||||
}
|
||||
|
||||
_loadMixCartons() async {
|
||||
if (_fcsShipment == null) return;
|
||||
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||
var mixCartons =
|
||||
await cartonModel.getMixCartonsByFcsShipment(_fcsShipment.id);
|
||||
setState(() {
|
||||
_mixCartons = mixCartons;
|
||||
});
|
||||
}
|
||||
|
||||
_loadPackages() async {
|
||||
if (_user == null) return;
|
||||
PackageModel packageModel =
|
||||
Provider.of<PackageModel>(context, listen: false);
|
||||
List<Package> packages = await packageModel.getPackages(_user.id);
|
||||
String prevCompare;
|
||||
packages.forEach((p) {
|
||||
String compare = (p.deliveryAddress?.fullName ?? "") +
|
||||
(p.deliveryAddress?.phoneNumber ?? "");
|
||||
if (prevCompare != null && compare == prevCompare) {
|
||||
p.isChecked = true;
|
||||
} else {
|
||||
p.isChecked = false;
|
||||
}
|
||||
if (prevCompare == null) {
|
||||
p.isChecked = true;
|
||||
prevCompare = compare;
|
||||
}
|
||||
});
|
||||
List<Package> packages = await packageModel.getPackages(
|
||||
_user.id, [package_processed_status, package_packed_status]);
|
||||
if (_isNew) {
|
||||
String prevCompare;
|
||||
packages.forEach((p) {
|
||||
String compare = (p.deliveryAddress?.fullName ?? "") +
|
||||
(p.deliveryAddress?.phoneNumber ?? "");
|
||||
if (prevCompare != null && compare == prevCompare) {
|
||||
p.isChecked = true;
|
||||
} else {
|
||||
p.isChecked = false;
|
||||
}
|
||||
if (prevCompare == null) {
|
||||
p.isChecked = true;
|
||||
prevCompare = compare;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
packages.forEach((p) {
|
||||
if (_carton.packages.contains(p)) {
|
||||
p.isChecked = _carton.packages.firstWhere((cp) => cp == p).isChecked;
|
||||
} else {
|
||||
p.isChecked = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_carton.packages = packages;
|
||||
@@ -176,12 +201,17 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
Widget build(BuildContext context) {
|
||||
var boxModel = Provider.of<CartonModel>(context);
|
||||
bool isMixBox = _selectedCartonType == carton_mix_box;
|
||||
bool isSmallBag = _selectedCartonType == carton_small_bag;
|
||||
final shipmentBox = DisplayText(
|
||||
text: _carton.fcsShipmentNumber,
|
||||
labelTextKey: "box.fcs_shipment_num",
|
||||
iconData: Ionicons.ios_airplane,
|
||||
);
|
||||
|
||||
final mixCartonNumberBox = DisplayText(
|
||||
text: _carton.mixCartonNumber,
|
||||
labelTextKey: "box.mix.carton",
|
||||
iconData: MaterialCommunityIcons.package,
|
||||
);
|
||||
var fcsShipmentsBox = LocalDropdown<FcsShipment>(
|
||||
callback: (v) {
|
||||
setState(() {
|
||||
@@ -190,6 +220,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
if (_selectedCartonType == carton_mix_box) {
|
||||
_loadCartons();
|
||||
}
|
||||
if (_selectedCartonType == carton_small_bag) {
|
||||
_loadMixCartons();
|
||||
}
|
||||
},
|
||||
labelKey: "shipment.pack.fcs.shipment",
|
||||
iconData: Ionicons.ios_airplane,
|
||||
@@ -198,6 +231,19 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
values: _fcsShipments,
|
||||
);
|
||||
|
||||
var mixCartonsBox = LocalDropdown<Carton>(
|
||||
callback: (v) {
|
||||
setState(() {
|
||||
_mixCarton = v;
|
||||
});
|
||||
},
|
||||
labelKey: "box.mix.carton",
|
||||
iconData: MaterialCommunityIcons.package,
|
||||
display: (u) => u.cartonNumber,
|
||||
selectedValue: _mixCarton,
|
||||
values: _mixCartons,
|
||||
);
|
||||
|
||||
final fcsIDBox = Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
@@ -338,16 +384,19 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
cartonTypeBox,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
_isNew ? fcsShipmentsBox : shipmentBox,
|
||||
isSmallBag
|
||||
? _isNew ? mixCartonsBox : mixCartonNumberBox
|
||||
: Container(),
|
||||
...(isMixBox
|
||||
? [
|
||||
CartonMixTable(
|
||||
cartons: _carton.cartons,
|
||||
onSelect: (c, check) {
|
||||
setState(() {
|
||||
c.isChecked = check;
|
||||
});
|
||||
},
|
||||
)
|
||||
// CartonMixTable(
|
||||
// cartons: _carton.cartons,
|
||||
// onSelect: (c, check) {
|
||||
// setState(() {
|
||||
// c.isChecked = check;
|
||||
// });
|
||||
// },
|
||||
// )
|
||||
]
|
||||
: [
|
||||
fcsIDBox,
|
||||
@@ -368,9 +417,11 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
),
|
||||
cargoTableTitleBox,
|
||||
cargoTableBox,
|
||||
LocalTitle(textKey: "box.dimension"),
|
||||
dimBox,
|
||||
shipmentWeightBox,
|
||||
isSmallBag
|
||||
? Container()
|
||||
: LocalTitle(textKey: "box.dimension"),
|
||||
isSmallBag ? Container() : dimBox,
|
||||
isSmallBag ? Container() : shipmentWeightBox,
|
||||
LocalTitle(textKey: "box.delivery_address"),
|
||||
DefaultDeliveryAddress(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
@@ -413,7 +464,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
}
|
||||
|
||||
_save() async {
|
||||
if (_user == null) {
|
||||
bool isFromShipment = _selectedCartonType == carton_from_shipments;
|
||||
bool isSmallBag = _selectedCartonType == carton_small_bag;
|
||||
if (_user == null && (isFromShipment || isSmallBag)) {
|
||||
showMsgDialog(context, "Error", "Please select customer");
|
||||
return;
|
||||
}
|
||||
@@ -421,35 +474,40 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
showMsgDialog(context, "Error", "Please select FCS shipment");
|
||||
return;
|
||||
}
|
||||
if ((_carton.cargoTypes?.length ?? 0) == 0) {
|
||||
if ((_carton.cargoTypes?.length ?? 0) == 0 &&
|
||||
(isFromShipment || isSmallBag)) {
|
||||
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
||||
return;
|
||||
}
|
||||
double l = double.parse(_lengthController.text, (s) => 0);
|
||||
double w = double.parse(_widthController.text, (s) => 0);
|
||||
double h = double.parse(_heightController.text, (s) => 0);
|
||||
if (l <= 0 || w <= 0 || h <= 0) {
|
||||
if ((l <= 0 || w <= 0 || h <= 0) && isFromShipment) {
|
||||
showMsgDialog(context, "Error", "Invalid dimension");
|
||||
return;
|
||||
}
|
||||
if (_deliveryAddress == null) {
|
||||
if (_deliveryAddress == null && (isFromShipment || isSmallBag)) {
|
||||
showMsgDialog(context, "Error", "Invalid delivery address");
|
||||
return;
|
||||
}
|
||||
if (isSmallBag && _mixCarton == null) {
|
||||
showMsgDialog(context, "Error", "Invalid mix carton");
|
||||
return;
|
||||
}
|
||||
|
||||
Carton carton = Carton();
|
||||
carton.id = _carton.id;
|
||||
carton.cartonType = _selectedCartonType;
|
||||
carton.fcsShipmentID = _isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
||||
carton.userID = _user.id;
|
||||
carton.userID = _user?.id;
|
||||
carton.cargoTypes = _carton.cargoTypes;
|
||||
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
||||
|
||||
carton.mixCartonID = _mixCarton?.id;
|
||||
carton.length = l;
|
||||
carton.width = w;
|
||||
carton.height = h;
|
||||
carton.deliveryAddress = _deliveryAddress;
|
||||
|
||||
carton.cartons = _carton.cartons.where((c) => c.isChecked).toList();
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
|
||||
@@ -55,7 +55,8 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
|
||||
bool isMixBox;
|
||||
bool isFromShipments;
|
||||
bool isFromPackage;
|
||||
bool isFromPackages;
|
||||
bool isSmallBag;
|
||||
bool isEdiable;
|
||||
|
||||
@override
|
||||
@@ -72,35 +73,39 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
_widthController.addListener(_calShipmentWeight);
|
||||
_heightController.addListener(_calShipmentWeight);
|
||||
|
||||
_updateBoxData();
|
||||
_loadPackages();
|
||||
}
|
||||
|
||||
_updateBoxData() {
|
||||
_widthController.text = _box.width.toString();
|
||||
_heightController.text = _box.height.toString();
|
||||
_lengthController.text = _box.length.toString();
|
||||
|
||||
_cargoTypes = _box.cargoTypes;
|
||||
_deliveryAddress = _box.deliveryAddress;
|
||||
|
||||
isMixBox = _box.cartonType == carton_mix_box;
|
||||
isFromShipments = _box.cartonType == carton_from_shipments;
|
||||
isFromPackage = _box.cartonType == carton_from_packages;
|
||||
isEdiable =
|
||||
(isMixBox || isFromPackage) && _box.status == carton_packed_status;
|
||||
|
||||
if (isFromPackage) {
|
||||
_loadPackages();
|
||||
}
|
||||
isFromPackages = _box.cartonType == carton_from_packages;
|
||||
isSmallBag = _box.cartonType == carton_small_bag;
|
||||
isEdiable = !isMixBox &&
|
||||
(isFromPackages || isSmallBag) &&
|
||||
_box.status == carton_packed_status;
|
||||
}
|
||||
|
||||
_loadPackages() async {
|
||||
if (!isFromPackages && !isSmallBag) return;
|
||||
|
||||
if (_box.cartonType == carton_from_packages && _box.userID == null) return;
|
||||
PackageModel packageModel =
|
||||
Provider.of<PackageModel>(context, listen: false);
|
||||
List<Package> packages = await packageModel.getPackages(_box.userID);
|
||||
List<Package> packages = await packageModel.getPackages(_box.userID, [
|
||||
package_processed_status,
|
||||
package_packed_status,
|
||||
package_shipped_status
|
||||
]);
|
||||
packages = packages.where((p) => _box.packageIDs.contains(p.id)).toList();
|
||||
packages.forEach((p) {
|
||||
if (_box.packageIDs.contains(p.id)) {
|
||||
p.isChecked = true;
|
||||
} else {
|
||||
p.isChecked = false;
|
||||
}
|
||||
p.isChecked = true;
|
||||
});
|
||||
|
||||
setState(() {
|
||||
@@ -219,6 +224,11 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
final cargoTableBox = CargoTable(
|
||||
cargoTypes: _box.cargoTypes,
|
||||
);
|
||||
final mixCartonNumberBox = DisplayText(
|
||||
text: _box.mixCartonNumber,
|
||||
labelTextKey: "box.mix.carton",
|
||||
iconData: MaterialCommunityIcons.package,
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
@@ -250,65 +260,68 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
]
|
||||
: [],
|
||||
),
|
||||
body: Card(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(children: <Widget>[
|
||||
Center(child: getCartonNumberStatus(context, _box)),
|
||||
LocalTitle(textKey: "box.type.title"),
|
||||
cartonTypeBox,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
shipmentBox,
|
||||
fcsIDBox,
|
||||
customerNameBox,
|
||||
isFromPackage
|
||||
? CartonPackageTable(
|
||||
packages: _box.packages,
|
||||
)
|
||||
: Container(),
|
||||
isFromPackage
|
||||
? Container()
|
||||
: isFromShipments
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.shipment.boxes"),
|
||||
shipmentBoxTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
shipmentBoxRow
|
||||
],
|
||||
)
|
||||
: _selectedCartonType == "Mix carton"
|
||||
? CartonMixTable(
|
||||
cartons: _box.cartons,
|
||||
onSelect: (c, check) {
|
||||
setState(() {
|
||||
c.isChecked = check;
|
||||
});
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
LocalTitle(textKey: "box.cargo.type"),
|
||||
cargoTableBox,
|
||||
LocalTitle(textKey: "box.dimension"),
|
||||
dimBox,
|
||||
shipmentWeightBox,
|
||||
LocalTitle(textKey: "box.delivery_address"),
|
||||
DefaultDeliveryAddress(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(children: <Widget>[
|
||||
Center(child: getCartonNumberStatus(context, _box)),
|
||||
LocalTitle(textKey: "box.type.title"),
|
||||
cartonTypeBox,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
shipmentBox,
|
||||
isSmallBag ? mixCartonNumberBox : Container(),
|
||||
isMixBox ? Container() : fcsIDBox,
|
||||
isMixBox ? Container() : customerNameBox,
|
||||
isFromPackages || isSmallBag
|
||||
? CartonPackageTable(
|
||||
packages: _box.packages,
|
||||
)
|
||||
: Container(),
|
||||
isFromPackages
|
||||
? Container()
|
||||
: isFromShipments
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.shipment.boxes"),
|
||||
shipmentBoxTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
shipmentBoxRow
|
||||
],
|
||||
)
|
||||
: Container(),
|
||||
// : _selectedCartonType == "Mix carton"
|
||||
// ? CartonMixTable(
|
||||
// cartons: _box.cartons,
|
||||
// onSelect: (c, check) {
|
||||
// setState(() {
|
||||
// c.isChecked = check;
|
||||
// });
|
||||
// },
|
||||
// )
|
||||
// : Container(),
|
||||
isMixBox ? Container() : LocalTitle(textKey: "box.cargo.type"),
|
||||
isMixBox ? Container() : cargoTableBox,
|
||||
...(isFromPackages
|
||||
? [
|
||||
LocalTitle(textKey: "box.dimension"),
|
||||
dimBox,
|
||||
shipmentWeightBox,
|
||||
]
|
||||
: []),
|
||||
isMixBox
|
||||
? Container()
|
||||
: LocalTitle(textKey: "box.delivery_address"),
|
||||
isMixBox
|
||||
? Container()
|
||||
: DefaultDeliveryAddress(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
labelKey: "box.delivery_address",
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
]),
|
||||
)),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -324,6 +337,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
var c = await cartonModel.getCarton(widget.box.id);
|
||||
setState(() {
|
||||
_box = c;
|
||||
_updateBoxData();
|
||||
});
|
||||
_loadPackages();
|
||||
}
|
||||
|
||||
@@ -7,32 +7,20 @@ import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'carton_info.dart';
|
||||
|
||||
class CartonListRow extends StatefulWidget {
|
||||
class CartonListRow extends StatelessWidget {
|
||||
final Carton box;
|
||||
const CartonListRow({Key key, this.box}) : super(key: key);
|
||||
CartonListRow({Key key, this.box}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CartonListRowState createState() => _CartonListRowState();
|
||||
}
|
||||
|
||||
class _CartonListRowState extends State<CartonListRow> {
|
||||
final double dotSize = 15.0;
|
||||
Carton _box = new Carton();
|
||||
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_box = widget.box;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => CartonInfo(box: _box)),
|
||||
CupertinoPageRoute(builder: (context) => CartonInfo(box: box)),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
@@ -59,7 +47,7 @@ class _CartonListRowState extends State<CartonListRow> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
_box.cartonNumber ?? "",
|
||||
box.cartonNumber ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
@@ -67,7 +55,7 @@ class _CartonListRowState extends State<CartonListRow> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||
child: new Text(
|
||||
_box.userName ?? "",
|
||||
box.userName ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
@@ -83,14 +71,14 @@ class _CartonListRowState extends State<CartonListRow> {
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: getStatus(_box.status == null ? "" : _box.status),
|
||||
child: getStatus(box.status == null ? "" : box.status),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
"${_box.actualWeight?.toString() ?? ''} lb",
|
||||
"${box.actualWeight?.toString() ?? ''} lb",
|
||||
style:
|
||||
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
|
||||
@@ -31,45 +31,47 @@ class CartonMixTable extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
|
||||
final rows = cartons.asMap().entries.map((p) {
|
||||
return Container(
|
||||
color: p.value.isChecked
|
||||
? Colors.grey.withOpacity(0.2)
|
||||
: Colors.grey[50].withOpacity(0.2),
|
||||
child: Container(
|
||||
padding:
|
||||
EdgeInsets.only(left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: p.key == cartons.length - 1
|
||||
? Colors.white
|
||||
: Colors.grey[350],
|
||||
width: 1),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Checkbox(
|
||||
value: p.value.isChecked,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (bool check) {
|
||||
if (onSelect != null) onSelect(p.value, check);
|
||||
}),
|
||||
Expanded(
|
||||
child: new Text(
|
||||
p.value.cartonNumber ?? "",
|
||||
style: textStyle,
|
||||
)),
|
||||
new Text(
|
||||
p.value?.actualWeight?.toString() ?? "",
|
||||
style: textStyle,
|
||||
final rows = cartons == null
|
||||
? []
|
||||
: cartons.asMap().entries.map((p) {
|
||||
return Container(
|
||||
color: p.value.isChecked
|
||||
? Colors.grey.withOpacity(0.2)
|
||||
: Colors.grey[50].withOpacity(0.2),
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: p.key == cartons.length - 1
|
||||
? Colors.white
|
||||
: Colors.grey[350],
|
||||
width: 1),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Checkbox(
|
||||
value: p.value.isChecked,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (bool check) {
|
||||
if (onSelect != null) onSelect(p.value, check);
|
||||
}),
|
||||
Expanded(
|
||||
child: new Text(
|
||||
p.value.cartonNumber ?? "",
|
||||
style: textStyle,
|
||||
)),
|
||||
new Text(
|
||||
p.value?.actualWeight?.toString() ?? "",
|
||||
style: textStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
);
|
||||
}).toList();
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
|
||||
@@ -55,11 +55,16 @@ class CartonModel extends BaseModel {
|
||||
});
|
||||
}
|
||||
|
||||
List<String> cartonTypes = [carton_from_packages, carton_mix_box];
|
||||
List<String> cartonTypes = [
|
||||
carton_from_packages,
|
||||
carton_mix_box,
|
||||
carton_small_bag
|
||||
];
|
||||
List<String> cartonTypesInfo = [
|
||||
carton_from_packages,
|
||||
carton_mix_box,
|
||||
carton_from_shipments
|
||||
carton_from_shipments,
|
||||
carton_small_bag
|
||||
];
|
||||
|
||||
set selectedIndex(int index) {
|
||||
@@ -192,6 +197,19 @@ class CartonModel extends BaseModel {
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<List<Carton>> getMixCartonsByFcsShipment(String fcsShipmentID) async {
|
||||
String path = "/$cartons_collection";
|
||||
var querySnap = await Firestore.instance
|
||||
.collection(path)
|
||||
.where("fcs_shipment_id", isEqualTo: fcsShipmentID)
|
||||
.where("carton_type", isEqualTo: carton_mix_box)
|
||||
.where("is_deleted", isEqualTo: false)
|
||||
.getDocuments();
|
||||
return querySnap.documents
|
||||
.map((e) => Carton.fromMap(e.data, e.documentID))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<Carton> getCarton(String id) async {
|
||||
String path = "/$cartons_collection";
|
||||
var snap = await Firestore.instance.collection(path).document(id).get();
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/carton/widgets.dart';
|
||||
import 'package:fcs/pages/delivery/model/delivery_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/package/model/package_model.dart';
|
||||
@@ -460,90 +461,80 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
// ),
|
||||
// ],
|
||||
),
|
||||
body: Card(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(children: <Widget>[
|
||||
// Center(child: nameWidget(_box.packageNumber)),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
LocalTitle(textKey: "box.type.title"),
|
||||
cargoType,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
shipmentBox,
|
||||
fcsIDBox,
|
||||
customerNameBox,
|
||||
_selectedCartonType == "From packages"
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.packages"),
|
||||
packageTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
Column(
|
||||
children: getPackageRowList(),
|
||||
),
|
||||
],
|
||||
)
|
||||
: _selectedCartonType == "From shipments"
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.shipment.boxes"),
|
||||
shipmentBoxTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
shipmentBoxRow
|
||||
],
|
||||
)
|
||||
: _selectedCartonType == "Mix carton"
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.shipment.boxes"),
|
||||
mixBoxTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
Column(
|
||||
children: getMixBoxRowList(),
|
||||
)
|
||||
],
|
||||
)
|
||||
: Container(),
|
||||
LocalTitle(textKey: "box.cargo_type"),
|
||||
cargoTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
Column(
|
||||
children: getCargoRowList(),
|
||||
),
|
||||
LocalTitle(textKey: "box.dimension"),
|
||||
dimBox,
|
||||
shipmentWeightBox,
|
||||
LocalTitle(textKey: "box.delivery_address"),
|
||||
DefaultDeliveryAddress(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
labelKey: "box.delivery_address",
|
||||
),
|
||||
LocalTitle(textKey: "box.status"),
|
||||
Container(
|
||||
height: 230,
|
||||
child: Timeline(
|
||||
children: _models(), position: TimelinePosition.Left),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(children: <Widget>[
|
||||
Center(child: getCartonNumberStatus(context, _box)),
|
||||
LocalTitle(textKey: "box.type.title"),
|
||||
cargoType,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
shipmentBox,
|
||||
fcsIDBox,
|
||||
customerNameBox,
|
||||
_selectedCartonType == "From packages"
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.packages"),
|
||||
packageTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
Column(
|
||||
children: getPackageRowList(),
|
||||
),
|
||||
],
|
||||
)
|
||||
]),
|
||||
)),
|
||||
],
|
||||
),
|
||||
: _selectedCartonType == "From shipments"
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.shipment.boxes"),
|
||||
shipmentBoxTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
shipmentBoxRow
|
||||
],
|
||||
)
|
||||
: _selectedCartonType == "Mix carton"
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.shipment.boxes"),
|
||||
mixBoxTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
Column(
|
||||
children: getMixBoxRowList(),
|
||||
)
|
||||
],
|
||||
)
|
||||
: Container(),
|
||||
LocalTitle(textKey: "box.cargo_type"),
|
||||
cargoTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
Column(
|
||||
children: getCargoRowList(),
|
||||
),
|
||||
LocalTitle(textKey: "box.dimension"),
|
||||
dimBox,
|
||||
shipmentWeightBox,
|
||||
LocalTitle(textKey: "box.delivery_address"),
|
||||
DefaultDeliveryAddress(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
labelKey: "box.delivery_address",
|
||||
),
|
||||
LocalTitle(textKey: "box.status"),
|
||||
Container(
|
||||
height: 230,
|
||||
child: Timeline(
|
||||
children: _models(), position: TimelinePosition.Left),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -8,32 +8,20 @@ import 'package:intl/intl.dart';
|
||||
|
||||
import 'delivery_info.dart';
|
||||
|
||||
class DeliveryListRow extends StatefulWidget {
|
||||
class DeliveryListRow extends StatelessWidget {
|
||||
final Carton box;
|
||||
const DeliveryListRow({Key key,this.box}):super(key:key);
|
||||
DeliveryListRow({Key key, this.box}) : super(key: key);
|
||||
|
||||
@override
|
||||
_DeliveryListRowState createState() => _DeliveryListRowState();
|
||||
}
|
||||
|
||||
class _DeliveryListRowState extends State<DeliveryListRow> {
|
||||
final double dotSize = 15.0;
|
||||
Carton _box = new Carton();
|
||||
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_box = widget.box;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => DeliveryInfo(box: _box)),
|
||||
CupertinoPageRoute(builder: (context) => DeliveryInfo(box: box)),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
@@ -42,7 +30,7 @@ class _DeliveryListRowState extends State<DeliveryListRow> {
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
@@ -60,7 +48,7 @@ class _DeliveryListRowState extends State<DeliveryListRow> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
_box.cartonNumber ?? "",
|
||||
box.cartonNumber ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
@@ -68,7 +56,7 @@ class _DeliveryListRowState extends State<DeliveryListRow> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||
child: new Text(
|
||||
_box.userName ?? "",
|
||||
box.userName ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
@@ -84,14 +72,14 @@ class _DeliveryListRowState extends State<DeliveryListRow> {
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: getStatus(_box.status == null ? "" : _box.status),
|
||||
child: getStatus(box.status == null ? "" : box.status),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
"${_box.actualWeight?.toString() ?? ''} lb",
|
||||
"${box.actualWeight?.toString() ?? ''} lb",
|
||||
style:
|
||||
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
|
||||
@@ -112,7 +112,14 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
||||
shadowColor: Colors.transparent,
|
||||
title: LocalText(context, 'delivery_address',
|
||||
color: primaryColor, fontSize: 18),
|
||||
actions: [IconButton(icon: Icon(Icons.delete), onPressed: _delete)],
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.delete,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: _delete)
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, right: 10),
|
||||
|
||||
@@ -8,25 +8,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class DiscountListRow extends StatefulWidget {
|
||||
class DiscountListRow extends StatelessWidget {
|
||||
final Discount discount;
|
||||
const DiscountListRow({Key key, this.discount}) : super(key: key);
|
||||
DiscountListRow({Key key, this.discount}) : super(key: key);
|
||||
|
||||
@override
|
||||
_DiscountListRowState createState() => _DiscountListRowState();
|
||||
}
|
||||
|
||||
class _DiscountListRowState extends State<DiscountListRow> {
|
||||
final double dotSize = 15.0;
|
||||
Discount _discount;
|
||||
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_discount = widget.discount;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
@@ -34,7 +21,7 @@ class _DiscountListRowState extends State<DiscountListRow> {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => DiscountEditor(discount: _discount)),
|
||||
builder: (context) => DiscountEditor(discount: discount)),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
@@ -61,7 +48,7 @@ class _DiscountListRowState extends State<DiscountListRow> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
_discount.code ?? "",
|
||||
discount.code ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
@@ -69,7 +56,7 @@ class _DiscountListRowState extends State<DiscountListRow> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||
child: new Text(
|
||||
_discount.customerName ?? "",
|
||||
discount.customerName ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
@@ -85,14 +72,14 @@ class _DiscountListRowState extends State<DiscountListRow> {
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: Text(_discount.status),
|
||||
child: Text(discount.status),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
"${_discount.amount ?? ''}",
|
||||
"${discount.amount ?? ''}",
|
||||
style:
|
||||
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
|
||||
@@ -113,16 +113,16 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
||||
iconData: Icons.date_range,
|
||||
controller: _cutoffDateController,
|
||||
),
|
||||
InputDate(
|
||||
labelTextKey: "FCSshipment.ETA",
|
||||
iconData: Icons.date_range,
|
||||
controller: _arrivalDateController,
|
||||
),
|
||||
InputDate(
|
||||
labelTextKey: "FCSshipment.departure_date",
|
||||
iconData: Icons.date_range,
|
||||
controller: _departureDateControler,
|
||||
),
|
||||
InputDate(
|
||||
labelTextKey: "FCSshipment.ETA",
|
||||
iconData: Icons.date_range,
|
||||
controller: _arrivalDateController,
|
||||
),
|
||||
DropdownButtonFormField(
|
||||
value: _currentShipmentType == "" ? null : _currentShipmentType,
|
||||
decoration: InputDecoration(
|
||||
|
||||
@@ -158,8 +158,8 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
child: ListView(children: <Widget>[
|
||||
shipmentNumberBox,
|
||||
cutoffDateDBox,
|
||||
etaBox,
|
||||
departureDateBox,
|
||||
etaBox,
|
||||
shipTypeBox,
|
||||
consigneeBox,
|
||||
portBox,
|
||||
|
||||
@@ -128,7 +128,7 @@ class PackageModel extends BaseModel {
|
||||
if (forCustomer) {
|
||||
q = q.where("user_id", isEqualTo: user.id);
|
||||
}
|
||||
|
||||
q = q.orderBy("tracking_id", descending: false);
|
||||
listener = q.snapshots().listen((QuerySnapshot snapshot) {
|
||||
_packages.clear();
|
||||
_packages = snapshot.documents.map((documentSnapshot) {
|
||||
@@ -197,13 +197,12 @@ class PackageModel extends BaseModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<List<Package>> getPackages(String userID) async {
|
||||
Future<List<Package>> getPackages(String userID, List<String> status) async {
|
||||
List<Package> packages = [];
|
||||
try {
|
||||
var snaps = await Firestore.instance
|
||||
.collection("/$packages_collection")
|
||||
.where("status",
|
||||
whereIn: [package_processed_status, package_packed_status])
|
||||
.where("status", whereIn: status)
|
||||
.where("user_id", isEqualTo: userID)
|
||||
.where("is_deleted", isEqualTo: false)
|
||||
.where("is_delivered", isEqualTo: false)
|
||||
|
||||
@@ -62,6 +62,9 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
Widget build(BuildContext context) {
|
||||
String id = Provider.of<MainModel>(context).user.id;
|
||||
bool owner = _package.userID == id;
|
||||
bool canChangeDeliveryAddress =
|
||||
_package.status == package_received_status ||
|
||||
_package.status == package_processed_status;
|
||||
|
||||
final trackingIdBox = DisplayText(
|
||||
text: _package.trackingID,
|
||||
@@ -106,7 +109,7 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
final deliveryAddressBox = DefaultDeliveryAddress(
|
||||
deliveryAddress: _package.deliveryAddress,
|
||||
labelKey: "package.delivery.address",
|
||||
onTap: owner
|
||||
onTap: owner && canChangeDeliveryAddress
|
||||
? () async {
|
||||
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
|
||||
context,
|
||||
|
||||
@@ -59,7 +59,7 @@ class ShipmentRateModel extends BaseModel {
|
||||
}
|
||||
|
||||
Future<void> deleteCustomDuty(String id) {
|
||||
return Services.instance.rateService.deleteCargoType(id);
|
||||
return Services.instance.rateService.deleteCustomDuty(id);
|
||||
}
|
||||
|
||||
//Discount by weight
|
||||
|
||||
@@ -3,12 +3,10 @@ import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||
import 'package:fcs/domain/entities/rate.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/rates/cargo_type_list.dart';
|
||||
import 'package:fcs/pages/rates/custom_list.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||
import 'package:fcs/domain/entities/rate.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../main/util.dart';
|
||||
import 'cargo_editor.dart';
|
||||
import 'custom_editor.dart';
|
||||
import 'discount_by_weight_editor.dart';
|
||||
|
||||
class ShipmentRatesEdit extends StatefulWidget {
|
||||
ShipmentRatesEdit();
|
||||
@@ -34,14 +30,16 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
||||
TextEditingController _deliveryFee = new TextEditingController();
|
||||
TextEditingController _volumetricRatio = new TextEditingController();
|
||||
|
||||
bool _isNew = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_minWeight.text = "10";
|
||||
_deliveryFee.text = "5";
|
||||
_volumetricRatio.text = "166.36";
|
||||
var shipmentRateModel =
|
||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||
Rate rate = shipmentRateModel.rate;
|
||||
|
||||
_minWeight.text = rate.freeDeliveryWeight?.toString() ?? "";
|
||||
_deliveryFee.text = rate.deliveryFee?.toString() ?? "";
|
||||
_volumetricRatio.text = rate.volumetricRatio?.toString() ?? "";
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -91,202 +89,6 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
||||
feeBox,
|
||||
ratioBox,
|
||||
SizedBox(height: 10),
|
||||
// ExpansionTile(
|
||||
// title: Text(
|
||||
// 'Cargo Types',
|
||||
// style: TextStyle(
|
||||
// color: primaryColor, fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// children: <Widget>[
|
||||
// Container(
|
||||
// child: SingleChildScrollView(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// child: MyDataTable(
|
||||
// headingRowHeight: 40,
|
||||
// columnSpacing: 50,
|
||||
// columns: [
|
||||
// MyDataColumn(
|
||||
// label: Text("Cargo Type",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Rate",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Delete",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// ],
|
||||
// rows: getCargoRows(
|
||||
// shipmentRateModel.rate.cargoTypes),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// padding:
|
||||
// EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||
// child: Align(
|
||||
// alignment: Alignment.bottomRight,
|
||||
// child: Container(
|
||||
// width: 120,
|
||||
// height: 40,
|
||||
// child: FloatingActionButton.extended(
|
||||
// materialTapTargetSize:
|
||||
// MaterialTapTargetSize.shrinkWrap,
|
||||
// icon: Icon(Icons.add),
|
||||
// onPressed: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// CupertinoPageRoute(
|
||||
// builder: (context) => CargoEditor()),
|
||||
// );
|
||||
// },
|
||||
// label: Text(
|
||||
// 'Add Cargo',
|
||||
// style: TextStyle(fontSize: 12),
|
||||
// ),
|
||||
// backgroundColor: primaryColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ExpansionTile(
|
||||
// title: Text(
|
||||
// 'Custom Duties',
|
||||
// style: TextStyle(
|
||||
// color: primaryColor, fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// children: <Widget>[
|
||||
// Container(
|
||||
// child: SingleChildScrollView(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// child: MyDataTable(
|
||||
// headingRowHeight: 40,
|
||||
// columnSpacing: 50,
|
||||
// columns: [
|
||||
// MyDataColumn(
|
||||
// label: Text("Produt Type",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Fee",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Delete",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// ],
|
||||
// rows: getCustomsRows(
|
||||
// shipmentRateModel.rate.customDuties),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// padding:
|
||||
// EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||
// child: Align(
|
||||
// alignment: Alignment.bottomRight,
|
||||
// child: Container(
|
||||
// width: 120,
|
||||
// height: 40,
|
||||
// child: FloatingActionButton.extended(
|
||||
// materialTapTargetSize:
|
||||
// MaterialTapTargetSize.shrinkWrap,
|
||||
// icon: Icon(Icons.add),
|
||||
// onPressed: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// CupertinoPageRoute(
|
||||
// builder: (context) => CustomEditor()),
|
||||
// );
|
||||
// },
|
||||
// label: Text(
|
||||
// 'Add Custom\nDuty',
|
||||
// style: TextStyle(fontSize: 12),
|
||||
// ),
|
||||
// backgroundColor: primaryColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ExpansionTile(
|
||||
// title: Text(
|
||||
// 'Discounts by weight',
|
||||
// style: TextStyle(
|
||||
// color: primaryColor, fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// children: <Widget>[
|
||||
// Container(
|
||||
// child: SingleChildScrollView(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// child: MyDataTable(
|
||||
// headingRowHeight: 40,
|
||||
// columnSpacing: 30,
|
||||
// columns: [
|
||||
// MyDataColumn(
|
||||
// label: Text("Weight",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Discount Rate",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Delete",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// ],
|
||||
// rows: getDiscounts(
|
||||
// shipmentRateModel.rate.discountByWeights),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// padding:
|
||||
// EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||
// child: Align(
|
||||
// alignment: Alignment.bottomRight,
|
||||
// child: Container(
|
||||
// width: 130,
|
||||
// height: 40,
|
||||
// child: FloatingActionButton.extended(
|
||||
// materialTapTargetSize:
|
||||
// MaterialTapTargetSize.shrinkWrap,
|
||||
// icon: Icon(Icons.add),
|
||||
// onPressed: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// CupertinoPageRoute(
|
||||
// builder: (context) =>
|
||||
// DiscountByWeightEditor()),
|
||||
// );
|
||||
// },
|
||||
// label: Text(
|
||||
// 'Add Discount',
|
||||
// style: TextStyle(fontSize: 12),
|
||||
// ),
|
||||
// backgroundColor: primaryColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -311,7 +113,7 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
||||
deliveryFee: double.parse(_deliveryFee.text),
|
||||
freeDeliveryWeight: double.parse(_minWeight.text),
|
||||
volumetricRatio: double.parse(_volumetricRatio.text));
|
||||
Rate r = new Rate();
|
||||
Rate r = new Rate();
|
||||
print('_rate =>$r');
|
||||
await shipmentRateModel.updateRate(_rate);
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -10,7 +10,8 @@ class LengthPicker extends StatefulWidget {
|
||||
final String lableKey;
|
||||
final bool isReadOnly;
|
||||
|
||||
const LengthPicker({Key key, this.controller, this.lableKey, this.isReadOnly})
|
||||
const LengthPicker(
|
||||
{Key key, this.controller, this.lableKey, this.isReadOnly = false})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -42,9 +43,7 @@ class _LengthPickerState extends State<LengthPicker> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () => widget.isReadOnly == null
|
||||
? _showDialog(context)
|
||||
: widget.isReadOnly ? null : _showDialog(context),
|
||||
onTap: widget.isReadOnly ? null : () => _showDialog(context),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 8, right: 8),
|
||||
child: InputText(
|
||||
|
||||
Reference in New Issue
Block a user