update cartion editor for package
This commit is contained in:
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))
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user