update cartion editor for package
This commit is contained in:
@@ -137,3 +137,7 @@ const payment_canceled_status = "canceled";
|
||||
//Delivery types
|
||||
const delivery_caton = "Delivery carton";
|
||||
const pickup_carton = "Pick-up carton";
|
||||
|
||||
// bill
|
||||
const billToSender ="Bill to sender";
|
||||
const billToConsignee="Bill to consignee";
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../../domain/entities/cargo_type.dart';
|
||||
import '../../domain/entities/user.dart';
|
||||
import '../main/util.dart';
|
||||
import '../rates/model/shipment_rate_model.dart';
|
||||
import '../widgets/continue_button.dart';
|
||||
import '../widgets/display_text.dart';
|
||||
@@ -22,14 +23,14 @@ class CargoWidget extends StatefulWidget {
|
||||
final User sender;
|
||||
final User consignee;
|
||||
final List<CargoType> cargoTypes;
|
||||
final List<CargoType> customDuties;
|
||||
final List<CargoType> surchargeItems;
|
||||
final OnPrevious? onPrevious;
|
||||
final OnContinue? onContinue;
|
||||
|
||||
const CargoWidget({
|
||||
Key? key,
|
||||
required this.cargoTypes,
|
||||
required this.customDuties,
|
||||
required this.surchargeItems,
|
||||
this.onPrevious,
|
||||
this.onContinue,
|
||||
required this.sender,
|
||||
@@ -42,9 +43,10 @@ class CargoWidget extends StatefulWidget {
|
||||
|
||||
class _CargoWidgetState extends State<CargoWidget> {
|
||||
List<CargoType> _cargoTypes = [];
|
||||
List<CargoType> _customDuties = [];
|
||||
List<CargoType> _surchareItems = [];
|
||||
TextEditingController _totalCtl = TextEditingController();
|
||||
List<TextEditingController> _cargoTypeControllers = [];
|
||||
List<TextEditingController> _surchargeControllers = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -53,10 +55,28 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
}
|
||||
|
||||
_init() {
|
||||
// for cargo types
|
||||
var model = context.read<ShipmentRateModel>();
|
||||
_cargoTypes = model.rate.cargoTypes.map((e) => e.clone()).toList();
|
||||
|
||||
if (widget.cargoTypes.isNotEmpty) {
|
||||
_cargoTypes.forEach((mp) {
|
||||
mp.weight = 0;
|
||||
widget.cargoTypes.forEach((vp) {
|
||||
if (mp.id == vp.id) {
|
||||
mp.weight = vp.weight;
|
||||
}
|
||||
});
|
||||
});
|
||||
_cargoTypes.forEach((e) {
|
||||
var editor = new TextEditingController();
|
||||
editor.text = removeTrailingZeros(e.weight);
|
||||
editor.addListener(inputChangeListener);
|
||||
_cargoTypeControllers.add(editor);
|
||||
});
|
||||
|
||||
double total = _cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
||||
_totalCtl.text = removeTrailingZeros(total);
|
||||
} else {
|
||||
_cargoTypes.forEach((e) {
|
||||
var editor = new TextEditingController();
|
||||
@@ -66,6 +86,18 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
});
|
||||
}
|
||||
|
||||
//for surcharge items
|
||||
|
||||
if (widget.surchargeItems.isNotEmpty) {
|
||||
_surchareItems = List.from(widget.surchargeItems);
|
||||
_surchareItems.forEach((e) {
|
||||
var editor = new TextEditingController();
|
||||
editor.text = e.qty.toString();
|
||||
editor.addListener(inputChangeListener);
|
||||
_surchargeControllers.add(editor);
|
||||
});
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
@@ -87,11 +119,6 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
|
||||
inputChangeListener() {
|
||||
List<int> emptyFields = getEmptyFields();
|
||||
print("emptyFields:$emptyFields");
|
||||
|
||||
// if (emptyFields.isNotEmpty && emptyFields.length == 1) {
|
||||
// // _cargoTypeControllers[emptyFields.first].text =
|
||||
// }
|
||||
|
||||
if (emptyFields.isEmpty) {
|
||||
_cargoTypes.asMap().entries.forEach((e) {
|
||||
@@ -100,29 +127,8 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
});
|
||||
double total = _cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
||||
setState(() {
|
||||
_totalCtl.text = total.toString();
|
||||
_totalCtl.text = removeTrailingZeros(total);
|
||||
});
|
||||
} else {
|
||||
// if (emptyFields.length == 1) {
|
||||
// print("_totalCtl.text:${_totalCtl.text}");
|
||||
|
||||
// if (_totalCtl.text.isNotEmpty) {
|
||||
// double t = double.tryParse(_totalCtl.text) ?? 0;
|
||||
|
||||
// _cargoTypes.asMap().entries.forEach((e) {
|
||||
// _cargoTypes[e.key].weight =
|
||||
// double.tryParse(_cargoTypeControllers[e.key].text) ?? 0;
|
||||
// });
|
||||
// double result =
|
||||
// _cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
||||
|
||||
// double remaining = t - result;
|
||||
// setState(() {
|
||||
// _cargoTypeControllers[emptyFields.first].text =
|
||||
// remaining.toString();
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,10 +152,7 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
|
||||
final userRow = Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: senderBox,
|
||||
flex: 2,
|
||||
),
|
||||
Expanded(child: senderBox, flex: 2),
|
||||
Flexible(child: consigneeBox)
|
||||
],
|
||||
);
|
||||
@@ -167,34 +170,34 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
InkResponse(
|
||||
radius: 25,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_cargoTypeControllers[key].clear();
|
||||
});
|
||||
double totalWeight = double.tryParse(_totalCtl.text) ?? 0;
|
||||
double removeWeight =
|
||||
(double.tryParse(_cargoTypeControllers[key].text) ??
|
||||
0);
|
||||
|
||||
if (totalWeight >= removeWeight) {
|
||||
double result = totalWeight - removeWeight;
|
||||
_totalCtl.text = removeTrailingZeros(result);
|
||||
}
|
||||
|
||||
_cargoTypeControllers[key].clear();
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
child: Icon(MaterialIcons.clear)),
|
||||
child: Icon(MaterialIcons.clear, color: labelColor)),
|
||||
const SizedBox(width: 10),
|
||||
Flexible(
|
||||
child: inputTextFieldWidget(context,
|
||||
lableText: c.name ?? "",
|
||||
controller: _cargoTypeControllers[key]
|
||||
// onChanged: (newValue) {
|
||||
// setState(() {
|
||||
// _cargoTypes[key].weight = double.tryParse(newValue) ?? 0;
|
||||
// });
|
||||
// double total =
|
||||
// _cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
||||
// setState(() {
|
||||
// _totalCtl.text = total.toString();
|
||||
// });
|
||||
// },
|
||||
),
|
||||
controller: _cargoTypeControllers[key]),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList());
|
||||
|
||||
final totalBox = Row(
|
||||
final totalWeightBox = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
SizedBox(
|
||||
@@ -208,11 +211,34 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
_totalCtl.clear();
|
||||
});
|
||||
},
|
||||
child: Icon(MaterialIcons.clear)),
|
||||
child: Icon(MaterialIcons.clear, color: labelColor)),
|
||||
const SizedBox(width: 10),
|
||||
Flexible(
|
||||
child: inputTextFieldWidget(context,
|
||||
lableText: "Total", controller: _totalCtl),
|
||||
lableText: "Total",
|
||||
controller: _totalCtl,
|
||||
readOnly: getEmptyFields().isEmpty, onChanged: (neValue) {
|
||||
List<int> emptyFields = getEmptyFields();
|
||||
if (emptyFields.length == 1) {
|
||||
double totalWeight = double.tryParse(neValue) ?? 0;
|
||||
|
||||
_cargoTypes.asMap().entries.forEach((e) {
|
||||
_cargoTypes[e.key].weight = double.tryParse(
|
||||
_cargoTypeControllers[e.key].text) ??
|
||||
0;
|
||||
});
|
||||
double result = _cargoTypes.fold(
|
||||
0, (sum, value) => sum + value.weight);
|
||||
|
||||
if (totalWeight >= result) {
|
||||
double remaining = totalWeight - result;
|
||||
setState(() {
|
||||
_cargoTypeControllers[emptyFields.first].text =
|
||||
removeTrailingZeros(remaining);
|
||||
});
|
||||
}
|
||||
}
|
||||
}),
|
||||
),
|
||||
],
|
||||
)),
|
||||
@@ -231,10 +257,17 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
CustomDutyAddition(customDuties: _customDuties)));
|
||||
CustomDutyAddition(customDuties: _surchareItems)));
|
||||
if (customList == null) return;
|
||||
|
||||
_customDuties = List.from(customList);
|
||||
_surchareItems = List.from(customList);
|
||||
|
||||
_surchargeControllers.clear();
|
||||
_surchareItems.asMap().entries.forEach((e) {
|
||||
var editor = new TextEditingController();
|
||||
editor.text = e.value.qty == 0 ? "" : e.value.qty.toString();
|
||||
_surchargeControllers.add(editor);
|
||||
});
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
@@ -245,7 +278,7 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
final subChargeItemsBox = Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
runSpacing: 15,
|
||||
children: _customDuties.asMap().entries.map((e) {
|
||||
children: _surchareItems.asMap().entries.map((e) {
|
||||
var key = e.key;
|
||||
var c = e.value;
|
||||
return SizedBox(
|
||||
@@ -256,15 +289,21 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
radius: 25,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_customDuties.removeAt(key);
|
||||
_surchareItems.removeAt(key);
|
||||
});
|
||||
},
|
||||
child: Icon(Feather.minus_circle)),
|
||||
child: Icon(Feather.minus_circle, color: labelColor)),
|
||||
const SizedBox(width: 10),
|
||||
Flexible(
|
||||
child: inputTextFieldWidget(
|
||||
context,
|
||||
lableText: c.name ?? "",
|
||||
controller: _surchargeControllers[key],
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
_surchareItems[key].qty = int.tryParse(newValue) ?? 0;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -274,20 +313,15 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
|
||||
final continueBtn = ContinueButton(
|
||||
onTap: () {
|
||||
// if (selectedPackageList.isEmpty || searchResults.isEmpty) {
|
||||
// showMsgDialog(context, 'Error', "Please select the packages");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// if (widget.onContinue != null) {
|
||||
// widget.onContinue!(selectedPackageList);
|
||||
// }
|
||||
if (widget.onContinue != null) {
|
||||
widget.onContinue!(_cargoTypes, _surchareItems);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
final previousBtn = PreviousButton(onTap: () {
|
||||
if (widget.onPrevious != null) {
|
||||
widget.onPrevious!(_cargoTypes, _customDuties);
|
||||
widget.onPrevious!(_cargoTypes, _surchareItems);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -305,7 +339,7 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
const SizedBox(height: 15),
|
||||
Divider(),
|
||||
const SizedBox(height: 5),
|
||||
totalBox,
|
||||
totalWeightBox,
|
||||
subchargeItemTitleBox,
|
||||
subChargeItemsBox,
|
||||
const SizedBox(height: 30),
|
||||
@@ -333,13 +367,15 @@ class _CargoWidgetState extends State<CargoWidget> {
|
||||
Widget inputTextFieldWidget(BuildContext context,
|
||||
{required String lableText,
|
||||
TextEditingController? controller,
|
||||
Function(String)? onChanged}) {
|
||||
Function(String)? onChanged,
|
||||
bool readOnly = false}) {
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
style: textStyle,
|
||||
cursorColor: primaryColor,
|
||||
keyboardType: TextInputType.number,
|
||||
onChanged: onChanged,
|
||||
readOnly: readOnly,
|
||||
decoration: new InputDecoration(
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
labelText: lableText,
|
||||
|
||||
@@ -33,7 +33,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
|
||||
bool _isLoading = false;
|
||||
bool _isNew = false;
|
||||
int _billToValue = 1;
|
||||
String _billToValue = billToSender;
|
||||
String? _selectedCartonType;
|
||||
|
||||
User? _consignee;
|
||||
@@ -159,7 +159,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => CartonEditorForPackage(
|
||||
sender: _sender!, consignee: _consignee!)));
|
||||
sender: _sender!, consignee: _consignee!,billToValue: _billToValue)));
|
||||
}
|
||||
// for mix cartion
|
||||
else {
|
||||
@@ -275,16 +275,16 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_billToValue = 1;
|
||||
_billToValue = billToSender;
|
||||
});
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
LocalRadio(
|
||||
value: 1,
|
||||
value: billToSender,
|
||||
groupValue: _billToValue,
|
||||
onChanged: (p0) {
|
||||
setState(() {
|
||||
_billToValue = 1;
|
||||
_billToValue = billToSender;
|
||||
});
|
||||
},
|
||||
),
|
||||
@@ -293,7 +293,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: LocalText(context, 'box.bill_to_sender',
|
||||
fontSize: 15,
|
||||
color: _billToValue == 1 ? primaryColor : Colors.black),
|
||||
color: _billToValue == billToSender ? primaryColor : Colors.black),
|
||||
),
|
||||
)
|
||||
]),
|
||||
@@ -302,16 +302,16 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_billToValue = 2;
|
||||
_billToValue = billToConsignee;
|
||||
});
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
LocalRadio(
|
||||
value: 2,
|
||||
value: billToConsignee,
|
||||
groupValue: _billToValue,
|
||||
onChanged: (p0) {
|
||||
setState(() {
|
||||
_billToValue = 2;
|
||||
_billToValue = billToConsignee;
|
||||
});
|
||||
},
|
||||
),
|
||||
@@ -320,7 +320,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: LocalText(context, 'box.bill_to.consignee',
|
||||
fontSize: 15,
|
||||
color: _billToValue == 2 ? primaryColor : Colors.black),
|
||||
color: _billToValue == billToConsignee ? primaryColor : Colors.black),
|
||||
),
|
||||
)
|
||||
]),
|
||||
|
||||
@@ -19,14 +19,16 @@ import '../widgets/progress.dart';
|
||||
import '../widgets/step_widget.dart';
|
||||
import 'cargo_widget.dart';
|
||||
import 'carton_size_widget.dart';
|
||||
import 'carton_submit.dart';
|
||||
import 'model/package_selection_model.dart';
|
||||
import 'package_selection_widget.dart';
|
||||
|
||||
class CartonEditorForPackage extends StatefulWidget {
|
||||
final User sender;
|
||||
final User consignee;
|
||||
final String billToValue;
|
||||
const CartonEditorForPackage(
|
||||
{Key? key, required this.sender, required this.consignee})
|
||||
{Key? key, required this.sender, required this.consignee, required this.billToValue})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -44,7 +46,7 @@ class _CartonEditorForPackageState extends State<CartonEditorForPackage> {
|
||||
];
|
||||
List<Package> _packages = [];
|
||||
List<CargoType> _cargoTypes = [];
|
||||
List<CargoType> _customDuties = [];
|
||||
List<CargoType> _surchareItems = [];
|
||||
|
||||
int currentStep = 0;
|
||||
double _length = 0;
|
||||
@@ -181,18 +183,18 @@ class _CartonEditorForPackageState extends State<CartonEditorForPackage> {
|
||||
sender: widget.sender,
|
||||
consignee: widget.consignee,
|
||||
cargoTypes: _cargoTypes,
|
||||
customDuties: _customDuties,
|
||||
surchargeItems: _surchareItems,
|
||||
onContinue: (cargoTypes, customDuties) {
|
||||
setState(() {
|
||||
_cargoTypes = List.from(cargoTypes);
|
||||
_customDuties = List.from(customDuties);
|
||||
_surchareItems = List.from(customDuties);
|
||||
currentStep += 1;
|
||||
});
|
||||
},
|
||||
onPrevious: (cargoTypes, customDuties) {
|
||||
setState(() {
|
||||
_cargoTypes = List.from(cargoTypes);
|
||||
_customDuties = List.from(customDuties);
|
||||
_surchareItems = List.from(customDuties);
|
||||
currentStep -= 1;
|
||||
});
|
||||
},
|
||||
@@ -200,24 +202,29 @@ class _CartonEditorForPackageState extends State<CartonEditorForPackage> {
|
||||
);
|
||||
} else {
|
||||
return Expanded(
|
||||
child: Text("Submit"),
|
||||
// child: MixCartonSubmit(
|
||||
// cartonSizeType: _cartonSizeType,
|
||||
// standardSize: _standardSize,
|
||||
// length: _length,
|
||||
// width: _width,
|
||||
// height: _height,
|
||||
// shipment: _shipment!,
|
||||
// cartons: _packages,
|
||||
// onCreate: () {
|
||||
// _create();
|
||||
// },
|
||||
// onPrevious: () {
|
||||
// setState(() {
|
||||
// currentStep -= 1;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
child: CartonSubmit(
|
||||
sender: widget.sender,
|
||||
consingee: widget.consignee,
|
||||
billToValue: widget.billToValue,
|
||||
cartonSizeType: _cartonSizeType,
|
||||
standardSize: _standardSize,
|
||||
length: _length,
|
||||
width: _width,
|
||||
height: _height,
|
||||
deliveryType: _selectedDeliveryType,
|
||||
shipment: _shipment!,
|
||||
packages: _packages,
|
||||
cargoTypes: _cargoTypes,
|
||||
surchareItems: _surchareItems,
|
||||
onCreate: () {
|
||||
_create();
|
||||
},
|
||||
onPrevious: () {
|
||||
setState(() {
|
||||
currentStep -= 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
373
lib/pages/carton/carton_submit.dart
Normal file
373
lib/pages/carton/carton_submit.dart
Normal file
@@ -0,0 +1,373 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../domain/constants.dart';
|
||||
import '../../../domain/entities/cargo_type.dart';
|
||||
import '../../../domain/entities/carton_size.dart';
|
||||
import '../../../domain/entities/fcs_shipment.dart';
|
||||
import '../../../helpers/theme.dart';
|
||||
|
||||
import '../../domain/entities/package.dart';
|
||||
import '../../domain/entities/user.dart';
|
||||
import '../main/util.dart';
|
||||
import '../widgets/local_text.dart';
|
||||
import '../widgets/previous_button.dart';
|
||||
import '../widgets/submit_text_widget.dart';
|
||||
|
||||
typedef OnCreateCarton = Function();
|
||||
typedef OnPrevious = Function();
|
||||
final NumberFormat numberFormatter = NumberFormat("#,###");
|
||||
|
||||
class CartonSubmit extends StatelessWidget {
|
||||
final User sender;
|
||||
final User consingee;
|
||||
final String billToValue;
|
||||
final FcsShipment shipment;
|
||||
final List<Package> packages;
|
||||
final String cartonSizeType;
|
||||
final CartonSize? standardSize;
|
||||
final double length;
|
||||
final double width;
|
||||
final double height;
|
||||
final String deliveryType;
|
||||
final List<CargoType> cargoTypes;
|
||||
final List<CargoType> surchareItems;
|
||||
final OnCreateCarton? onCreate;
|
||||
final OnPrevious? onPrevious;
|
||||
const CartonSubmit(
|
||||
{Key? key,
|
||||
required this.sender,
|
||||
required this.consingee,
|
||||
required this.billToValue,
|
||||
this.onCreate,
|
||||
this.onPrevious,
|
||||
required this.shipment,
|
||||
this.packages = const [],
|
||||
this.standardSize,
|
||||
required this.cartonSizeType,
|
||||
required this.deliveryType,
|
||||
this.length = 0,
|
||||
this.width = 0,
|
||||
this.height = 0,
|
||||
this.cargoTypes = const [],
|
||||
this.surchareItems = const []})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String? boxDimension = cartonSizeType == standardCarton
|
||||
? "${standardSize?.name} - ${standardSize?.length.toInt()}”x${standardSize?.width.toInt()}”x${standardSize?.height.toInt()}”"
|
||||
: cartonSizeType == customCarton
|
||||
? "${length.toInt()}”x${width.toInt()}”x${height.toInt()}”"
|
||||
: null;
|
||||
|
||||
double totalWeight = cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
||||
|
||||
final cartonType = Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: SubmitTextWidget(
|
||||
labelKey: 'box.carton.type',
|
||||
text: carton_from_packages,
|
||||
subText: boxDimension),
|
||||
);
|
||||
|
||||
final shipmentBox = Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: SubmitTextWidget(
|
||||
labelKey: 'box.shipment',
|
||||
text: shipment.shipmentNumber ?? '',
|
||||
subText: shipment.status ?? "",
|
||||
),
|
||||
);
|
||||
|
||||
final usersBox = Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 5, bottom: 5),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: LocalText(context, 'box.sender.title',
|
||||
color: primaryColor,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 13),
|
||||
child: LocalText(context, 'box.consignee.title',
|
||||
color: primaryColor,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: primaryColor),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(sender.name ?? "",
|
||||
style: const TextStyle(
|
||||
fontSize: 16.0, fontWeight: FontWeight.w500)),
|
||||
sender.fcsID == null
|
||||
? const SizedBox()
|
||||
: Text(sender.fcsID!,
|
||||
style: const TextStyle(
|
||||
fontSize: 14.0, color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
),
|
||||
billToValue == billToSender
|
||||
? billWidget(context)
|
||||
: const SizedBox()
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 15),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(consingee.name ?? "",
|
||||
style: const TextStyle(
|
||||
fontSize: 16.0, fontWeight: FontWeight.w500)),
|
||||
consingee.fcsID == null
|
||||
? const SizedBox()
|
||||
: Text(consingee.fcsID!,
|
||||
style: const TextStyle(
|
||||
fontSize: 14.0, color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
),
|
||||
billToValue == billToConsignee
|
||||
? billWidget(context)
|
||||
: const SizedBox()
|
||||
],
|
||||
),
|
||||
))
|
||||
]),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
final deliveryTypeBox = Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: SubmitTextWidget(
|
||||
labelKey: 'box.delivery_type',
|
||||
text: deliveryType,
|
||||
),
|
||||
);
|
||||
|
||||
final packagesBox = Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 5, bottom: 5),
|
||||
child: LocalText(context, 'box.package.count',
|
||||
translationVariables: [packages.length.toString()],
|
||||
color: primaryColor,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: primaryColor),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Wrap(
|
||||
spacing: 15,
|
||||
children: packages.map((e) {
|
||||
return SizedBox(
|
||||
width: MediaQuery.of(context).size.width / 2.5,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Text(
|
||||
e.trackingID ?? "",
|
||||
style: TextStyle(color: Colors.black, fontSize: 15),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList()),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
final cargosBox = Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 5, bottom: 5, right: 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
LocalText(context, 'box.cargo.type',
|
||||
color: primaryColor,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal),
|
||||
Text("${removeTrailingZeros(totalWeight)} lb",
|
||||
style: TextStyle(color: Colors.black, fontSize: 15))
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: primaryColor),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: 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),
|
||||
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()),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
final createBtn = InkWell(
|
||||
onTap: () {
|
||||
if (onCreate != null) {
|
||||
onCreate!();
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment.bottomRight,
|
||||
height: 45,
|
||||
width: 150,
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: null,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: LocalText(context, 'box.crete.carton',
|
||||
color: Colors.white, fontSize: 15),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
const Icon(
|
||||
MaterialCommunityIcons.check_circle_outline,
|
||||
color: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
final previousBtn = PreviousButton(onTap: () {
|
||||
if (onPrevious != null) {
|
||||
onPrevious!();
|
||||
}
|
||||
});
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
children: [
|
||||
cartonType,
|
||||
const SizedBox(height: 10),
|
||||
shipmentBox,
|
||||
const SizedBox(height: 10),
|
||||
usersBox,
|
||||
const SizedBox(height: 10),
|
||||
deliveryTypeBox,
|
||||
const SizedBox(height: 10),
|
||||
packages.isNotEmpty ? packagesBox : const SizedBox(),
|
||||
const SizedBox(height: 10),
|
||||
cargosBox,
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15, right: 15),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [previousBtn, createBtn],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget billWidget(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(Ionicons.document_text_outline, color: primaryColor, size: 20),
|
||||
Text("Bill to", style: TextStyle(color: primaryColor, fontSize: 15))
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -35,11 +35,18 @@ class _CustomDutyAdditionState extends State<CustomDutyAddition> {
|
||||
shipmentRateModel.rate.customDuties.map((e) => e.clone()).toList();
|
||||
|
||||
for (var p in customDuties) {
|
||||
p.qty = 0;
|
||||
if (widget.customDuties.any((e) => e.id == p.id)) {
|
||||
p.isChecked = true;
|
||||
} else {
|
||||
p.isChecked = false;
|
||||
}
|
||||
|
||||
widget.customDuties.forEach((vp) {
|
||||
if (p.id == vp.id) {
|
||||
p.qty = vp.qty;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
@@ -87,6 +94,7 @@ class _CustomDutyAdditionState extends State<CustomDutyAddition> {
|
||||
callBack: () {
|
||||
List<CargoType> _cargos =
|
||||
customDuties.where((c) => c.isChecked).toList();
|
||||
|
||||
if (_cargos.isEmpty) {
|
||||
showMsgDialog(context, 'Error', "Please select the cargo type");
|
||||
return;
|
||||
|
||||
@@ -8,6 +8,7 @@ import '../../../domain/entities/carton.dart';
|
||||
import '../../../domain/entities/carton_size.dart';
|
||||
import '../../../domain/entities/fcs_shipment.dart';
|
||||
import '../../../helpers/theme.dart';
|
||||
import '../../main/util.dart';
|
||||
import '../../widgets/local_text.dart';
|
||||
import '../../widgets/previous_button.dart';
|
||||
import '../../widgets/submit_text_widget.dart';
|
||||
@@ -47,6 +48,7 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
final NumberFormat numberFormatter = NumberFormat("#,###");
|
||||
Map<String?, double> _mapCargosByWeight = {};
|
||||
Map<String?, double> _mapCargosByCustomDutyFee = {};
|
||||
double totalWeight = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -69,6 +71,9 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
_mapCargosByWeight[key] = total;
|
||||
});
|
||||
|
||||
totalWeight =
|
||||
_mapCargosByWeight.entries.fold(0, (sum, value) => sum + value.value);
|
||||
|
||||
// get cargos by custom duty fee
|
||||
Map<String?, List<CargoType>> _cargosByCustomDutyFee =
|
||||
groupCargos(_cargoTypes.where((e) => e.isCutomDuty).toList());
|
||||
@@ -104,7 +109,7 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: SubmitTextWidget(
|
||||
labelKey: 'box.carton.type',
|
||||
text: 'Mix Carton',
|
||||
text: carton_mix_carton,
|
||||
subText: boxDimension,
|
||||
),
|
||||
);
|
||||
@@ -159,9 +164,18 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 5, bottom: 5),
|
||||
child: LocalText(context, 'box.cargo.type',
|
||||
color: primaryColor, fontSize: 16, fontWeight: FontWeight.normal),
|
||||
padding: const EdgeInsets.only(left: 5, bottom: 5, right: 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
LocalText(context, 'box.cargo.type',
|
||||
color: primaryColor,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal),
|
||||
Text("${removeTrailingZeros(totalWeight)} lb",
|
||||
style: TextStyle(color: Colors.black, fontSize: 15))
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
@@ -185,7 +199,7 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
style:
|
||||
TextStyle(color: Colors.black, fontSize: 15),
|
||||
),
|
||||
Text("${numberFormatter.format(e.value)} lb",
|
||||
Text("${removeTrailingZeros(e.value)} lb",
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 15))
|
||||
],
|
||||
|
||||
@@ -395,3 +395,12 @@ bool hasUnicode(String text) {
|
||||
text.codeUnits.where((ch) => ch > maxBits).toList();
|
||||
return unicodeSymbols.length > 0;
|
||||
}
|
||||
|
||||
|
||||
String removeTrailingZeros(double number) {
|
||||
String result = number.toString();
|
||||
result = result.indexOf('.') > 0
|
||||
? result.replaceAll(RegExp(r"([.]*0)(?!.*\d)"), "")
|
||||
: result;
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user