add carton editor to update
This commit is contained in:
@@ -14,6 +14,7 @@ import '../../domain/entities/cargo_type.dart';
|
||||
import '../../domain/entities/carton.dart';
|
||||
import '../../domain/entities/package.dart';
|
||||
import '../../domain/entities/user.dart';
|
||||
import '../fcs_shipment/model/fcs_shipment_model.dart';
|
||||
import '../main/util.dart';
|
||||
import '../widgets/local_text.dart';
|
||||
import '../widgets/progress.dart';
|
||||
@@ -64,20 +65,37 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_init();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
_init() async {
|
||||
_sender = User(
|
||||
name: "ptd-phyo44 kaelone",
|
||||
fcsID: "FCS-8X6V",
|
||||
phoneNumber: "+959444444444",
|
||||
id: "48u_4s-HiQeW-HwSqeRd9TSMWh3mLZfSk5rpaUEh_zw");
|
||||
name: widget.carton.senderName,
|
||||
fcsID: widget.carton.senderFCSID,
|
||||
id: widget.carton.senderID);
|
||||
|
||||
_consignee = User(
|
||||
id: "HsIwG88K-0_HSazgEy5QR27kcjkOvfv7_Sr1JP18Q1A",
|
||||
name: "One One",
|
||||
phoneNumber: "+959111111111",
|
||||
fcsID: "FCS-EFRF");
|
||||
id: widget.carton.userID,
|
||||
name: widget.carton.userName,
|
||||
fcsID: widget.carton.fcsID);
|
||||
|
||||
_billToValue = widget.carton.billTo ?? billToSender;
|
||||
_selectedDeliveryType = delivery_caton;
|
||||
_cartonSizeType = customCarton;
|
||||
_length = widget.carton.length;
|
||||
_width = widget.carton.width;
|
||||
_height = widget.carton.height;
|
||||
|
||||
var s = await context
|
||||
.read<FcsShipmentModel>()
|
||||
.getFcsShipment(widget.carton.fcsShipmentID ?? "");
|
||||
_shipment = s;
|
||||
|
||||
context.read<PackageSelectionModel>().clearSelection();
|
||||
super.initState();
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -116,7 +134,7 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
|
||||
},
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
title: LocalText(context, 'boxes.new',
|
||||
title: LocalText(context, 'box.update_title',
|
||||
color: primaryColor, fontSize: 20),
|
||||
),
|
||||
body: Column(
|
||||
@@ -220,6 +238,7 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
|
||||
} else {
|
||||
return Expanded(
|
||||
child: CartonSubmit(
|
||||
isNew: false,
|
||||
sender: _sender!,
|
||||
consingee: _consignee!,
|
||||
billToValue: _billToValue,
|
||||
|
||||
@@ -63,7 +63,7 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
|
||||
List<String> _deliveryTypes = [delivery_caton, pickup_carton];
|
||||
|
||||
FcsShipment? _shipment;
|
||||
String _cartionSizeType = standardCarton;
|
||||
String _cartonSizeType = standardCarton;
|
||||
|
||||
List<FcsShipment> _shipments = [];
|
||||
CartonSize? _selectStandardSize;
|
||||
@@ -83,34 +83,40 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
|
||||
_init() async {
|
||||
_selectedDeliveryType = widget.deliveryType;
|
||||
_billToValue = widget.billType;
|
||||
_shipment = widget.shipment;
|
||||
_cartionSizeType = widget.cartonSizeType;
|
||||
_cartonSizeType = widget.cartonSizeType;
|
||||
|
||||
List<CartonSize> cartonSizes = context.read<CartonSizeModel>().cartonSizes;
|
||||
_selectStandardSize = widget.standardSize ?? cartonSizes.first;
|
||||
|
||||
_lengthController.text =
|
||||
widget.length == null ? "0" : widget.length.toString();
|
||||
widget.length == null ? "0" : removeTrailingZeros(widget.length ?? 0);
|
||||
_widthController.text =
|
||||
widget.width == null ? "0" : widget.width.toString();
|
||||
widget.width == null ? "0" : removeTrailingZeros(widget.width ?? 0);
|
||||
_heightController.text =
|
||||
widget.height == null ? "0" : widget.height.toString();
|
||||
widget.height == null ? "0" : removeTrailingZeros(widget.height ?? 0);
|
||||
|
||||
var fcsShipments =
|
||||
await context.read<FcsShipmentModel>().getActiveFcsShipments();
|
||||
_shipments = fcsShipments;
|
||||
_shipment = widget.shipment;
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant CartonSizeWidget oldWidget) {
|
||||
_init();
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<CartonSize> cartonSizes = context.watch<CartonSizeModel>().cartonSizes;
|
||||
bool isStandardSize = _cartionSizeType == standardCarton;
|
||||
bool isCustomSize = _cartionSizeType == customCarton;
|
||||
bool isNoneDefinedSize = _cartionSizeType == packageCartion;
|
||||
bool isStandardSize = _cartonSizeType == standardCarton;
|
||||
bool isCustomSize = _cartonSizeType == customCarton;
|
||||
bool isNoneDefinedSize = _cartonSizeType == packageCartion;
|
||||
|
||||
final senderBox = DisplayText(
|
||||
text: widget.sender.name,
|
||||
@@ -242,7 +248,7 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
|
||||
|
||||
if (widget.onContinue != null) {
|
||||
widget.onContinue!(
|
||||
_selectedDeliveryType, _billToValue, _shipment!, _cartionSizeType,
|
||||
_selectedDeliveryType, _billToValue, _shipment!, _cartonSizeType,
|
||||
standardSize: _selectStandardSize, length: l, width: w, height: h);
|
||||
}
|
||||
});
|
||||
@@ -321,16 +327,16 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_cartionSizeType = standardCarton;
|
||||
_cartonSizeType = standardCarton;
|
||||
});
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
LocalRadio(
|
||||
value: standardCarton,
|
||||
groupValue: _cartionSizeType,
|
||||
groupValue: _cartonSizeType,
|
||||
onChanged: (p0) {
|
||||
setState(() {
|
||||
_cartionSizeType = standardCarton;
|
||||
_cartonSizeType = standardCarton;
|
||||
});
|
||||
},
|
||||
),
|
||||
@@ -350,16 +356,16 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_cartionSizeType = customCarton;
|
||||
_cartonSizeType = customCarton;
|
||||
});
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
LocalRadio(
|
||||
value: customCarton,
|
||||
groupValue: _cartionSizeType,
|
||||
groupValue: _cartonSizeType,
|
||||
onChanged: (p0) {
|
||||
setState(() {
|
||||
_cartionSizeType = customCarton;
|
||||
_cartonSizeType = customCarton;
|
||||
});
|
||||
},
|
||||
),
|
||||
@@ -379,16 +385,16 @@ class _CartonSizeWidgetState extends State<CartonSizeWidget> {
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_cartionSizeType = packageCartion;
|
||||
_cartonSizeType = packageCartion;
|
||||
});
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
LocalRadio(
|
||||
value: packageCartion,
|
||||
groupValue: _cartionSizeType,
|
||||
groupValue: _cartonSizeType,
|
||||
onChanged: (p0) {
|
||||
setState(() {
|
||||
_cartionSizeType = packageCartion;
|
||||
_cartonSizeType = packageCartion;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
@@ -35,6 +35,7 @@ class CartonSubmit extends StatelessWidget {
|
||||
final List<CargoType> surchareItems;
|
||||
final OnCreateCarton? onCreate;
|
||||
final OnPrevious? onPrevious;
|
||||
final bool isNew;
|
||||
const CartonSubmit(
|
||||
{Key? key,
|
||||
required this.sender,
|
||||
@@ -51,7 +52,8 @@ class CartonSubmit extends StatelessWidget {
|
||||
this.width = 0,
|
||||
this.height = 0,
|
||||
this.cargoTypes = const [],
|
||||
this.surchareItems = const []})
|
||||
this.surchareItems = const [],
|
||||
this.isNew = true})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -310,7 +312,8 @@ class CartonSubmit extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: LocalText(context, 'box.crete.carton',
|
||||
child: LocalText(
|
||||
context, isNew ? 'box.crete.carton' : "box.update.btn",
|
||||
color: Colors.white, fontSize: 15),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// ignore_for_file: deprecated_member_use
|
||||
|
||||
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@@ -50,10 +51,26 @@ class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
context.read<CartonSelectionModel>().clearSelection();
|
||||
_init();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
_init() async {
|
||||
var s = await context
|
||||
.read<FcsShipmentModel>()
|
||||
.getFcsShipment(widget.carton.fcsShipmentID ?? "");
|
||||
_shipment = s;
|
||||
_cartonSizeType = customCarton;
|
||||
_length = widget.carton.length;
|
||||
_width = widget.carton.width;
|
||||
_height = widget.carton.height;
|
||||
|
||||
context.read<CartonSelectionModel>().clearSelection();
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
@@ -90,7 +107,7 @@ class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
},
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
title: LocalText(context, 'boxes.new',
|
||||
title: LocalText(context, 'box.update_title',
|
||||
color: primaryColor, fontSize: 20),
|
||||
),
|
||||
body: Column(
|
||||
@@ -163,6 +180,7 @@ class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
} else {
|
||||
return Expanded(
|
||||
child: MixCartonSubmit(
|
||||
isNew: false,
|
||||
cartonSizeType: _cartonSizeType,
|
||||
standardSize: _standardSize,
|
||||
length: _length,
|
||||
@@ -171,7 +189,7 @@ class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
shipment: _shipment!,
|
||||
cartons: _cartons,
|
||||
onCreate: () {
|
||||
_create();
|
||||
_update();
|
||||
},
|
||||
onPrevious: () {
|
||||
setState(() {
|
||||
@@ -183,7 +201,7 @@ class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
}
|
||||
}
|
||||
|
||||
_create() async {
|
||||
_update() async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ typedef OnCreateMixCarton = Function();
|
||||
typedef OnPrevious = Function();
|
||||
|
||||
class MixCartonSubmit extends StatefulWidget {
|
||||
final bool isNew;
|
||||
final FcsShipment shipment;
|
||||
final List<Carton> cartons;
|
||||
final String cartonSizeType;
|
||||
@@ -37,7 +38,8 @@ class MixCartonSubmit extends StatefulWidget {
|
||||
required this.cartonSizeType,
|
||||
this.length = 0,
|
||||
this.width = 0,
|
||||
this.height = 0})
|
||||
this.height = 0,
|
||||
this.isNew = true})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -253,7 +255,8 @@ class _MixCartonSubmitState extends State<MixCartonSubmit> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: LocalText(context, 'box.crete.carton',
|
||||
child: LocalText(context,
|
||||
widget.isNew ? 'box.crete.carton' : 'box.update.btn',
|
||||
color: Colors.white, fontSize: 15),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
|
||||
@@ -65,28 +65,33 @@ class _TypeWidgetState extends State<TypeWidget> {
|
||||
}
|
||||
|
||||
_init() async {
|
||||
_shipment = widget.shipment;
|
||||
_cartionSizeType = widget.cartonSizeType;
|
||||
|
||||
List<CartonSize> cartonSizes = context.read<CartonSizeModel>().cartonSizes;
|
||||
_selectStandardSize = widget.standardSize ?? cartonSizes.first;
|
||||
_cartionSizeType = widget.cartonSizeType;
|
||||
|
||||
_lengthController.text =
|
||||
widget.length == null ? "0" : widget.length.toString();
|
||||
widget.length == null ? "0" : removeTrailingZeros(widget.length ?? 0);
|
||||
_widthController.text =
|
||||
widget.width == null ? "0" : widget.width.toString();
|
||||
widget.width == null ? "0" : removeTrailingZeros(widget.width ?? 0);
|
||||
_heightController.text =
|
||||
widget.height == null ? "0" : widget.height.toString();
|
||||
widget.height == null ? "0" : removeTrailingZeros(widget.height ?? 0);
|
||||
|
||||
var fcsShipments =
|
||||
await context.read<FcsShipmentModel>().getActiveFcsShipments();
|
||||
_shipments = fcsShipments;
|
||||
_shipment = widget.shipment;
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant TypeWidget oldWidget) {
|
||||
_init();
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<CartonSize> cartonSizes = context.watch<CartonSizeModel>().cartonSizes;
|
||||
|
||||
Reference in New Issue
Block a user