add carton editor for package

This commit is contained in:
tzw
2024-02-05 17:49:12 +06:30
parent afb980e6ae
commit a9e16ede8f
17 changed files with 1216 additions and 82 deletions

View File

@@ -14,13 +14,14 @@ import '../widgets/box_size_picker.dart';
import '../widgets/continue_button.dart';
import '../widgets/display_text.dart';
import '../widgets/local_dropdown.dart';
import '../widgets/local_radio_buttons.dart';
import '../widgets/local_text.dart';
import '../widgets/local_title.dart';
import '../widgets/previous_button.dart';
typedef OnPrevious = Function();
typedef OnContinue = Function(FcsShipment shipment, String cartonSizeType,
typedef OnContinue = Function(String deliveryType,FcsShipment shipment, String cartonSizeType,
{CartonSize? standardSize, double? length, double? width, double? height});
class CartonSizeWidget extends StatefulWidget {
@@ -28,6 +29,7 @@ class CartonSizeWidget extends StatefulWidget {
final OnContinue? onContinue;
final User sender;
final User consignee;
final String deliveryType;
final FcsShipment? shipment;
final String cartonSizeType;
final CartonSize? standardSize;
@@ -46,7 +48,8 @@ class CartonSizeWidget extends StatefulWidget {
this.width,
this.height,
required this.sender,
required this.consignee})
required this.consignee,
required this.deliveryType})
: super(key: key);
@override
@@ -54,11 +57,14 @@ class CartonSizeWidget extends StatefulWidget {
}
class _CartonSizeWidgetState extends State<CartonSizeWidget> {
List<String> _deliveryTypes = [delivery_caton, pickup_carton];
FcsShipment? _shipment;
String _cartionSizeType = standardCarton;
List<FcsShipment> _shipments = [];
CartonSize? _selectStandardSize;
late String _selectedDeliveryType;
TextEditingController _widthController = new TextEditingController();
TextEditingController _heightController = new TextEditingController();
@@ -71,9 +77,10 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
}
_init() async {
_selectedDeliveryType = widget.deliveryType;
_shipment = widget.shipment;
_cartionSizeType = widget.cartonSizeType;
List<CartonSize> cartonSizes = context.read<CartonSizeModel>().cartonSizes;
_selectStandardSize = widget.standardSize ?? cartonSizes.first;
@@ -104,17 +111,21 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
text: widget.sender.name,
labelTextKey: "box.sender.title",
iconData: MaterialCommunityIcons.account_arrow_right,
subText: Text(widget.sender.fcsID!,
style: TextStyle(fontSize: 13, color: labelColor)),
);
final consigneeBox = DisplayText(
text: widget.consignee.name,
labelTextKey: "box.consignee.title",
iconData: MaterialCommunityIcons.account_arrow_left,
subText: Text(widget.consignee.fcsID!,
style: TextStyle(fontSize: 13, color: labelColor)),
);
final userRow = Row(
children: [
Flexible(
Expanded(
child: senderBox,
flex: 2,
),
@@ -122,6 +133,15 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
],
);
final deliveryTypeBox = LocalRadioButtons(
values: _deliveryTypes,
selectedValue: _selectedDeliveryType,
callback: (String? v) {
setState(() {
_selectedDeliveryType = v!;
});
});
final continueBtn = ContinueButton(onTap: () {
double l = double.tryParse(_lengthController.text) ?? 0;
double w = double.tryParse(_widthController.text) ?? 0;
@@ -137,7 +157,7 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
!isCustomSize &&
!isNoneDefinedSize) {
showMsgDialog(
context, "Error", "Please select the standard cartion size");
context, "Error", "Please select the standard carton size");
return;
}
@@ -145,12 +165,12 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
!isStandardSize &&
!isNoneDefinedSize &&
(l == 0 || w == 0 || h == 0)) {
showMsgDialog(context, "Error", "Please add the cartion size");
showMsgDialog(context, "Error", "Please add the carton size");
return;
}
if (widget.onContinue != null) {
widget.onContinue!(_shipment!, _cartionSizeType,
widget.onContinue!(_selectedDeliveryType,_shipment!, _cartionSizeType,
standardSize: _selectStandardSize, length: l, width: w, height: h);
}
});
@@ -346,13 +366,18 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
children: [
const SizedBox(height: 8),
userRow,
LocalTitle(textKey: "box.select.delivery", topPadding: 10),
const SizedBox(height: 5),
deliveryTypeBox,
const SizedBox(height: 5),
LocalTitle(textKey: "box.select_carton_size"),
const SizedBox(height: 8),
cartonSizedBox,
const SizedBox(height: 8),
LocalTitle(textKey: "box.select_shipment"),
const SizedBox(height: 5),
fcsShipmentsBox
fcsShipmentsBox,
const SizedBox(height: 30)
],
)),
Padding(