add carton editor for package
This commit is contained in:
@@ -3,25 +3,31 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../domain/constants.dart';
|
||||
import '../../../domain/entities/carton.dart';
|
||||
import '../../../domain/entities/carton_size.dart';
|
||||
import '../../../domain/entities/fcs_shipment.dart';
|
||||
import '../../../domain/vo/local_step.dart';
|
||||
import '../../../helpers/theme.dart';
|
||||
import '../../domain/entities/cargo_type.dart';
|
||||
import '../../domain/entities/package.dart';
|
||||
import '../../domain/entities/user.dart';
|
||||
import '../main/util.dart';
|
||||
import '../widgets/local_text.dart';
|
||||
import '../widgets/progress.dart';
|
||||
import '../widgets/step_widget.dart';
|
||||
import 'cargo_widget.dart';
|
||||
import 'carton_size_widget.dart';
|
||||
import 'mix_carton/mix_carton_submit.dart';
|
||||
import 'model/package_selection_model.dart';
|
||||
import 'package_selection_widget.dart';
|
||||
|
||||
class CartonEditorForPackage extends StatefulWidget {
|
||||
final User sender;
|
||||
final User consignee;
|
||||
const CartonEditorForPackage({Key? key, required this.sender, required this.consignee}) : super(key: key);
|
||||
const CartonEditorForPackage(
|
||||
{Key? key, required this.sender, required this.consignee})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<CartonEditorForPackage> createState() => _CartonEditorForPackageState();
|
||||
@@ -36,18 +42,27 @@ class _CartonEditorForPackageState extends State<CartonEditorForPackage> {
|
||||
LocalStep(lable: 'Cargos', stepType: StepType.CARGOS),
|
||||
LocalStep(lable: 'Submit', stepType: StepType.SUBMIT)
|
||||
];
|
||||
List<Carton> _cartions = [];
|
||||
List<Package> _packages = [];
|
||||
List<CargoType> _cargoTypes = [];
|
||||
List<CargoType> _customDuties = [];
|
||||
|
||||
int currentStep = 0;
|
||||
double _length = 0;
|
||||
double _width = 0;
|
||||
double _height = 0;
|
||||
|
||||
String _selectedDeliveryType = delivery_caton;
|
||||
FcsShipment? _shipment;
|
||||
String _cartonSizeType = standardCarton;
|
||||
CartonSize? _standardSize;
|
||||
bool _isLoading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
context.read<PackageSelectionModel>().clearSelection();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
@@ -113,8 +128,9 @@ class _CartonEditorForPackageState extends State<CartonEditorForPackage> {
|
||||
if (step.stepType == StepType.SIZE) {
|
||||
return Expanded(
|
||||
child: CartonSizeWidget(
|
||||
sender: widget.sender,
|
||||
consignee: widget.consignee,
|
||||
deliveryType: _selectedDeliveryType,
|
||||
sender: widget.sender,
|
||||
consignee: widget.consignee,
|
||||
shipment: _shipment,
|
||||
cartonSizeType: _cartonSizeType,
|
||||
standardSize: _standardSize,
|
||||
@@ -124,9 +140,10 @@ class _CartonEditorForPackageState extends State<CartonEditorForPackage> {
|
||||
onPrevious: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onContinue: (shipment, cartonSizeType,
|
||||
onContinue: (deliveryType, shipment, cartonSizeType,
|
||||
{standardSize, length, width, height}) {
|
||||
setState(() {
|
||||
_selectedDeliveryType = deliveryType;
|
||||
_shipment = shipment;
|
||||
_cartonSizeType = cartonSizeType;
|
||||
_standardSize = standardSize;
|
||||
@@ -139,64 +156,69 @@ class _CartonEditorForPackageState extends State<CartonEditorForPackage> {
|
||||
));
|
||||
} else if (step.stepType == StepType.PACKAGES) {
|
||||
return Expanded(
|
||||
child: Text("PACKAGES"),
|
||||
// child: CartonSelectionWidget(
|
||||
// shipment: _shipment!,
|
||||
// cartons: _cartions,
|
||||
// onContinue: (cartons) {
|
||||
// setState(() {
|
||||
// _cartions = List.from(cartons);
|
||||
// currentStep += 1;
|
||||
// });
|
||||
// },
|
||||
// onPrevious: (cartons) {
|
||||
// setState(() {
|
||||
// _cartions = List.from(cartons);
|
||||
// currentStep -= 1;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
);
|
||||
} else if (step.stepType == StepType.CARGOS) {
|
||||
return Expanded(
|
||||
child: Text("cargos"),
|
||||
// child: CartonSelectionWidget(
|
||||
// shipment: _shipment!,
|
||||
// cartons: _cartions,
|
||||
// onContinue: (cartons) {
|
||||
// setState(() {
|
||||
// _cartions = List.from(cartons);
|
||||
// currentStep += 1;
|
||||
// });
|
||||
// },
|
||||
// onPrevious: (cartons) {
|
||||
// setState(() {
|
||||
// _cartions = List.from(cartons);
|
||||
// currentStep -= 1;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
);
|
||||
} else {
|
||||
return Expanded(
|
||||
child: MixCartonSubmit(
|
||||
cartonSizeType: _cartonSizeType,
|
||||
standardSize: _standardSize,
|
||||
length: _length,
|
||||
width: _width,
|
||||
height: _height,
|
||||
child: PackageSelectionWidget(
|
||||
sender: widget.sender,
|
||||
consignee: widget.consignee,
|
||||
shipment: _shipment!,
|
||||
cartons: _cartions,
|
||||
onCreate: () {
|
||||
_create();
|
||||
},
|
||||
onPrevious: () {
|
||||
packages: _packages,
|
||||
onContinue: (packages) {
|
||||
setState(() {
|
||||
_packages = List.from(packages);
|
||||
currentStep += 1;
|
||||
});
|
||||
},
|
||||
onPrevious: (packages) {
|
||||
setState(() {
|
||||
_packages = List.from(packages);
|
||||
currentStep -= 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
} else if (step.stepType == StepType.CARGOS) {
|
||||
return Expanded(
|
||||
child: CargoWidget(
|
||||
sender: widget.sender,
|
||||
consignee: widget.consignee,
|
||||
cargoTypes: _cargoTypes,
|
||||
customDuties: _customDuties,
|
||||
onContinue: (cargoTypes, customDuties) {
|
||||
setState(() {
|
||||
_cargoTypes = List.from(cargoTypes);
|
||||
_customDuties = List.from(customDuties);
|
||||
currentStep += 1;
|
||||
});
|
||||
},
|
||||
onPrevious: (cargoTypes, customDuties) {
|
||||
setState(() {
|
||||
_cargoTypes = List.from(cargoTypes);
|
||||
_customDuties = List.from(customDuties);
|
||||
currentStep -= 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
} 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;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user