update package and carton selection
This commit is contained in:
@@ -56,35 +56,32 @@ class _CartonSelectionWidgetState extends State<CartonSelectionWidget> {
|
||||
|
||||
_init() {
|
||||
var model = context.read<CartonSelectionModel>();
|
||||
model.addDefaultCartons(widget.shipment.id!);
|
||||
_controller.text = model.query;
|
||||
_query = model.query;
|
||||
model.refresh(widget.shipment.id!, term: _query);
|
||||
|
||||
model.addSelectedCarton(widget.cartons);
|
||||
|
||||
_controller.text = model.query;
|
||||
_query = model.query;
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant CartonSelectionWidget oldWidget) {
|
||||
_init();
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
// @override
|
||||
// void didUpdateWidget(covariant CartonSelectionWidget oldWidget) {
|
||||
// _init();
|
||||
// super.didUpdateWidget(oldWidget);
|
||||
// }
|
||||
|
||||
Future<void> _loadMoreData() async {
|
||||
if (_isLoadMore) return;
|
||||
var model = context.read<CartonSelectionModel>();
|
||||
if (model.reachEnd || model.ended) return;
|
||||
if (model.ended) return;
|
||||
setState(() {
|
||||
_isLoadMore = true;
|
||||
});
|
||||
if (_query != "") {
|
||||
await model.loadMoreSearch(term: _query, shipmentId: widget.shipment.id!);
|
||||
} else {
|
||||
await model.loadMoreData(widget.shipment.id!);
|
||||
}
|
||||
|
||||
await model.loadMoreData(widget.shipment.id!, term: _query);
|
||||
|
||||
setState(() {
|
||||
_isLoadMore = false;
|
||||
@@ -95,7 +92,7 @@ class _CartonSelectionWidgetState extends State<CartonSelectionWidget> {
|
||||
Widget build(BuildContext context) {
|
||||
var model = context.watch<CartonSelectionModel>();
|
||||
List<Carton> searchResults = model.cartons;
|
||||
List<Carton> selectedCartonList = model.selectedCartonList;
|
||||
List<Carton> selectedCartonList = model.selectedCartons;
|
||||
|
||||
final continueBtn = ContinueButton(
|
||||
onTap: () {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:fcs/pages/widgets/local_radio.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -6,6 +7,7 @@ import '../../../domain/constants.dart';
|
||||
import '../../../domain/entities/carton_size.dart';
|
||||
import '../../../domain/entities/fcs_shipment.dart';
|
||||
import '../../../helpers/theme.dart';
|
||||
import '../../carton_size/carton_size_list.dart';
|
||||
import '../../carton_size/model/carton_size_model.dart';
|
||||
import '../../fcs_shipment/model/fcs_shipment_model.dart';
|
||||
import '../../main/util.dart';
|
||||
@@ -17,6 +19,7 @@ import '../../widgets/local_title.dart';
|
||||
import '../../widgets/previous_button.dart';
|
||||
|
||||
typedef OnPrevious = Function();
|
||||
const manageStandardCartonSize = "Manage carton size";
|
||||
|
||||
typedef OnContinue = Function(FcsShipment shipment, String cartonSizeType,
|
||||
{CartonSize? standardSize, double? length, double? width, double? height});
|
||||
@@ -101,7 +104,9 @@ class _TypeWidgetState extends State<TypeWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<CartonSize> cartonSizes = context.watch<CartonSizeModel>().cartonSizes;
|
||||
List<CartonSize> cartonSizes =
|
||||
context.watch<CartonSizeModel>().getCartonSizes;
|
||||
|
||||
bool isStandardSize = _cartionSizeType == standardCarton;
|
||||
bool isCustomSize = _cartionSizeType == customCarton;
|
||||
bool isNoneDefinedSize = _cartionSizeType == packageCartion;
|
||||
@@ -156,6 +161,11 @@ class _TypeWidgetState extends State<TypeWidget> {
|
||||
underline: Container(height: 1, color: Colors.grey),
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
if (newValue?.name == MANAGE_CARTONSIZE) {
|
||||
_selectStandardSize = null;
|
||||
_manageCartonSize();
|
||||
return;
|
||||
}
|
||||
_selectStandardSize = newValue!;
|
||||
});
|
||||
},
|
||||
@@ -164,16 +174,22 @@ class _TypeWidgetState extends State<TypeWidget> {
|
||||
cartonSizes.map<DropdownMenuItem<CartonSize>>((CartonSize value) {
|
||||
return DropdownMenuItem<CartonSize>(
|
||||
value: value,
|
||||
child: Row(
|
||||
children: [
|
||||
Text("${value.name} - ",
|
||||
child: value.name == MANAGE_CARTONSIZE
|
||||
? Text("${value.name}",
|
||||
style: TextStyle(
|
||||
color: isStandardSize ? Colors.black : labelColor)),
|
||||
Text(
|
||||
"${value.length.toInt()}”x${value.width.toInt()}”x${value.height.toInt()}”",
|
||||
style: TextStyle(color: labelColor)),
|
||||
],
|
||||
),
|
||||
color: isStandardSize ? secondaryColor : labelColor))
|
||||
: Row(
|
||||
children: [
|
||||
Text("${value.name} - ",
|
||||
style: TextStyle(
|
||||
color: isStandardSize
|
||||
? Colors.black
|
||||
: labelColor)),
|
||||
Text(
|
||||
"${value.length.toInt()}”x${value.width.toInt()}”x${value.height.toInt()}”",
|
||||
style: TextStyle(color: labelColor)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
@@ -355,4 +371,11 @@ class _TypeWidgetState extends State<TypeWidget> {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
_manageCartonSize() {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => CartonSizeList()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user