update carton and cargo type
This commit is contained in:
@@ -11,23 +11,24 @@ import 'package:fcs/pages/widgets/local_dropdown.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons_null_safety/flutter_icons_null_safety.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ShipmentRatesCal extends StatefulWidget {
|
||||
ShipmentRatesCal();
|
||||
const ShipmentRatesCal({super.key});
|
||||
|
||||
@override
|
||||
_ShipmentRatesCalState createState() => _ShipmentRatesCalState();
|
||||
}
|
||||
|
||||
class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
||||
bool _isLoading = false;
|
||||
bool isLoading = false;
|
||||
late CargoType _cargoType;
|
||||
TextEditingController _widthController = new TextEditingController();
|
||||
TextEditingController _heightController = new TextEditingController();
|
||||
TextEditingController _lengthController = new TextEditingController();
|
||||
TextEditingController _actualWeightCtl = new TextEditingController();
|
||||
TextEditingController widthController = TextEditingController();
|
||||
TextEditingController heightController = TextEditingController();
|
||||
TextEditingController lengthController = TextEditingController();
|
||||
TextEditingController actualWeightCtl = TextEditingController();
|
||||
double _shipmentWeight = 0;
|
||||
double _amount = 0;
|
||||
double _deliveryFee = 0;
|
||||
@@ -38,25 +39,25 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
||||
|
||||
//for shipment weight
|
||||
Rate rate = Provider.of<ShipmentRateModel>(context, listen: false).rate;
|
||||
_lengthController.addListener(_calShipmentWeight);
|
||||
_widthController.addListener(_calShipmentWeight);
|
||||
_heightController.addListener(_calShipmentWeight);
|
||||
_actualWeightCtl.addListener(_calShipmentWeight);
|
||||
lengthController.addListener(_calShipmentWeight);
|
||||
widthController.addListener(_calShipmentWeight);
|
||||
heightController.addListener(_calShipmentWeight);
|
||||
actualWeightCtl.addListener(_calShipmentWeight);
|
||||
_cargoType = rate.defaultCargoType;
|
||||
_lengthController.text = '12';
|
||||
_widthController.text = '12';
|
||||
_heightController.text = '12';
|
||||
_actualWeightCtl.text = "10.00";
|
||||
lengthController.text = '12';
|
||||
widthController.text = '12';
|
||||
heightController.text = '12';
|
||||
actualWeightCtl.text = "10.00";
|
||||
_calShipmentWeight();
|
||||
}
|
||||
|
||||
_calShipmentWeight() {
|
||||
Rate rate = Provider.of<ShipmentRateModel>(context, listen: false).rate;
|
||||
|
||||
double l = double.tryParse(_lengthController.text) ?? 0;
|
||||
double w = double.tryParse(_widthController.text) ?? 0;
|
||||
double h = double.tryParse(_heightController.text) ?? 0;
|
||||
_cargoType.weight = double.tryParse(_actualWeightCtl.text) ?? 0;
|
||||
double l = double.tryParse(lengthController.text) ?? 0;
|
||||
double w = double.tryParse(widthController.text) ?? 0;
|
||||
double h = double.tryParse(heightController.text) ?? 0;
|
||||
_cargoType.weight = double.tryParse(actualWeightCtl.text) ?? 0;
|
||||
Carton box =
|
||||
Carton(cargoTypes: [_cargoType], length: l, width: w, height: h);
|
||||
var amount = box.calAmount(rate);
|
||||
@@ -83,15 +84,15 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
||||
List<CargoType> cargos = shipmentRateModel.rate.cargoTypes;
|
||||
|
||||
final lengthBox = LengthPicker(
|
||||
controller: _lengthController,
|
||||
controller: lengthController,
|
||||
lableKey: "box.length",
|
||||
);
|
||||
final widthBox = LengthPicker(
|
||||
controller: _widthController,
|
||||
controller: widthController,
|
||||
lableKey: "box.width",
|
||||
);
|
||||
final heightBox = LengthPicker(
|
||||
controller: _heightController,
|
||||
controller: heightController,
|
||||
lableKey: "box.height",
|
||||
);
|
||||
|
||||
@@ -102,9 +103,9 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: Icon(FontAwesome.arrow_circle_right, color: primaryColor),
|
||||
),
|
||||
SizedBox(child: lengthBox, width: 80),
|
||||
SizedBox(child: widthBox, width: 80),
|
||||
SizedBox(child: heightBox, width: 80),
|
||||
SizedBox(width: 80, child: lengthBox),
|
||||
SizedBox(width: 80, child: widthBox),
|
||||
SizedBox(width: 80, child: heightBox),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -115,7 +116,7 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
||||
);
|
||||
|
||||
final actualWeightBox = InputText(
|
||||
controller: _actualWeightCtl,
|
||||
controller: actualWeightCtl,
|
||||
labelTextKey: "box.actual_weight",
|
||||
iconData: MaterialCommunityIcons.weight,
|
||||
textInputType: TextInputType.numberWithOptions(decimal: true),
|
||||
@@ -129,13 +130,13 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
||||
});
|
||||
},
|
||||
labelKey: "cargo.type",
|
||||
iconData: Icons.text_format,
|
||||
iconData: Ionicons.text,
|
||||
selectedValue: _cargoType,
|
||||
values: cargos,
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
inAsyncCall: isLoading,
|
||||
child: Scaffold(
|
||||
appBar: LocalAppBar(
|
||||
labelKey: "rate.cal.title",
|
||||
|
||||
Reference in New Issue
Block a user