update ui
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../domain/entities/carton.dart';
|
||||
import '../../../helpers/theme.dart';
|
||||
import '../../main/util.dart';
|
||||
import '../model/carton_selection_model.dart';
|
||||
|
||||
typedef OnAction = Future<void> Function();
|
||||
@@ -72,20 +73,20 @@ class CartonSelectionResult extends StatelessWidget {
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new Padding(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(carton.cartonNumber ?? "",
|
||||
style: new TextStyle(
|
||||
Text(carton.cartonNumber ?? "",
|
||||
style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
color: Colors.black)),
|
||||
new Text(
|
||||
"${carton.cartonWeight.toStringAsFixed(2)} lb",
|
||||
style: new TextStyle(
|
||||
Text(
|
||||
"${twoDecimalFormatted(carton.cartonWeight)} lb",
|
||||
style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
color: Colors.grey),
|
||||
),
|
||||
|
||||
@@ -29,7 +29,7 @@ class MixCartonSubmit extends StatefulWidget {
|
||||
final OnCreateMixCarton? onCreate;
|
||||
final OnPrevious? onPrevious;
|
||||
const MixCartonSubmit(
|
||||
{Key? key,
|
||||
{super.key,
|
||||
this.onCreate,
|
||||
this.onPrevious,
|
||||
required this.shipment,
|
||||
@@ -39,8 +39,7 @@ class MixCartonSubmit extends StatefulWidget {
|
||||
this.length = 0,
|
||||
this.width = 0,
|
||||
this.height = 0,
|
||||
this.isNew = true})
|
||||
: super(key: key);
|
||||
this.isNew = true});
|
||||
|
||||
@override
|
||||
State<MixCartonSubmit> createState() => _MixCartonSubmitState();
|
||||
@@ -48,8 +47,8 @@ class MixCartonSubmit extends StatefulWidget {
|
||||
|
||||
class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
final NumberFormat numberFormatter = NumberFormat("#,###");
|
||||
Map<String?, double> _mapCargos = {};
|
||||
Map<String?, double> _mapSurchargeItems = {};
|
||||
final Map<String?, double> _mapCargos = {};
|
||||
final Map<String?, double> _mapSurchargeItems = {};
|
||||
double totalWeight = 0;
|
||||
|
||||
@override
|
||||
@@ -60,15 +59,15 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
|
||||
_init() {
|
||||
// get cargos by weight
|
||||
List<CargoType> _cargoTypes = [];
|
||||
List<CargoType> cargoTypes = [];
|
||||
for (var c in widget.cartons) {
|
||||
_cargoTypes.addAll(c.cargoTypes);
|
||||
cargoTypes.addAll(c.cargoTypes);
|
||||
}
|
||||
|
||||
_cargoTypes.sort((a, b) => a.name!.compareTo(b.name!));
|
||||
cargoTypes.sort((a, b) => a.name!.compareTo(b.name!));
|
||||
|
||||
Map<String?, List<CargoType>> _cargosByWeight = groupCargos(_cargoTypes);
|
||||
_cargosByWeight.forEach((key, value) {
|
||||
Map<String?, List<CargoType>> cargosByWeight = groupCargos(cargoTypes);
|
||||
cargosByWeight.forEach((key, value) {
|
||||
double total = value.fold(0, (sum, item) => sum + item.weight);
|
||||
_mapCargos[key] = total;
|
||||
});
|
||||
@@ -77,17 +76,17 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
|
||||
// get surcharge items
|
||||
|
||||
List<CargoType> _surchargeItems = [];
|
||||
List<CargoType> surchargeItems = [];
|
||||
for (var c in widget.cartons) {
|
||||
_surchargeItems.addAll(c.surchareItems);
|
||||
surchargeItems.addAll(c.surchareItems);
|
||||
}
|
||||
|
||||
_surchargeItems.sort((a, b) => a.name!.compareTo(b.name!));
|
||||
surchargeItems.sort((a, b) => a.name!.compareTo(b.name!));
|
||||
|
||||
Map<String?, List<CargoType>> _cargosByCustomDutyFee =
|
||||
groupCargos(_surchargeItems);
|
||||
Map<String?, List<CargoType>> cargosByCustomDutyFee =
|
||||
groupCargos(surchargeItems);
|
||||
|
||||
_cargosByCustomDutyFee.forEach((key, value) {
|
||||
cargosByCustomDutyFee.forEach((key, value) {
|
||||
double total = value.fold(0, (sum, item) => sum + item.qty);
|
||||
_mapSurchargeItems[key] = total;
|
||||
});
|
||||
@@ -99,8 +98,8 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
|
||||
Map<String?, List<CargoType>> groupCargos(List<CargoType> cargos) {
|
||||
var groups = groupBy(cargos, (CargoType e) {
|
||||
String? _categoryName = e.name;
|
||||
return _categoryName;
|
||||
String? categoryName = e.name;
|
||||
return categoryName;
|
||||
});
|
||||
|
||||
return groups;
|
||||
@@ -220,22 +219,80 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
),
|
||||
);
|
||||
}).toList()),
|
||||
const SizedBox(height: 10),
|
||||
// const SizedBox(height: 10),
|
||||
// Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: _mapSurchargeItems.entries.map((e) {
|
||||
// return Padding(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text(
|
||||
// e.key ?? "",
|
||||
// style: TextStyle(color: labelColor, fontSize: 15),
|
||||
// ),
|
||||
// Text("${numberFormatter.format(e.value)} pc",
|
||||
// style:
|
||||
// TextStyle(color: labelColor, fontSize: 15))
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }).toList()),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
final surChargeItemsBox = 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.input_surcharge_item',
|
||||
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: Column(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _mapSurchargeItems.entries.map((e) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
e.key ?? "",
|
||||
style: TextStyle(color: labelColor, fontSize: 15),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
e.key ?? "",
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 15),
|
||||
),
|
||||
Text(
|
||||
"${removeTrailingZeros((e.value).toDouble())} pc",
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 15))
|
||||
],
|
||||
),
|
||||
Text("${numberFormatter.format(e.value)} pc",
|
||||
style:
|
||||
TextStyle(color: labelColor, fontSize: 15))
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -302,7 +359,12 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
const SizedBox(height: 10),
|
||||
widget.cartons.isNotEmpty ? cartonsBox : const SizedBox(),
|
||||
const SizedBox(height: 10),
|
||||
cargosBox,
|
||||
_mapCargos.isNotEmpty ? cargosBox : const SizedBox(),
|
||||
_mapSurchargeItems.isNotEmpty
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: surChargeItemsBox)
|
||||
: const SizedBox(),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -172,7 +172,8 @@ class _TypeWidgetState extends State<TypeWidget> {
|
||||
isDense: true,
|
||||
value: _selectStandardSize,
|
||||
style: TextStyle(color: Colors.black, fontSize: 14),
|
||||
underline: Container(height: 1, color: Colors.grey),
|
||||
underline: Container(
|
||||
height: 1, color: isStandardSize ? primaryColor : Colors.grey),
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
if (newValue?.name == MANAGE_CARTONSIZE) {
|
||||
|
||||
Reference in New Issue
Block a user