move bill to to cartion size widget

This commit is contained in:
tzw
2024-02-09 12:16:39 +06:30
parent b2603c02ce
commit 4a9c04ef1e
5 changed files with 100 additions and 88 deletions

View File

@@ -21,7 +21,8 @@ import '../widgets/previous_button.dart';
typedef OnPrevious = Function();
typedef OnContinue = Function(String deliveryType,FcsShipment shipment, String cartonSizeType,
typedef OnContinue = Function(String deliveryType, String billType,
FcsShipment shipment, String cartonSizeType,
{CartonSize? standardSize, double? length, double? width, double? height});
class CartonSizeWidget extends StatefulWidget {
@@ -30,6 +31,7 @@ class CartonSizeWidget extends StatefulWidget {
final User sender;
final User consignee;
final String deliveryType;
final String billType;
final FcsShipment? shipment;
final String cartonSizeType;
final CartonSize? standardSize;
@@ -49,7 +51,8 @@ class CartonSizeWidget extends StatefulWidget {
this.height,
required this.sender,
required this.consignee,
required this.deliveryType})
required this.deliveryType,
required this.billType})
: super(key: key);
@override
@@ -65,6 +68,7 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
List<FcsShipment> _shipments = [];
CartonSize? _selectStandardSize;
late String _selectedDeliveryType;
late String _billToValue;
TextEditingController _widthController = new TextEditingController();
TextEditingController _heightController = new TextEditingController();
@@ -78,9 +82,10 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
_init() async {
_selectedDeliveryType = widget.deliveryType;
_billToValue = widget.billType;
_shipment = widget.shipment;
_cartionSizeType = widget.cartonSizeType;
List<CartonSize> cartonSizes = context.read<CartonSizeModel>().cartonSizes;
_selectStandardSize = widget.standardSize ?? cartonSizes.first;
@@ -142,6 +147,72 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
});
});
final billRadioBox = Container(
child: Row(
children: [
Flexible(
child: InkWell(
onTap: () {
setState(() {
_billToValue = billToSender;
});
},
child: Row(children: <Widget>[
LocalRadio(
value: billToSender,
groupValue: _billToValue,
onChanged: (p0) {
setState(() {
_billToValue = billToSender;
});
},
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.bill_to_sender',
fontSize: 15,
color: _billToValue == billToSender
? primaryColor
: Colors.black),
),
)
]),
)),
Flexible(
child: InkWell(
onTap: () {
setState(() {
_billToValue = billToConsignee;
});
},
child: Row(children: <Widget>[
LocalRadio(
value: billToConsignee,
groupValue: _billToValue,
onChanged: (p0) {
setState(() {
_billToValue = billToConsignee;
});
},
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: LocalText(context, 'box.bill_to.consignee',
fontSize: 15,
color: _billToValue == billToConsignee
? primaryColor
: Colors.black),
),
)
]),
),
)
],
),
);
final continueBtn = ContinueButton(onTap: () {
double l = double.tryParse(_lengthController.text) ?? 0;
double w = double.tryParse(_widthController.text) ?? 0;
@@ -170,7 +241,8 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
}
if (widget.onContinue != null) {
widget.onContinue!(_selectedDeliveryType,_shipment!, _cartionSizeType,
widget.onContinue!(
_selectedDeliveryType, _billToValue, _shipment!, _cartionSizeType,
standardSize: _selectStandardSize, length: l, width: w, height: h);
}
});
@@ -366,7 +438,9 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
children: [
const SizedBox(height: 8),
userRow,
LocalTitle(textKey: "box.select.delivery", topPadding: 10),
const SizedBox(height: 5),
billRadioBox,
LocalTitle(textKey: "box.select.delivery"),
const SizedBox(height: 5),
deliveryTypeBox,
const SizedBox(height: 5),