2020-10-20 06:19:10 +06:30
|
|
|
import 'package:fcs/domain/constants.dart';
|
2020-12-11 17:34:56 +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';
|
2021-01-07 18:15:39 +06:30
|
|
|
import 'package:fcs/domain/entities/carton_size.dart';
|
2020-10-14 16:53:16 +06:30
|
|
|
import 'package:fcs/domain/entities/package.dart';
|
|
|
|
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
|
|
|
|
import 'package:fcs/helpers/theme.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/defalut_delivery_address.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/display_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/length_picker.dart';
|
2020-10-20 06:19:10 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
|
2020-10-14 16:53:16 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/local_title.dart';
|
|
|
|
|
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-12-10 20:06:15 +06:30
|
|
|
import 'cargo_table.dart';
|
2020-10-19 05:13:49 +06:30
|
|
|
import 'carton_editor.dart';
|
2020-10-20 06:19:10 +06:30
|
|
|
import 'carton_package_table.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-20 06:19:10 +06:30
|
|
|
import 'widgets.dart';
|
2020-10-14 16:53:16 +06:30
|
|
|
|
|
|
|
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
|
|
|
|
|
2020-10-19 05:13:49 +06:30
|
|
|
class CartonInfo extends StatefulWidget {
|
2021-09-10 12:00:08 +06:30
|
|
|
final Carton? box;
|
2020-10-19 05:13:49 +06:30
|
|
|
CartonInfo({this.box});
|
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;
|
2020-10-14 16:53:16 +06:30
|
|
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
|
|
|
|
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;
|
2020-10-20 06:19:10 +06:30
|
|
|
|
2020-10-14 16:53:16 +06:30
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_box = widget.box;
|
|
|
|
|
//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);
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_updateBoxData() {
|
2021-09-10 12:00:08 +06:30
|
|
|
_widthController.text = _box!.width.toString();
|
|
|
|
|
_heightController.text = _box!.height.toString();
|
|
|
|
|
_lengthController.text = _box!.length.toString();
|
|
|
|
|
_cartonSizeController.text = _box!.cartonSizeName;
|
|
|
|
|
_deliveryAddress = _box!.deliveryAddress;
|
|
|
|
|
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(() {
|
|
|
|
|
_cartonSizeController.text = c.name;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
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 12:00:08 +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() {
|
|
|
|
|
double l = double.parse(_lengthController.text, (s) => 0);
|
|
|
|
|
double w = double.parse(_widthController.text, (s) => 0);
|
|
|
|
|
double h = double.parse(_heightController.text, (s) => 0);
|
|
|
|
|
setState(() {
|
|
|
|
|
shipmentWeight = l * w * h / volumetricRatio;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2020-10-20 06:19:10 +06:30
|
|
|
var cartonModel = Provider.of<CartonModel>(context);
|
2020-10-14 16:53:16 +06:30
|
|
|
|
2020-10-20 06:19:10 +06:30
|
|
|
final cartonTypeBox = LocalRadioButtons(
|
|
|
|
|
readOnly: true,
|
|
|
|
|
values: cartonModel.cartonTypesInfo,
|
|
|
|
|
selectedValue:
|
2021-09-10 12:00:08 +06:30
|
|
|
_box!.isShipmentCarton ? carton_from_shipments : _box!.cartonType);
|
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",
|
|
|
|
|
iconData: Ionicons.ios_airplane,
|
|
|
|
|
);
|
|
|
|
|
final fcsIDBox = DisplayText(
|
2021-09-10 12:00:08 +06:30
|
|
|
text: _box!.fcsID == null ? "" : _box!.fcsID,
|
2020-10-14 16:53:16 +06:30
|
|
|
labelTextKey: "box.fcs.id",
|
|
|
|
|
icon: FcsIDIcon(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final customerNameBox = DisplayText(
|
2021-09-10 12:00:08 +06:30
|
|
|
text: _box!.userName == null ? "" : _box!.userName,
|
2020-10-14 16:53:16 +06:30
|
|
|
labelTextKey: "box.name",
|
|
|
|
|
iconData: Icons.person,
|
|
|
|
|
);
|
|
|
|
|
|
2021-01-09 19:11:47 +06:30
|
|
|
final consigneefcsIDBox = DisplayText(
|
2021-09-10 12:00:08 +06:30
|
|
|
text: _box!.fcsID != null ? _box!.fcsID : "",
|
2021-01-09 19:11:47 +06:30
|
|
|
labelTextKey: "processing.fcs.id",
|
|
|
|
|
icon: FcsIDIcon(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final consigneeNameBox = DisplayText(
|
2021-09-10 12:00:08 +06:30
|
|
|
text: _box!.userName != null ? _box!.userName : "",
|
2021-01-09 19:11:47 +06:30
|
|
|
labelTextKey: "processing.consignee.name",
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
iconData: Icons.person,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final consigneeBox = Container(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
consigneefcsIDBox,
|
|
|
|
|
consigneeNameBox,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final shipperIDBox = Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: DisplayText(
|
2021-09-10 12:00:08 +06:30
|
|
|
text: _box!.senderFCSID,
|
2021-01-09 19:11:47 +06:30
|
|
|
labelTextKey: "processing.fcs.id",
|
|
|
|
|
icon: FcsIDIcon(),
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final shipperNamebox = DisplayText(
|
2021-09-10 12:00:08 +06:30
|
|
|
text: _box!.senderName,
|
2021-01-09 19:11:47 +06:30
|
|
|
labelTextKey: "processing.shipper.name",
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
iconData: Icons.person,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final shipperBox = Container(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
shipperIDBox,
|
|
|
|
|
shipperNamebox,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
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),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
|
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
|
|
|
);
|
2020-10-20 06:19:10 +06:30
|
|
|
final cargoTableBox = CargoTable(
|
2021-09-10 12:00:08 +06:30
|
|
|
cargoTypes: _box!.cargoTypes,
|
2020-10-20 06:19:10 +06:30
|
|
|
);
|
2020-10-21 02:59:10 +06:30
|
|
|
final mixCartonNumberBox = DisplayText(
|
2021-09-10 12:00:08 +06:30
|
|
|
text: _box!.mixCartonNumber,
|
2020-10-21 02:59:10 +06:30
|
|
|
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(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
leading: new IconButton(
|
|
|
|
|
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
|
|
|
|
shadowColor: Colors.transparent,
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
title: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"box.info.title",
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
color: 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
|
|
|
),
|
2020-10-21 02:59:10 +06:30
|
|
|
body: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(10.0),
|
2020-12-11 17:34:56 +06:30
|
|
|
child: ListView(shrinkWrap: true, children: <Widget>[
|
2021-09-10 12:00:08 +06:30
|
|
|
Center(child: getCartonNumberStatus(context, _box!)),
|
2020-10-21 02:59:10 +06:30
|
|
|
LocalTitle(textKey: "box.type.title"),
|
|
|
|
|
cartonTypeBox,
|
|
|
|
|
LocalTitle(textKey: "box.shipment_info"),
|
|
|
|
|
shipmentBox,
|
2021-01-09 19:11:47 +06:30
|
|
|
// isSmallBag ? mixCartonNumberBox : Container(),
|
|
|
|
|
isMixBox
|
|
|
|
|
? Container()
|
|
|
|
|
: isFromPackages
|
|
|
|
|
? fcsIDBox
|
|
|
|
|
: Container(),
|
|
|
|
|
isMixBox
|
|
|
|
|
? Container()
|
|
|
|
|
: isFromPackages
|
|
|
|
|
? customerNameBox
|
|
|
|
|
: Container(),
|
|
|
|
|
isFromCartons
|
|
|
|
|
? Row(
|
|
|
|
|
children: [
|
|
|
|
|
Flexible(child: consigneeBox),
|
|
|
|
|
Flexible(child: shipperBox)
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
2020-12-11 17:34:56 +06:30
|
|
|
isMixBox ? mixTypeBox : Container(),
|
2021-01-09 19:11:47 +06:30
|
|
|
isMixBox ? LocalTitle(textKey: "box.mix_caton_title") : Container(),
|
2020-12-11 17:34:56 +06:30
|
|
|
isMixBox
|
2021-09-10 12:00:08 +06:30
|
|
|
? Column(children: _getCartons(context, _box!.mixCartons))
|
2020-12-11 17:34:56 +06:30
|
|
|
: Container(),
|
2020-10-21 02:59:10 +06:30
|
|
|
isFromPackages || isSmallBag
|
|
|
|
|
? CartonPackageTable(
|
2021-09-10 12:00:08 +06:30
|
|
|
packages: _box!.packages,
|
2020-10-21 02:59:10 +06:30
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
isMixBox ? Container() : LocalTitle(textKey: "box.cargo.type"),
|
|
|
|
|
isMixBox ? Container() : cargoTableBox,
|
2021-01-09 19:11:47 +06:30
|
|
|
...(isFromPackages || isFromCartons
|
2020-10-21 02:59:10 +06:30
|
|
|
? [
|
|
|
|
|
LocalTitle(textKey: "box.dimension"),
|
2020-12-11 17:34:56 +06:30
|
|
|
cartonSizeBox,
|
2020-10-21 02:59:10 +06:30
|
|
|
dimBox,
|
|
|
|
|
]
|
|
|
|
|
: []),
|
|
|
|
|
isMixBox
|
|
|
|
|
? Container()
|
|
|
|
|
: LocalTitle(textKey: "box.delivery_address"),
|
|
|
|
|
isMixBox
|
|
|
|
|
? Container()
|
|
|
|
|
: DefaultDeliveryAddress(
|
2020-10-14 16:53:16 +06:30
|
|
|
deliveryAddress: _deliveryAddress,
|
|
|
|
|
labelKey: "box.delivery_address",
|
|
|
|
|
),
|
2020-10-21 02:59:10 +06:30
|
|
|
SizedBox(
|
|
|
|
|
height: 20,
|
|
|
|
|
)
|
|
|
|
|
]),
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
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-01-23 23:55:53 +06:30
|
|
|
CupertinoPageRoute(builder: (context) => CartonEditor(box: _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 12:00:08 +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
|
|
|
}
|
|
|
|
|
}
|