Files
fcs/lib/pages/carton/carton_info.dart

784 lines
25 KiB
Dart
Raw Normal View History

2020-10-20 06:19:10 +06:30
import 'package:fcs/domain/constants.dart';
2024-02-05 17:28:53 +06:30
import 'package:fcs/domain/entities/cargo_type.dart';
2020-10-20 06:19:10 +06:30
import 'package:fcs/domain/entities/carton.dart';
2020-10-14 16:53:16 +06:30
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/carton/carton_image_upload.dart';
2021-01-07 18:15:39 +06:30
import 'package:fcs/pages/carton_size/model/carton_size_model.dart';
2020-10-14 16:53:16 +06:30
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/package/model/package_model.dart';
2020-10-15 03:06:13 +06:30
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
2020-10-14 16:53:16 +06:30
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/length_picker.dart';
2024-01-25 17:40:35 +06:30
import 'package:fcs/pages/widgets/local_app_bar.dart';
2020-10-14 16:53:16 +06:30
import 'package:fcs/pages/widgets/local_text.dart';
2024-02-05 17:28:53 +06:30
import 'package:fcs/pages/widgets/multi_img_controller.dart';
import 'package:fcs/pages/widgets/multi_img_file.dart';
2020-10-14 16:53:16 +06:30
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
2021-09-10 12:00:08 +06:30
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
2020-10-14 16:53:16 +06:30
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
2020-10-19 05:13:49 +06:30
import 'carton_editor.dart';
2020-12-11 17:34:56 +06:30
import 'carton_row.dart';
2020-10-18 02:38:46 +06:30
import 'model/carton_model.dart';
2020-10-14 16:53:16 +06:30
final DateFormat dateFormat = DateFormat("d MMM yyyy");
final NumberFormat numberFormatter = NumberFormat("#,###");
2020-10-14 16:53:16 +06:30
2020-10-19 05:13:49 +06:30
class CartonInfo extends StatefulWidget {
2024-02-05 17:28:53 +06:30
final Package? package;
2024-02-06 17:42:12 +06:30
final Carton box;
2024-02-05 17:28:53 +06:30
2024-02-06 17:42:12 +06:30
CartonInfo({required this.box,this.package});
2020-10-14 16:53:16 +06:30
@override
2020-10-19 05:13:49 +06:30
_CartonInfoState createState() => _CartonInfoState();
2020-10-14 16:53:16 +06:30
}
2020-10-19 05:13:49 +06:30
class _CartonInfoState extends State<CartonInfo> {
2020-10-14 16:53:16 +06:30
bool _isLoading = false;
2021-09-10 12:00:08 +06:30
Carton? _box;
2024-02-05 17:28:53 +06:30
2024-02-06 17:42:12 +06:30
2024-02-07 17:32:39 +06:30
// DeliveryAddress? _deliveryAddress = new DeliveryAddress();
2024-02-05 17:28:53 +06:30
MultiImgController multiImgController = MultiImgController();
2020-10-14 16:53:16 +06:30
TextEditingController _widthController = new TextEditingController();
TextEditingController _heightController = new TextEditingController();
TextEditingController _lengthController = new TextEditingController();
2020-12-11 17:34:56 +06:30
TextEditingController _cartonSizeController = new TextEditingController();
2020-10-14 16:53:16 +06:30
double volumetricRatio = 0;
double shipmentWeight = 0;
2021-09-10 12:00:08 +06:30
String? selectMixBoxType;
2020-10-14 16:53:16 +06:30
2021-09-10 12:00:08 +06:30
bool isMixBox = false;
bool isFromShipments = false;
bool isFromPackages = false;
bool isSmallBag = false;
bool isFromCartons = false;
bool isEdiable = false;
final List<CargoType> cargoTypes=[];
final List<CargoType> surchareItems=[];
2020-10-14 16:53:16 +06:30
@override
void initState() {
super.initState();
_box = widget.box;
2024-02-06 17:42:12 +06:30
//initPackage(widget.package!);
2020-10-14 16:53:16 +06:30
//for shipment weight
2020-10-15 03:06:13 +06:30
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
.rate
.volumetricRatio;
2020-10-14 16:53:16 +06:30
_lengthController.addListener(_calShipmentWeight);
_widthController.addListener(_calShipmentWeight);
_heightController.addListener(_calShipmentWeight);
multiImgController.setImageUrls = _box!.photos;
2020-10-21 02:59:10 +06:30
_updateBoxData();
_loadPackages();
2021-01-10 15:56:27 +06:30
_loadMixCartons();
2020-10-21 02:59:10 +06:30
}
2024-02-06 17:42:12 +06:30
2020-10-21 02:59:10 +06:30
_updateBoxData() {
2021-09-10 12:00:08 +06:30
_widthController.text = _box!.width.toString();
_heightController.text = _box!.height.toString();
_lengthController.text = _box!.length.toString();
2021-09-10 16:33:52 +06:30
_cartonSizeController.text = _box!.cartonSizeName ?? "";
2024-02-07 17:32:39 +06:30
// _deliveryAddress = _box!.deliveryAddress;
2021-09-10 12:00:08 +06:30
isMixBox = _box!.cartonType == carton_mix_box;
isFromShipments = _box!.cartonType == carton_from_shipments;
isFromPackages = _box!.cartonType == carton_from_packages;
isSmallBag = _box!.cartonType == carton_small_bag;
isFromCartons = _box!.cartonType == carton_from_cartons;
2021-01-09 19:11:47 +06:30
isEdiable = (isFromPackages || isMixBox || isFromCartons) &&
2021-09-10 12:00:08 +06:30
_box!.status == carton_packed_status;
selectMixBoxType = _box!.mixBoxType;
2021-01-07 18:15:39 +06:30
getCartonSize();
2020-10-20 06:19:10 +06:30
}
2021-01-07 18:15:39 +06:30
getCartonSize() {
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
cartonSizeModel.cartonSizes.forEach((c) {
2021-09-10 12:00:08 +06:30
if (c.length == _box!.length &&
c.width == _box!.width &&
c.height == _box!.height) {
2021-01-07 18:15:39 +06:30
setState(() {
2021-09-10 16:33:52 +06:30
_cartonSizeController.text = c.name ?? "";
2021-01-07 18:15:39 +06:30
});
}
});
}
2020-10-20 06:19:10 +06:30
_loadPackages() async {
2020-10-21 02:59:10 +06:30
if (!isFromPackages && !isSmallBag) return;
2021-09-10 12:00:08 +06:30
if (_box!.cartonType == carton_from_packages && _box!.userID == null)
return;
2020-10-20 06:19:10 +06:30
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
2021-09-10 16:33:52 +06:30
List<Package> packages =
await packageModel.getPackages(_box!.userID ?? "", [
2020-10-21 02:59:10 +06:30
package_processed_status,
package_packed_status,
2020-10-23 01:27:23 +06:30
package_shipped_status,
package_delivered_status
2020-10-21 02:59:10 +06:30
]);
2021-09-10 12:00:08 +06:30
packages = packages.where((p) => _box!.packageIDs.contains(p.id)).toList();
2020-10-20 06:19:10 +06:30
packages.forEach((p) {
2020-10-21 02:59:10 +06:30
p.isChecked = true;
2020-10-20 06:19:10 +06:30
});
setState(() {
2021-09-10 12:00:08 +06:30
_box!.packages = packages;
2020-10-20 06:19:10 +06:30
});
2020-10-14 16:53:16 +06:30
}
2021-01-10 15:56:27 +06:30
_loadMixCartons() async {
2021-09-10 12:00:08 +06:30
if (_box!.cartonType != carton_mix_box) return;
2021-01-10 15:56:27 +06:30
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
List<Carton> catons = [];
2021-09-10 12:00:08 +06:30
for (var id in _box!.mixCartonIDs) {
2021-01-10 15:56:27 +06:30
Carton c = await cartonModel.getCarton(id);
catons.add(c);
}
setState(() {
2021-09-10 12:00:08 +06:30
_box!.mixCartons = catons;
2021-01-10 15:56:27 +06:30
});
}
2020-10-14 16:53:16 +06:30
_calShipmentWeight() {
2021-09-13 09:51:55 +06:30
double l = double.tryParse(_lengthController.text) ?? 0;
double w = double.tryParse(_widthController.text) ?? 0;
double h = double.tryParse(_heightController.text) ?? 0;
2020-10-14 16:53:16 +06:30
setState(() {
shipmentWeight = l * w * h / volumetricRatio;
});
}
@override
void dispose() {
super.dispose();
}
final DateFormat dateFormat = DateFormat("d MMM yyyy");
@override
Widget build(BuildContext context) {
2024-02-07 17:32:39 +06:30
double totalWeight = _box!.cargoTypes.fold(0, (sum, value) => sum + value.weight);
double totalPieces = surchareItems.fold(0, (sum, value) => sum + value.qty);
// final cartonTypeBox = LocalRadioButtons(
// readOnly: true,
// values: cartonModel.cartonTypesInfo,
// selectedValue: (_box!.isShipmentCarton ?? false)
// ? carton_from_shipments
// : _box!.cartonType);
final cartonTypeBox = DisplayText(
text: _box!.cartonNumber,
labelTextKey: "box.number",
//iconData: Ionicons.ios_airplane,
);
final cartonQrBox = DisplayText(
2024-02-05 11:13:12 +06:30
// text: _box!.,
//labelTextKey: "box.number",
iconData: AntDesign.qrcode,
);
2020-10-14 16:53:16 +06:30
final shipmentBox = DisplayText(
2021-09-10 12:00:08 +06:30
text: _box!.fcsShipmentNumber,
2020-10-14 16:53:16 +06:30
labelTextKey: "box.fcs_shipment_num",
2024-02-05 11:13:12 +06:30
// iconData: Ionicons.ios_airplane,
);
final deliveryBox = DisplayText(
text: "Delivery Carton",
labelTextKey: "box.delivery_type",
//icon: FcsIDIcon(),
2020-10-14 16:53:16 +06:30
);
// final fcsIDBox = DisplayText(
// text: _box!.fcsID == null ? "" : _box!.fcsID,
// labelTextKey: "box.fcs.id",
// //icon: FcsIDIcon(),
// );
2020-10-14 16:53:16 +06:30
final customerNameBox = DisplayText(
2021-09-10 12:00:08 +06:30
text: _box!.userName == null ? "" : _box!.userName,
2024-02-05 11:13:12 +06:30
subText: Text(_box!.fcsID ?? "", style: textStyle),
2020-10-14 16:53:16 +06:30
labelTextKey: "box.name",
2024-02-05 11:13:12 +06:30
//iconData: Icons.person,
2020-10-14 16:53:16 +06:30
);
// final consigneefcsIDBox = DisplayText(
// text: _box!.fcsID != null ? _box!.fcsID : "",
// labelTextKey: "processing.fcs.id",
// icon: FcsIDIcon(),
// );
2021-01-09 19:11:47 +06:30
final consigneeNameBox = DisplayText(
2024-02-05 17:28:53 +06:30
text: _box!.senderName != null ? _box!.senderName : "",
subText: Text(_box!.senderFCSID ?? "", style: textStyle),
2024-02-05 11:13:12 +06:30
2021-01-09 19:11:47 +06:30
labelTextKey: "processing.consignee.name",
//maxLines: 2,
2024-02-05 11:11:44 +06:30
// iconData: Ionicons.document_text_outline,
2021-01-09 19:11:47 +06:30
);
// final consigneeBox = Container(
// child: Column(
// children: [
// consigneeNameBox,
// IconButton(icon:Icon(Ionicons.document_text_outline),
// onPressed:() {},),
// Text("Bill to",style:TextStyle(color:Color.fromARGB(255, 57, 80, 233)))
2024-02-05 11:11:44 +06:30
// ],
// ),
// );
2021-01-09 19:11:47 +06:30
// final shipperIDBox = Row(
// children: <Widget>[
// Expanded(
// child: DisplayText(
// text: _box!.senderFCSID,
// labelTextKey: "processing.fcs.id",
// icon: FcsIDIcon(),
// )),
// ],
// );
2021-01-09 19:11:47 +06:30
// final shipperNamebox = DisplayText(
// text: _box!.senderName,
// labelTextKey: "processing.shipper.name",
// maxLines: 2,
// iconData: Icons.person,
// );
2021-01-09 19:11:47 +06:30
// final shipperBox = Container(
// child: Column(
// children: [
// shipperIDBox,
// shipperNamebox,
// ],
// ),
// );
2021-01-09 19:11:47 +06:30
2020-10-14 16:53:16 +06:30
final lengthBox = LengthPicker(
controller: _lengthController,
lableKey: "box.length",
isReadOnly: true,
);
final widthBox = LengthPicker(
controller: _widthController,
lableKey: "box.width",
isReadOnly: true,
);
final heightBox = LengthPicker(
controller: _heightController,
lableKey: "box.height",
isReadOnly: true,
);
final dimBox = Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Icon(FontAwesome.arrow_circle_right, color: primaryColor),
),
SizedBox(child: lengthBox, width: 80),
SizedBox(child: widthBox, width: 80),
SizedBox(child: heightBox, width: 80),
],
);
2024-02-05 11:13:12 +06:30
final packageBox = DisplayText(
2024-02-05 17:28:53 +06:30
//text: "203FVH",
labelTextKey: "box.package",
2024-02-05 17:28:53 +06:30
);
final cargosBox = Padding(
padding: const EdgeInsets.only(top: 10),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
// Padding(
// padding: const EdgeInsets.only(left: 5, bottom: 5, right: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
LocalText(context, 'box.cargo.type',
color: Colors.black54,
fontSize: 16,
fontWeight: FontWeight.normal),
Padding(padding: EdgeInsets.only(right: 100),
child:
Text("${removeTrailingZeros(totalWeight)} lb",
style: TextStyle(color: Colors.black54, fontSize: 15)))
],
),
//),
Container(
// decoration: BoxDecoration(
// border: Border.all(color: primaryColor),
// borderRadius: BorderRadius.circular(5),
// ),
child: Padding(
padding: const EdgeInsets.only(right: 100),
child: Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _box!.cargoTypes.map((e) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
e.name ?? "",
style:
TextStyle(color: Colors.black, fontSize: 15),
),
Text("${removeTrailingZeros(e.weight)} lb",
style: TextStyle(
color: Colors.black, fontSize: 15))
],
),
);
}).toList()),
const SizedBox(height: 10),
],
),
),
),
]),
);
final surchargeItemBox = Padding(
padding: const EdgeInsets.only(top: 10),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
// Padding(
// padding: const EdgeInsets.only(left: 5, bottom: 5, right: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
LocalText(context, 'box.surcharge.item',
color: Colors.black54,
fontSize: 16,
fontWeight: FontWeight.normal),
Padding(padding: EdgeInsets.only(right: 100),
child:
Text("${removeTrailingZeros(totalPieces)} pcs",
style: TextStyle(color: Colors.black54, fontSize: 15)))
],
),
//),
Container(
// decoration: BoxDecoration(
// border: Border.all(color: primaryColor),
// borderRadius: BorderRadius.circular(5),
// ),
child: Padding(
padding: const EdgeInsets.only(right: 100),
child: Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: surchareItems.map((e) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
e.name ?? "",
style:
TextStyle(color: Colors.black, fontSize: 15),
),
Text("${removeTrailingZeros((e.qty).toDouble())} pc",
style: TextStyle(
color: Colors.black, fontSize: 15))
],
),
);
}).toList()),
const SizedBox(height: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: surchareItems.map((e) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
e.name ?? "",
style: TextStyle(color: labelColor, fontSize: 15),
),
Text("${numberFormatter.format(e.qty)} pc",
style:
TextStyle(color: labelColor, fontSize: 15))
],
),
);
}).toList()),
],
),
),
),
]),
);
2024-02-05 17:28:53 +06:30
final img = MultiImageFile(
enabled: false,
controller: multiImgController,
title: "Receipt File",
);
final billWidget
= Expanded(child:Padding(
padding: EdgeInsets.only(left: 0,top: 15),
child:
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(Ionicons.document_text_outline, color: primaryColor, size: 20),
Text("Bill to", style: TextStyle(color: primaryColor, fontSize: 15))
],
)));
2024-02-05 17:28:53 +06:30
final cargoBox = DisplayText(
//text: "203FVH",
labelTextKey: "box.cargo.type",
);
2020-10-14 16:53:16 +06:30
2020-12-11 17:34:56 +06:30
final cartonSizeBox = DisplayText(
text: _cartonSizeController.text,
labelTextKey: "box.carton_size",
iconData: AntDesign.CodeSandbox,
2020-10-14 16:53:16 +06:30
);
// final cargoTableBox = CargoTable(
// cargoTypes: _box!.cargoTypes,
// );
2024-01-23 16:28:08 +06:30
// final mixCartonNumberBox = DisplayText(
// text: _box!.mixCartonNumber,
// labelTextKey: "box.mix.carton",
// iconData: MaterialCommunityIcons.package,
// );
2020-10-14 16:53:16 +06:30
2020-12-11 17:34:56 +06:30
final mixTypeBox = Container(
padding: EdgeInsets.only(top: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(left: 5),
child: LocalText(
context,
"box.mix_type",
color: primaryColor,
fontSize: 15,
fontWeight: FontWeight.bold,
)),
Row(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
Icons.check,
color: primaryColor,
),
),
2021-09-10 12:00:08 +06:30
Text(selectMixBoxType ?? "")
2020-12-11 17:34:56 +06:30
],
)
],
),
);
2020-10-14 16:53:16 +06:30
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
2024-01-25 17:40:35 +06:30
appBar: LocalAppBar(
labelKey: "box.info.title",
2020-10-14 16:53:16 +06:30
backgroundColor: Colors.white,
2024-01-25 17:40:35 +06:30
labelColor: primaryColor,
arrowColor: primaryColor,
2020-10-20 06:19:10 +06:30
actions: isEdiable
? <Widget>[
IconButton(
icon: Icon(Icons.edit, color: primaryColor),
onPressed: _gotoEditor,
),
IconButton(
icon: Icon(Icons.delete, color: primaryColor),
onPressed: _delete,
),
]
: [],
2020-10-14 16:53:16 +06:30
),
body:
Container(
padding: const EdgeInsets.all(10.0),
child:
Column(children: [
2024-02-06 17:42:12 +06:30
Row(children:[
Flexible(child:
cartonTypeBox),
Flexible(child:
cartonQrBox,
),
2024-02-06 17:42:12 +06:30
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(child: shipmentBox,),
Flexible(child: deliveryBox,),
],),
2024-02-06 17:42:12 +06:30
Row(
mainAxisAlignment: MainAxisAlignment.start,
2024-02-06 17:42:12 +06:30
children: [
Expanded(
child: Row(
//crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
customerNameBox,
],
2024-02-06 17:42:12 +06:30
),
),
CargoType().isCutomDuty == false
? billWidget
: const SizedBox()
],
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
consigneeNameBox,
],
),
),
CargoType().isCutomDuty == true
? billWidget
: const SizedBox()
],
),
))
2024-02-06 17:42:12 +06:30
],),
2024-02-06 17:42:12 +06:30
packageBox,
Column(children:
getPackageList(_box!.packages),
),
cargosBox,
surchargeItemBox,
2024-02-05 17:28:53 +06:30
2024-02-06 17:42:12 +06:30
Flexible(child:
2024-02-05 17:28:53 +06:30
Padding(padding: EdgeInsets.only(left: 200.0,right: 8.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xff272262),
elevation: 3,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0)),
2024-02-06 17:42:12 +06:30
minimumSize: Size(10, 35), //////// HERE
2024-02-05 17:28:53 +06:30
),
onPressed: (){
Navigator.push(
context,
CupertinoPageRoute(builder: (context) => CartonImageUpload()),
);
},
2024-02-05 17:28:53 +06:30
child: const Text('Upload Images'),
),)),
2024-02-06 17:42:12 +06:30
img,
2024-02-05 17:28:53 +06:30
Center(child: ElevatedButton(
style: ElevatedButton.styleFrom(
2024-02-06 17:42:12 +06:30
backgroundColor:Color(0xffff0606),
2024-02-05 17:28:53 +06:30
elevation: 3,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0)),
minimumSize: Size(300, 45), //////// HERE
),
onPressed: (){},
child: const Text('Delete Carton',style:TextStyle(fontSize: 20)),
),),
2024-02-05 17:28:53 +06:30
//_package!.photoUrls.length == 0 || _package!.photoUrls.isEmpty ? Container() : img,
//LocalTitle(textKey: "box.shipment_info"),
2024-02-05 11:13:12 +06:30
// shipmentBox,
2021-01-09 19:11:47 +06:30
// isSmallBag ? mixCartonNumberBox : Container(),
// isMixBox
// ? Container()
// : isFromPackages
// ? fcsIDBox
// : Container(),
// isMixBox
// ? Container()
2024-02-06 17:42:12 +06:30
// : isFromPackages
// ? customerNameBox
// : Container(),
// isFromCartons
// ? Row(
// children: [
// Flexible(child: consigneeBox),
// Flexible(child: shipperBox)
// ],
// )
// : Container(),
2024-02-05 17:28:53 +06:30
// Padding(padding: EdgeInsets.only(left: 10),
// child: Row(children:[
// ListView.builder(
// itemCount: pickups.length,
// itemBuilder: (context, index) {
// return ListTile(
// title: Text(pickups[index]),
// );
// },)
2024-02-05 17:28:53 +06:30
// ])),
// // isMixBox ? mixTypeBox : Container(),
// isMixBox ? LocalTitle(textKey: "box.mix_caton_title") : Container(),
// isMixBox
// ? Column(children: _getCartons(context, _box!.mixCartons))
// : Container(),
// isFromPackages || isSmallBag
// ? CartonPackageTable(
// packages: _box!.packages,
// )
// : Container(),
// isMixBox ? Container() : LocalTitle(textKey: "box.cargo.type"),
// isMixBox ? Container() : cargoTableBox,
// ...(isFromPackages || isFromCartons
// ? [
// LocalTitle(textKey: "box.dimension"),
// cartonSizeBox,
// dimBox,
// ]
// : []),
// isMixBox
// ? Container()
// : LocalTitle(textKey: "box.delivery_address"),
// isMixBox
// ? Container()
// : DefaultDeliveryAddress(
// deliveryAddress: _deliveryAddress,
// labelKey: "box.delivery_address",
// ),
// SizedBox(
// height: 20,
// )
2024-02-06 17:42:12 +06:30
])
)
)
2024-02-06 17:42:12 +06:30
// ])
// )
// )
);
2020-10-14 16:53:16 +06:30
}
2020-12-11 17:34:56 +06:30
List<Widget> _getCartons(BuildContext context, List<Carton> cartons) {
return cartons.map((c) {
return CartonRow(box: c);
}).toList();
}
2024-02-06 17:42:12 +06:30
List<Widget> _getPackages(BuildContext context, List<Package> packages) {
return packages.map((p) {
return Text(p.packageType!);
}).toList();
}
2020-12-11 17:34:56 +06:30
2020-10-14 16:53:16 +06:30
_gotoEditor() async {
2021-09-10 12:00:08 +06:30
_box!.mixCartons = _box!.mixCartons;
bool? updated = await Navigator.push<bool>(
2020-10-14 16:53:16 +06:30
context,
2021-09-13 09:51:55 +06:30
CupertinoPageRoute(builder: (context) => CartonEditor(carton: _box)),
2020-10-14 16:53:16 +06:30
);
2020-10-20 06:19:10 +06:30
if (updated ?? false) {
var cartonModel = Provider.of<CartonModel>(context, listen: false);
2021-09-10 16:33:52 +06:30
var c = await cartonModel.getCarton(widget.box!.id ?? "");
2020-10-20 06:19:10 +06:30
setState(() {
_box = c;
2021-01-10 15:56:27 +06:30
_loadPackages();
_loadMixCartons();
2020-10-21 02:59:10 +06:30
_updateBoxData();
2020-10-20 06:19:10 +06:30
});
}
}
_delete() {
showConfirmDialog(context, "box.delete.confirm", () {
_deleteCarton();
});
}
_deleteCarton() async {
setState(() {
_isLoading = true;
});
try {
var cartonModel = Provider.of<CartonModel>(context, listen: false);
2021-09-10 12:00:08 +06:30
await cartonModel.deleteCarton(widget.box!);
2020-10-20 06:19:10 +06:30
Navigator.pop(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
2020-10-14 16:53:16 +06:30
}
2024-02-06 17:42:12 +06:30
List<Widget> getPackageList(List<Package> _p) {
return _p.map((p) {
return Container(
padding: EdgeInsets.only(top: 0),
child: Container(
//padding:
//EdgeInsets.only(top: 0.0),
child: Row(children:<Widget> [
new Text(p.packageType ?? '')
]),
));}).toList();
}
List<Widget> getCargoList(List<CargoType> _c) {
return _c.map((c) {
return Container(
padding: EdgeInsets.only(top: 0),
child: Container(
//padding:
//EdgeInsets.only(top: 0.0),
child: Row(children:<Widget> [
new Text(c.name ?? '')
]),
));}).toList();
}
2020-10-14 16:53:16 +06:30
}