update carton info
This commit is contained in:
@@ -1,118 +0,0 @@
|
|||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
|
||||||
import 'package:fcs/helpers/theme.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class CargoTable extends StatefulWidget {
|
|
||||||
final List<CargoType>? cargoTypes;
|
|
||||||
|
|
||||||
const CargoTable({
|
|
||||||
Key? key,
|
|
||||||
this.cargoTypes,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
_CargoTableState createState() => _CargoTableState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CargoTableState extends State<CargoTable> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
child: DataTable(
|
|
||||||
headingRowHeight: 40,
|
|
||||||
columnSpacing: 50,
|
|
||||||
showCheckboxColumn: false,
|
|
||||||
decoration: BoxDecoration(border: Border.all(color: Colors.white)),
|
|
||||||
border: TableBorder(horizontalInside: BorderSide(color: Colors.white)),
|
|
||||||
columns: [
|
|
||||||
DataColumn(
|
|
||||||
label: LocalText(
|
|
||||||
context,
|
|
||||||
"cargo.type",
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DataColumn(
|
|
||||||
label: LocalText(
|
|
||||||
context,
|
|
||||||
"cargo.qty",
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DataColumn(
|
|
||||||
label: LocalText(
|
|
||||||
context,
|
|
||||||
"cargo.weight",
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
rows: getCargoRows(context),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<DataRow> getCargoRows(BuildContext context) {
|
|
||||||
if (widget.cargoTypes == null) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
double total = 0;
|
|
||||||
var rows = widget.cargoTypes!.map((c) {
|
|
||||||
total += c.weight;
|
|
||||||
return DataRow(
|
|
||||||
onSelectChanged: (bool? selected) async {},
|
|
||||||
cells: [
|
|
||||||
DataCell(new Text(
|
|
||||||
c.name ?? "",
|
|
||||||
style: textStyle,
|
|
||||||
)),
|
|
||||||
DataCell(c.qty == 0
|
|
||||||
? Center(
|
|
||||||
child: Text(
|
|
||||||
"-",
|
|
||||||
style: textStyle,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Center(
|
|
||||||
child: Text(
|
|
||||||
c.qty.toString(),
|
|
||||||
style: textStyle,
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
DataCell(
|
|
||||||
Text(c.weight.toStringAsFixed(2), style: textStyle),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
var totalRow = DataRow(
|
|
||||||
onSelectChanged: (bool? selected) {},
|
|
||||||
cells: [
|
|
||||||
DataCell(Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: LocalText(
|
|
||||||
context,
|
|
||||||
"shipment.cargo.total",
|
|
||||||
color: Colors.black87,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
DataCell(Text("")),
|
|
||||||
DataCell(
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 48.0),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: Text(total.toStringAsFixed(2)+" lb",
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold))),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
rows.add(totalRow);
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
|
||||||
import 'package:fcs/helpers/theme.dart';
|
|
||||||
import 'package:fcs/pages/main/util.dart';
|
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_title.dart';
|
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
class CargoTypeAddition extends StatefulWidget {
|
|
||||||
@override
|
|
||||||
_CargoTypeAdditionState createState() => _CargoTypeAdditionState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|
||||||
bool _isLoading = false;
|
|
||||||
|
|
||||||
List<CargoType> cargos = [];
|
|
||||||
List<CargoType> specialCargos = [];
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
var shipmentRateModel =
|
|
||||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
|
||||||
|
|
||||||
cargos = shipmentRateModel.rate.cargoTypes.map((e) => e.clone()).toList();
|
|
||||||
specialCargos = List.from(shipmentRateModel.rate.customDuties);
|
|
||||||
specialCargos =
|
|
||||||
shipmentRateModel.rate.customDuties.map((e) => e.clone()).toList();
|
|
||||||
|
|
||||||
cargos.forEach((p) {
|
|
||||||
p.isChecked = false;
|
|
||||||
p.isCutomDuty = false;
|
|
||||||
p.weight = 0;
|
|
||||||
p.qty = 0;
|
|
||||||
});
|
|
||||||
specialCargos.forEach((p) {
|
|
||||||
p.isChecked = false;
|
|
||||||
p.isCutomDuty = true;
|
|
||||||
p.weight = 0;
|
|
||||||
p.qty = 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
List<Widget> getCargoRowList(List<CargoType> _c) {
|
|
||||||
return _c.map((c) {
|
|
||||||
return Container(
|
|
||||||
child: Container(
|
|
||||||
padding:
|
|
||||||
EdgeInsets.only(left: 10.0, right: 5.0, top: 3.0, bottom: 3.0),
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
c.isChecked = !c.isChecked;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Checkbox(
|
|
||||||
value: c.isChecked,
|
|
||||||
activeColor: primaryColor,
|
|
||||||
onChanged: (bool? check) {
|
|
||||||
setState(() {
|
|
||||||
c.isChecked = check ?? false;
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
new Text(c.name ?? '', style: textStyle),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
final saveBtn = fcsButton(
|
|
||||||
context,
|
|
||||||
getLocalString(context, 'box.cargo.select.btn'),
|
|
||||||
callack: () {
|
|
||||||
List<CargoType> _cargos =
|
|
||||||
this.cargos.where((c) => c.isChecked).toList();
|
|
||||||
List<CargoType> _scargos =
|
|
||||||
this.specialCargos.where((c) => c.isChecked).toList();
|
|
||||||
_cargos.addAll(_scargos);
|
|
||||||
Navigator.pop(context, _cargos);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return LocalProgress(
|
|
||||||
inAsyncCall: _isLoading,
|
|
||||||
child: Scaffold(
|
|
||||||
appBar: LocalAppBar(
|
|
||||||
labelKey: 'cargo.form.title',
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
labelColor: primaryColor,
|
|
||||||
arrowColor: primaryColor),
|
|
||||||
body: Container(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
child: ListView(
|
|
||||||
shrinkWrap: true,
|
|
||||||
children: <Widget>[
|
|
||||||
LocalTitle(
|
|
||||||
textKey: "box.select.cargo.title",
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: getCargoRowList(cargos),
|
|
||||||
),
|
|
||||||
LocalTitle(
|
|
||||||
textKey: "box.select.cargo.title",
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: getCargoRowList(specialCargos),
|
|
||||||
),
|
|
||||||
SizedBox(height: 30),
|
|
||||||
saveBtn,
|
|
||||||
SizedBox(height: 20),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,260 +0,0 @@
|
|||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
|
||||||
import 'package:fcs/helpers/theme.dart';
|
|
||||||
import 'package:fcs/pages/main/util.dart';
|
|
||||||
import 'package:fcs/pages/widgets/dialog_input.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
typedef OnRemove(CargoType cargoType);
|
|
||||||
typedef OnUpdate(CargoType cargoType);
|
|
||||||
|
|
||||||
class CargoTable extends StatefulWidget {
|
|
||||||
final List<CargoType>? cargoTypes;
|
|
||||||
final bool? isNew;
|
|
||||||
final OnRemove? onRemove;
|
|
||||||
final OnUpdate? onUpdate;
|
|
||||||
|
|
||||||
const CargoTable(
|
|
||||||
{Key? key, this.cargoTypes, this.isNew, this.onRemove, this.onUpdate})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
_CargoTableState createState() => _CargoTableState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CargoTableState extends State<CargoTable> {
|
|
||||||
double totalWeight = 0;
|
|
||||||
List<CargoType>? cargoTypes;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
cargoTypes = widget.cargoTypes;
|
|
||||||
if (!widget.isNew!) {
|
|
||||||
totalWeight =
|
|
||||||
cargoTypes!.fold(0, (previous, current) => previous + current.weight);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
child: DataTable(
|
|
||||||
showCheckboxColumn: false,
|
|
||||||
headingRowHeight: 40,
|
|
||||||
// columnSpacing: 40,
|
|
||||||
decoration: BoxDecoration(border: Border.all(color: Colors.white)),
|
|
||||||
border: TableBorder(horizontalInside: BorderSide(color: Colors.white)),
|
|
||||||
columns: [
|
|
||||||
DataColumn(
|
|
||||||
label: LocalText(
|
|
||||||
context,
|
|
||||||
"cargo.type",
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DataColumn(
|
|
||||||
label: LocalText(
|
|
||||||
context,
|
|
||||||
"cargo.qty",
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DataColumn(
|
|
||||||
label: LocalText(
|
|
||||||
context,
|
|
||||||
"cargo.weight",
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
rows: getCargoRows(context),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<DataRow> getCargoRows(BuildContext context) {
|
|
||||||
if (cargoTypes == null) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
var rows = cargoTypes!.map((c) {
|
|
||||||
return DataRow(
|
|
||||||
onSelectChanged: (bool? selected) async {},
|
|
||||||
cells: [
|
|
||||||
DataCell(
|
|
||||||
new Text(
|
|
||||||
c.name ?? '',
|
|
||||||
style: textStyle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DataCell(
|
|
||||||
c.isCutomDuty
|
|
||||||
? GestureDetector(
|
|
||||||
onTap: () async {
|
|
||||||
String? _t = await showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => DialogInput(
|
|
||||||
label: "cargo.qty", value: c.qty.toString()));
|
|
||||||
|
|
||||||
if (_t == null) return;
|
|
||||||
setState(() {
|
|
||||||
c.qty = int.tryParse(_t) ?? 0;
|
|
||||||
});
|
|
||||||
if (widget.onUpdate != null) widget.onUpdate!(c);
|
|
||||||
},
|
|
||||||
child: Center(
|
|
||||||
child: Container(
|
|
||||||
width: 40,
|
|
||||||
padding: const EdgeInsets.all(7.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(color: primaryColor),
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
|
||||||
),
|
|
||||||
child: new Text(
|
|
||||||
c.qty.toString(),
|
|
||||||
style: textStyle,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Center(
|
|
||||||
child: new Text(
|
|
||||||
"-",
|
|
||||||
style: textStyle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DataCell(
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () async {
|
|
||||||
if (this.totalWeight <= 0) {
|
|
||||||
showMsgDialog(
|
|
||||||
context, "Error", "Please insert total weight");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String? _t = await showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => DialogInput(
|
|
||||||
label: "cargo.weight",
|
|
||||||
value: c.weight.toStringAsFixed(2)));
|
|
||||||
|
|
||||||
if (_t == null) return;
|
|
||||||
setState(() {
|
|
||||||
c.weight = double.tryParse(_t) ?? 0;
|
|
||||||
});
|
|
||||||
if (c.weight != 0) {
|
|
||||||
_cal();
|
|
||||||
}
|
|
||||||
if (widget.onUpdate != null) widget.onUpdate!(c);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(7.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(color: primaryColor),
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
|
||||||
),
|
|
||||||
child: Text(c.weight.toStringAsFixed(2), style: textStyle),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
widget.onRemove == null
|
|
||||||
? SizedBox(
|
|
||||||
width: 50,
|
|
||||||
)
|
|
||||||
: IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.remove_circle,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
if (widget.onRemove != null) widget.onRemove!(c);
|
|
||||||
})
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
var totalRow = DataRow(
|
|
||||||
onSelectChanged: (bool? selected) {},
|
|
||||||
cells: [
|
|
||||||
DataCell(Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: LocalText(
|
|
||||||
context,
|
|
||||||
"shipment.cargo.total",
|
|
||||||
color: Colors.black87,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
DataCell(Text("")),
|
|
||||||
DataCell(
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 48.0),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () async {
|
|
||||||
String? _t = await showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => DialogInput(
|
|
||||||
label: "shipment.cargo.total",
|
|
||||||
value: totalWeight.toStringAsFixed(2)),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (_t == null) return;
|
|
||||||
setState(() {
|
|
||||||
totalWeight = double.tryParse(_t) ?? 0;
|
|
||||||
});
|
|
||||||
_cal();
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(7.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(color: primaryColor),
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
|
||||||
),
|
|
||||||
child: Text(totalWeight.toStringAsFixed(2),
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
rows.add(totalRow);
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
_cal() {
|
|
||||||
var cargoType = autoCalWeight(cargoTypes!, totalWeight);
|
|
||||||
if (cargoType == null) return;
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
cargoTypes!.remove(cargoType);
|
|
||||||
cargoTypes!.add(cargoType);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (widget.onUpdate != null) {
|
|
||||||
widget.onUpdate!(cargoType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CargoType? autoCalWeight(List<CargoType> cargoTypes, double total) {
|
|
||||||
List<CargoType> noWeight = cargoTypes.where((c) => c.weight == 0).toList();
|
|
||||||
if (noWeight.length != 1) return null;
|
|
||||||
|
|
||||||
double _existing =
|
|
||||||
cargoTypes.fold(0, (previous, current) => previous + current.weight);
|
|
||||||
|
|
||||||
noWeight[0].weight = total - _existing;
|
|
||||||
return noWeight[0];
|
|
||||||
}
|
|
||||||
@@ -14,10 +14,10 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import '../main/util.dart';
|
import '../main/util.dart';
|
||||||
import 'carton_editor_for_package.dart';
|
import 'carton_package_form.dart';
|
||||||
import 'carton_info.dart';
|
import 'carton_info.dart';
|
||||||
import 'mix_carton/mix_carton_form.dart';
|
import 'mix_carton/mix_carton_form.dart';
|
||||||
import 'carton_row.dart';
|
import 'widget/carton_row.dart';
|
||||||
|
|
||||||
class CartonEditor extends StatefulWidget {
|
class CartonEditor extends StatefulWidget {
|
||||||
final Carton? carton;
|
final Carton? carton;
|
||||||
@@ -154,7 +154,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => CartonEditorForPackage(
|
builder: (context) => CartonPackageForm(
|
||||||
sender: _sender!,
|
sender: _sender!,
|
||||||
consignee: _consignee!,
|
consignee: _consignee!,
|
||||||
)));
|
)));
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import '../../helpers/theme.dart';
|
|||||||
import '../../localization/app_translations.dart';
|
import '../../localization/app_translations.dart';
|
||||||
import '../main/util.dart';
|
import '../main/util.dart';
|
||||||
import '../widgets/local_text.dart';
|
import '../widgets/local_text.dart';
|
||||||
import 'user_search_result.dart';
|
import 'widget/user_search_result.dart';
|
||||||
import 'model/carton_model.dart';
|
import 'model/carton_model.dart';
|
||||||
import 'model/consignee_selection_model.dart';
|
import 'model/consignee_selection_model.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ import '../widgets/multi_img_file.dart';
|
|||||||
|
|
||||||
typedef void FindCallBack();
|
typedef void FindCallBack();
|
||||||
|
|
||||||
class CartonImageUpload extends StatefulWidget {
|
class CartonImageUploadEditor extends StatefulWidget {
|
||||||
final Carton? box;
|
final Carton? box;
|
||||||
const CartonImageUpload({this.box});
|
const CartonImageUploadEditor({this.box});
|
||||||
@override
|
@override
|
||||||
_CartonImageUploaState createState() => _CartonImageUploaState();
|
_CartonImageUploaState createState() => _CartonImageUploaState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CartonImageUploaState extends State<CartonImageUpload> {
|
class _CartonImageUploaState extends State<CartonImageUploadEditor> {
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
Carton? _box;
|
Carton? _box;
|
||||||
MultiImgController multiImgController = MultiImgController();
|
MultiImgController multiImgController = MultiImgController();
|
||||||
@@ -3,7 +3,7 @@ import 'package:fcs/domain/entities/cargo_type.dart';
|
|||||||
import 'package:fcs/domain/entities/carton.dart';
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/carton/carton_image_upload.dart';
|
import 'package:fcs/pages/carton/carton_image_upload_editor.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/package/model/package_model.dart';
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
@@ -18,6 +18,7 @@ import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import '../widgets/local_button.dart';
|
import '../widgets/local_button.dart';
|
||||||
|
import 'carton_package_editor.dart';
|
||||||
import 'mix_carton/mix_carton_editor.dart';
|
import 'mix_carton/mix_carton_editor.dart';
|
||||||
import 'model/carton_model.dart';
|
import 'model/carton_model.dart';
|
||||||
|
|
||||||
@@ -297,7 +298,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => CartonImageUpload(box: _carton)),
|
builder: (context) => CartonImageUploadEditor(box: _carton)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: const Text('Upload Images'),
|
child: const Text('Upload Images'),
|
||||||
@@ -404,28 +405,25 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_gotoEditor() async {
|
_gotoEditor() async {
|
||||||
if (_carton.cartonType == carton_mix_carton) {
|
bool? updated = _carton.cartonType == carton_mix_carton
|
||||||
bool? updated = await Navigator.push<bool>(
|
? await Navigator.push<bool>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => MixCartonEditor(carton: _carton)),
|
builder: (context) => MixCartonEditor(carton: _carton)),
|
||||||
);
|
)
|
||||||
|
: await Navigator.push<bool>(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => CartonPackageEditor(carton: _carton)),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (updated ?? false) {
|
||||||
|
Carton? c =
|
||||||
|
await context.read<CartonModel>().getCarton(widget.carton.id ?? "");
|
||||||
|
if (c == null) return;
|
||||||
|
_carton = c;
|
||||||
|
_init();
|
||||||
}
|
}
|
||||||
// bool? updated = await Navigator.push<bool>(
|
|
||||||
// context,
|
|
||||||
// CupertinoPageRoute(
|
|
||||||
// builder: (context) => MixCartonEditor(carton: _carton)),
|
|
||||||
// );
|
|
||||||
// if (updated ?? false) {
|
|
||||||
// // var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
|
||||||
// // var c = await cartonModel.getCarton(widget.box.id ?? "");
|
|
||||||
// // setState(() {
|
|
||||||
// // _box = c;
|
|
||||||
// // _loadPackages();
|
|
||||||
// // _loadMixCartons();
|
|
||||||
// // _updateBoxData();
|
|
||||||
// // });
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_delete() {
|
_delete() {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import '../fcs_shipment/model/fcs_shipment_model.dart';
|
|||||||
import 'carton_editor.dart';
|
import 'carton_editor.dart';
|
||||||
import 'carton_filter.dart';
|
import 'carton_filter.dart';
|
||||||
import 'carton_info.dart';
|
import 'carton_info.dart';
|
||||||
import 'carton_list_row.dart';
|
import 'widget/carton_list_row.dart';
|
||||||
|
|
||||||
class CartonList extends StatefulWidget {
|
class CartonList extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
|
|||||||
263
lib/pages/carton/carton_package_editor.dart
Normal file
263
lib/pages/carton/carton_package_editor.dart
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
// ignore_for_file: deprecated_member_use
|
||||||
|
|
||||||
|
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_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/carton.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 'carton_submit.dart';
|
||||||
|
import 'model/package_selection_model.dart';
|
||||||
|
import 'package_selection_widget.dart';
|
||||||
|
|
||||||
|
class CartonPackageEditor extends StatefulWidget {
|
||||||
|
final Carton carton;
|
||||||
|
|
||||||
|
const CartonPackageEditor({Key? key, required this.carton}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CartonPackageEditor> createState() => _CartonPackageEditorState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CartonPackageEditorState extends State<CartonPackageEditor> {
|
||||||
|
var dateFormatter = DateFormat('dd MMM yyyy');
|
||||||
|
final NumberFormat numberFormatter = NumberFormat("#,###");
|
||||||
|
List<LocalStep> steps = [
|
||||||
|
LocalStep(lable: 'Size', stepType: StepType.SIZE),
|
||||||
|
LocalStep(lable: 'Packages', stepType: StepType.PACKAGES),
|
||||||
|
LocalStep(lable: 'Cargos', stepType: StepType.CARGOS),
|
||||||
|
LocalStep(lable: 'Submit', stepType: StepType.SUBMIT)
|
||||||
|
];
|
||||||
|
List<Package> _packages = [];
|
||||||
|
List<CargoType> _cargoTypes = [];
|
||||||
|
List<CargoType> _surchareItems = [];
|
||||||
|
|
||||||
|
int currentStep = 0;
|
||||||
|
double _length = 0;
|
||||||
|
double _width = 0;
|
||||||
|
double _height = 0;
|
||||||
|
|
||||||
|
String _selectedDeliveryType = delivery_caton;
|
||||||
|
String _billToValue = billToSender;
|
||||||
|
|
||||||
|
FcsShipment? _shipment;
|
||||||
|
String _cartonSizeType = standardCarton;
|
||||||
|
CartonSize? _standardSize;
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
|
User? _consignee;
|
||||||
|
User? _sender;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_sender = User(
|
||||||
|
name: "ptd-phyo44 kaelone",
|
||||||
|
fcsID: "FCS-8X6V",
|
||||||
|
phoneNumber: "+959444444444",
|
||||||
|
id: "48u_4s-HiQeW-HwSqeRd9TSMWh3mLZfSk5rpaUEh_zw");
|
||||||
|
|
||||||
|
_consignee = User(
|
||||||
|
id: "HsIwG88K-0_HSazgEy5QR27kcjkOvfv7_Sr1JP18Q1A",
|
||||||
|
name: "One One",
|
||||||
|
phoneNumber: "+959111111111",
|
||||||
|
fcsID: "FCS-EFRF");
|
||||||
|
|
||||||
|
context.read<PackageSelectionModel>().clearSelection();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return WillPopScope(
|
||||||
|
onWillPop: () {
|
||||||
|
if (currentStep == 0) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
if (currentStep > 0) {
|
||||||
|
setState(() {
|
||||||
|
currentStep -= 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Future.value(false);
|
||||||
|
},
|
||||||
|
child: LocalProgress(
|
||||||
|
inAsyncCall: _isLoading,
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
elevation: 0,
|
||||||
|
centerTitle: true,
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(CupertinoIcons.back,
|
||||||
|
color: primaryColor, size: 25),
|
||||||
|
onPressed: () {
|
||||||
|
if (currentStep == 0) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
if (currentStep > 0) {
|
||||||
|
setState(() {
|
||||||
|
currentStep -= 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
title: LocalText(context, 'boxes.new',
|
||||||
|
color: primaryColor, fontSize: 20),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
StepperWidget(
|
||||||
|
labels: steps.map((e) => e.lable).toList(),
|
||||||
|
currentStep: currentStep,
|
||||||
|
eachStepWidth: MediaQuery.of(context).size.width / 4,
|
||||||
|
onChange: (index) {
|
||||||
|
if (index > currentStep) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
currentStep = index;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
getContent(currentStep)
|
||||||
|
],
|
||||||
|
))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getContent(int index) {
|
||||||
|
var step = steps[index];
|
||||||
|
if (step.stepType == StepType.SIZE) {
|
||||||
|
return Expanded(
|
||||||
|
child: CartonSizeWidget(
|
||||||
|
deliveryType: _selectedDeliveryType,
|
||||||
|
billType: _billToValue,
|
||||||
|
sender: _sender!,
|
||||||
|
consignee: _consignee!,
|
||||||
|
shipment: _shipment,
|
||||||
|
cartonSizeType: _cartonSizeType,
|
||||||
|
standardSize: _standardSize,
|
||||||
|
length: _length,
|
||||||
|
width: _width,
|
||||||
|
height: _height,
|
||||||
|
onPrevious: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
onContinue: (deliveryType, billType, shipment, cartonSizeType,
|
||||||
|
{standardSize, length, width, height}) {
|
||||||
|
setState(() {
|
||||||
|
_selectedDeliveryType = deliveryType;
|
||||||
|
_billToValue = billType;
|
||||||
|
_shipment = shipment;
|
||||||
|
_cartonSizeType = cartonSizeType;
|
||||||
|
_standardSize = standardSize;
|
||||||
|
_length = length ?? 0;
|
||||||
|
_width = width ?? 0;
|
||||||
|
_height = height ?? 0;
|
||||||
|
currentStep += 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else if (step.stepType == StepType.PACKAGES) {
|
||||||
|
return Expanded(
|
||||||
|
child: PackageSelectionWidget(
|
||||||
|
sender: _sender!,
|
||||||
|
consignee: _consignee!,
|
||||||
|
shipment: _shipment!,
|
||||||
|
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: _sender!,
|
||||||
|
consignee: _consignee!,
|
||||||
|
cargoTypes: _cargoTypes,
|
||||||
|
surchargeItems: _surchareItems,
|
||||||
|
onContinue: (cargoTypes, customDuties) {
|
||||||
|
setState(() {
|
||||||
|
_cargoTypes = List.from(cargoTypes);
|
||||||
|
_surchareItems = List.from(customDuties);
|
||||||
|
currentStep += 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onPrevious: (cargoTypes, customDuties) {
|
||||||
|
setState(() {
|
||||||
|
_cargoTypes = List.from(cargoTypes);
|
||||||
|
_surchareItems = List.from(customDuties);
|
||||||
|
currentStep -= 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Expanded(
|
||||||
|
child: CartonSubmit(
|
||||||
|
sender: _sender!,
|
||||||
|
consingee: _consignee!,
|
||||||
|
billToValue: _billToValue,
|
||||||
|
cartonSizeType: _cartonSizeType,
|
||||||
|
standardSize: _standardSize,
|
||||||
|
length: _length,
|
||||||
|
width: _width,
|
||||||
|
height: _height,
|
||||||
|
deliveryType: _selectedDeliveryType,
|
||||||
|
shipment: _shipment!,
|
||||||
|
packages: _packages,
|
||||||
|
cargoTypes: _cargoTypes,
|
||||||
|
surchareItems: _surchareItems,
|
||||||
|
onCreate: () {
|
||||||
|
_create();
|
||||||
|
},
|
||||||
|
onPrevious: () {
|
||||||
|
setState(() {
|
||||||
|
currentStep -= 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_create() async {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,11 +23,11 @@ import 'carton_submit.dart';
|
|||||||
import 'model/package_selection_model.dart';
|
import 'model/package_selection_model.dart';
|
||||||
import 'package_selection_widget.dart';
|
import 'package_selection_widget.dart';
|
||||||
|
|
||||||
class CartonEditorForPackage extends StatefulWidget {
|
class CartonPackageForm extends StatefulWidget {
|
||||||
final User sender;
|
final User sender;
|
||||||
final User consignee;
|
final User consignee;
|
||||||
|
|
||||||
const CartonEditorForPackage(
|
const CartonPackageForm(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
required this.sender,
|
required this.sender,
|
||||||
required this.consignee,
|
required this.consignee,
|
||||||
@@ -35,10 +35,10 @@ class CartonEditorForPackage extends StatefulWidget {
|
|||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CartonEditorForPackage> createState() => _CartonEditorForPackageState();
|
State<CartonPackageForm> createState() => _CartonPackageFormState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CartonEditorForPackageState extends State<CartonEditorForPackage> {
|
class _CartonPackageFormState extends State<CartonPackageForm> {
|
||||||
var dateFormatter = DateFormat('dd MMM yyyy');
|
var dateFormatter = DateFormat('dd MMM yyyy');
|
||||||
final NumberFormat numberFormatter = NumberFormat("#,###");
|
final NumberFormat numberFormatter = NumberFormat("#,###");
|
||||||
List<LocalStep> steps = [
|
List<LocalStep> steps = [
|
||||||
@@ -1,365 +0,0 @@
|
|||||||
import 'package:fcs/domain/constants.dart';
|
|
||||||
import 'package:fcs/domain/entities/carton.dart';
|
|
||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
|
||||||
import 'package:fcs/domain/entities/carton_size.dart';
|
|
||||||
import 'package:fcs/domain/entities/package.dart';
|
|
||||||
import 'package:fcs/domain/entities/user.dart';
|
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
|
||||||
import 'package:fcs/helpers/theme.dart';
|
|
||||||
import 'package:fcs/pages/carton_size/carton_size_list.dart';
|
|
||||||
import 'package:fcs/pages/carton_size/model/carton_size_model.dart';
|
|
||||||
import 'package:fcs/pages/main/util.dart';
|
|
||||||
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
|
||||||
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
|
||||||
import 'package:fcs/pages/widgets/length_picker.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_button.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_title.dart';
|
|
||||||
import 'package:fcs/pages/widgets/progress.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';
|
|
||||||
|
|
||||||
import 'cargo_type_addtion.dart';
|
|
||||||
import 'carton_cargo_table.dart';
|
|
||||||
import 'model/carton_model.dart';
|
|
||||||
|
|
||||||
class PackageCartonForm extends StatefulWidget {
|
|
||||||
final Carton? carton;
|
|
||||||
final bool? isNew;
|
|
||||||
final User? consignee;
|
|
||||||
PackageCartonForm({this.carton, this.isNew, this.consignee});
|
|
||||||
|
|
||||||
@override
|
|
||||||
_PackageCartonFormState createState() => _PackageCartonFormState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _PackageCartonFormState extends State<PackageCartonForm> {
|
|
||||||
TextEditingController _lengthCtl = new TextEditingController();
|
|
||||||
TextEditingController _widthCtl = new TextEditingController();
|
|
||||||
TextEditingController _heightCtl = new TextEditingController();
|
|
||||||
|
|
||||||
Carton? _carton;
|
|
||||||
bool _isLoading = false;
|
|
||||||
DeliveryAddress? _deliveryAddress = new DeliveryAddress();
|
|
||||||
List<CargoType> _cargoTypes = [];
|
|
||||||
CartonSize? selectedCatonSize;
|
|
||||||
bool isFromPackages = false;
|
|
||||||
bool isFromCartons = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_load();
|
|
||||||
}
|
|
||||||
|
|
||||||
_load() {
|
|
||||||
_carton = widget.carton;
|
|
||||||
isFromPackages = _carton!.cartonType == carton_from_packages;
|
|
||||||
isFromCartons = _carton!.cartonType == carton_from_cartons;
|
|
||||||
|
|
||||||
if (widget.isNew!) {
|
|
||||||
_lengthCtl.text = "0";
|
|
||||||
_widthCtl.text = "0";
|
|
||||||
_heightCtl.text = "0";
|
|
||||||
} else {
|
|
||||||
_cargoTypes = widget.carton!.cargoTypes.map((e) => e.clone()).toList();
|
|
||||||
_lengthCtl.text = _carton!.length.toString();
|
|
||||||
_widthCtl.text = _carton!.width.toString();
|
|
||||||
_heightCtl.text = _carton!.height.toString();
|
|
||||||
_deliveryAddress = _carton!.deliveryAddress;
|
|
||||||
_getCartonSize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_getCartonSize() {
|
|
||||||
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
|
||||||
cartonSizeModel.cartonSizes.forEach((c) {
|
|
||||||
if (c.length == _carton!.length &&
|
|
||||||
c.width == _carton!.width &&
|
|
||||||
c.height == _carton!.height) {
|
|
||||||
selectedCatonSize = CartonSize(
|
|
||||||
id: c.id,
|
|
||||||
name: c.name,
|
|
||||||
length: c.length,
|
|
||||||
width: c.width,
|
|
||||||
height: c.height);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final lengthBox = LengthPicker(
|
|
||||||
controller: _lengthCtl,
|
|
||||||
lableKey: "box.length",
|
|
||||||
isReadOnly: false,
|
|
||||||
);
|
|
||||||
final widthBox = LengthPicker(
|
|
||||||
controller: _widthCtl,
|
|
||||||
lableKey: "box.width",
|
|
||||||
isReadOnly: false,
|
|
||||||
);
|
|
||||||
final heightBox = LengthPicker(
|
|
||||||
controller: _heightCtl,
|
|
||||||
lableKey: "box.height",
|
|
||||||
isReadOnly: false,
|
|
||||||
);
|
|
||||||
final dimBox = Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
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),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
final createBtn = LocalButton(
|
|
||||||
textKey: widget.isNew! ? "box.new_carton_btn" : "box.cargo.save.btn",
|
|
||||||
callBack: _creatCarton,
|
|
||||||
);
|
|
||||||
|
|
||||||
final cargoTableTitleBox = LocalTitle(
|
|
||||||
textKey: "box.cargo.type",
|
|
||||||
trailing: IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.add_circle,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
List<CargoType>? cargos = await Navigator.push<List<CargoType>>(
|
|
||||||
context,
|
|
||||||
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
|
||||||
if (cargos == null) return;
|
|
||||||
setState(() {
|
|
||||||
_cargoTypes.addAll(
|
|
||||||
cargos.where((e) => !_cargoTypes.contains(e)).toList());
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
final cargoTableBox = CargoTable(
|
|
||||||
isNew: widget.isNew,
|
|
||||||
cargoTypes: _cargoTypes,
|
|
||||||
onRemove: (c) => _removeCargo(c),
|
|
||||||
onUpdate: (c) => _updateCargo(c),
|
|
||||||
);
|
|
||||||
|
|
||||||
return LocalProgress(
|
|
||||||
inAsyncCall: _isLoading,
|
|
||||||
child: Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
centerTitle: true,
|
|
||||||
leading: new IconButton(
|
|
||||||
icon: new Icon(
|
|
||||||
CupertinoIcons.back,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
onPressed: () => Navigator.of(context).pop()),
|
|
||||||
shadowColor: Colors.transparent,
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
title: LocalText(
|
|
||||||
context,
|
|
||||||
widget.isNew! ? "boxes.create.title" : "box.edit.title",
|
|
||||||
fontSize: 20,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
body: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: ListView(
|
|
||||||
children: [
|
|
||||||
cargoTableTitleBox,
|
|
||||||
cargoTableBox,
|
|
||||||
LocalTitle(textKey: "box.dimension"),
|
|
||||||
cartonSizeDropdown(),
|
|
||||||
dimBox,
|
|
||||||
LocalTitle(textKey: "box.delivery_address"),
|
|
||||||
DefaultDeliveryAddress(
|
|
||||||
deliveryAddress: _deliveryAddress,
|
|
||||||
labelKey: "box.delivery_address",
|
|
||||||
onTap: () async {
|
|
||||||
DeliveryAddress? d = await Navigator.push<DeliveryAddress>(
|
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) => DeliveryAddressSelection(
|
|
||||||
deliveryAddress: _deliveryAddress,
|
|
||||||
user: User(
|
|
||||||
id: _carton!.userID,
|
|
||||||
name: _carton!.userName),
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
if (d == null) return;
|
|
||||||
setState(() {
|
|
||||||
_deliveryAddress = d;
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
createBtn
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget cartonSizeDropdown() {
|
|
||||||
List<CartonSize> _cartonSizes =
|
|
||||||
Provider.of<CartonSizeModel>(context).getCartonSizes;
|
|
||||||
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 10),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 0, right: 10),
|
|
||||||
child: Icon(AntDesign.CodeSandbox, color: primaryColor),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 18.0),
|
|
||||||
child: LocalText(
|
|
||||||
context,
|
|
||||||
"box.carton_size",
|
|
||||||
color: Colors.black54,
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DropdownButton<CartonSize>(
|
|
||||||
isDense: true,
|
|
||||||
value: selectedCatonSize,
|
|
||||||
style: TextStyle(color: Colors.black, fontSize: 14),
|
|
||||||
underline: Container(
|
|
||||||
height: 1,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
onChanged: (CartonSize? newValue) {
|
|
||||||
setState(() {
|
|
||||||
if (newValue!.name == MANAGE_CARTONSIZE) {
|
|
||||||
selectedCatonSize = null;
|
|
||||||
_manageCartonSize();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectedCatonSize = newValue;
|
|
||||||
_widthCtl.text = selectedCatonSize!.width.toString();
|
|
||||||
_heightCtl.text = selectedCatonSize!.height.toString();
|
|
||||||
_lengthCtl.text = selectedCatonSize!.length.toString();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
isExpanded: true,
|
|
||||||
items: _cartonSizes
|
|
||||||
.map<DropdownMenuItem<CartonSize>>((CartonSize value) {
|
|
||||||
return DropdownMenuItem<CartonSize>(
|
|
||||||
value: value,
|
|
||||||
child: Text(value.name ?? "",
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
color: value.name == MANAGE_CARTONSIZE
|
|
||||||
? secondaryColor
|
|
||||||
: primaryColor)),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_manageCartonSize() {
|
|
||||||
Navigator.push<Package>(
|
|
||||||
context,
|
|
||||||
CupertinoPageRoute(builder: (context) => CartonSizeList()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_removeCargo(CargoType cargo) {
|
|
||||||
setState(() {
|
|
||||||
_cargoTypes.remove(cargo);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateCargo(CargoType cargo) {
|
|
||||||
setState(() {
|
|
||||||
var _c = _cargoTypes.firstWhere((e) => e.id == cargo.id);
|
|
||||||
_c.weight = cargo.weight;
|
|
||||||
_c.qty = cargo.qty;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_creatCarton() async {
|
|
||||||
if (_cargoTypes.length == 0) {
|
|
||||||
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
double l = double.parse(_lengthCtl.text);
|
|
||||||
double w = double.parse(_widthCtl.text);
|
|
||||||
double h = double.parse(_heightCtl.text);
|
|
||||||
if ((l <= 0 || w <= 0 || h <= 0)) {
|
|
||||||
showMsgDialog(context, "Error", "Invalid dimension");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_deliveryAddress == null) {
|
|
||||||
showMsgDialog(context, "Error", "Invalid delivery address");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Carton carton = Carton();
|
|
||||||
carton.id = _carton!.id;
|
|
||||||
carton.cartonType = _carton!.cartonType;
|
|
||||||
carton.fcsShipmentID = _carton!.fcsShipmentID;
|
|
||||||
carton.cargoTypes = _cargoTypes;
|
|
||||||
if (isFromPackages) {
|
|
||||||
carton.userID = _carton!.userID;
|
|
||||||
carton.packages = _carton!.packages.where((e) => e.isChecked).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFromCartons) {
|
|
||||||
carton.userID = _carton!.userID;
|
|
||||||
carton.fcsID = _carton!.fcsID;
|
|
||||||
carton.userName = _carton!.userName;
|
|
||||||
carton.senderID = _carton!.senderID;
|
|
||||||
carton.senderFCSID = _carton!.senderFCSID;
|
|
||||||
carton.senderName = _carton!.senderName;
|
|
||||||
}
|
|
||||||
|
|
||||||
carton.length = l;
|
|
||||||
carton.width = w;
|
|
||||||
carton.height = h;
|
|
||||||
carton.deliveryAddress = _deliveryAddress;
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
CartonModel cartonModel =
|
|
||||||
Provider.of<CartonModel>(context, listen: false);
|
|
||||||
if (widget.isNew!) {
|
|
||||||
Carton _c = await cartonModel.createCarton(carton);
|
|
||||||
Navigator.pop(context, _c);
|
|
||||||
} else {
|
|
||||||
await cartonModel.updateCarton(carton);
|
|
||||||
Carton? _c = await cartonModel.getCarton(_carton!.id!);
|
|
||||||
if (_c != null) {
|
|
||||||
Navigator.pop(context, _c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
showMsgDialog(context, "Error", e.toString());
|
|
||||||
} finally {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'carton_info.dart';
|
import '../carton_info.dart';
|
||||||
|
|
||||||
class CartonListRow extends StatelessWidget {
|
class CartonListRow extends StatelessWidget {
|
||||||
final Carton box;
|
final Carton box;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../helpers/theme.dart';
|
import '../../../../helpers/theme.dart';
|
||||||
import '../../domain/entities/user.dart';
|
import '../../../domain/entities/user.dart';
|
||||||
|
|
||||||
typedef OnAction = Future<void> Function();
|
typedef OnAction = Future<void> Function();
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@ import 'package:fcs/domain/entities/carton.dart';
|
|||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/carton/cargo_type_editor.dart';
|
import 'package:fcs/pages/shipment/cargo_type_editor.dart';
|
||||||
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||||
|
|||||||
Reference in New Issue
Block a user