null safety
This commit is contained in:
@@ -1,17 +1,17 @@
|
|||||||
class CargoType {
|
class CargoType {
|
||||||
String id;
|
String? id;
|
||||||
String name;
|
String? name;
|
||||||
double rate;
|
double? rate;
|
||||||
double weight;
|
double? weight;
|
||||||
bool isChecked;
|
bool? isChecked;
|
||||||
int qty;
|
int? qty;
|
||||||
bool isCutomDuty;
|
bool? isCutomDuty;
|
||||||
double customDutyFee;
|
double? customDutyFee;
|
||||||
|
|
||||||
double get calAmount => (calRate ?? 0) * (calWeight ?? 0);
|
double get calAmount => (calRate ?? 0) * (calWeight ?? 0);
|
||||||
|
|
||||||
double calRate;
|
double? calRate;
|
||||||
double calWeight;
|
double? calWeight;
|
||||||
CargoType(
|
CargoType(
|
||||||
{this.id,
|
{this.id,
|
||||||
this.name,
|
this.name,
|
||||||
@@ -52,7 +52,7 @@ class CargoType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CargoType clone() {
|
CargoType clone() {
|
||||||
return CargoType.fromMap(toMap(), this.id);
|
return CargoType.fromMap(toMap(), this.id!);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -63,7 +63,7 @@ class CargoType {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return name;
|
return name!;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isChangedForEdit(CargoType cargoType) {
|
bool isChangedForEdit(CargoType cargoType) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class BuyingOnlinePage extends StatefulWidget {
|
|||||||
|
|
||||||
class _BuyingOnlinePagetate extends State<BuyingOnlinePage>
|
class _BuyingOnlinePagetate extends State<BuyingOnlinePage>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
TabController _tabController;
|
late TabController _tabController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class CargoTable extends StatefulWidget {
|
class CargoTable extends StatefulWidget {
|
||||||
final List<CargoType> cargoTypes;
|
final List<CargoType>? cargoTypes;
|
||||||
|
|
||||||
const CargoTable({
|
const CargoTable({
|
||||||
Key key,
|
Key? key,
|
||||||
this.cargoTypes,
|
this.cargoTypes,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@@ -58,13 +58,13 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
double total = 0;
|
double total = 0;
|
||||||
var rows = widget.cargoTypes.map((c) {
|
var rows = widget.cargoTypes!.map((c) {
|
||||||
total += c.weight;
|
total += c.weight!;
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (bool selected) async {},
|
onSelectChanged: (bool selected) async {},
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(new Text(
|
MyDataCell(new Text(
|
||||||
c.name == null ? "" : c.name,
|
c.name ?? "",
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
)),
|
||||||
MyDataCell(c.qty == null || c.qty == 0
|
MyDataCell(c.qty == null || c.qty == 0
|
||||||
@@ -81,7 +81,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
MyDataCell(
|
MyDataCell(
|
||||||
Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2),
|
Text(c.weight == null ? "0" : c.weight!.toStringAsFixed(2),
|
||||||
style: textStyle),
|
style: textStyle),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
p.isChecked = false;
|
p.isChecked = false;
|
||||||
p.isCutomDuty = false;
|
p.isCutomDuty = false;
|
||||||
p.weight = 0;
|
p.weight = 0;
|
||||||
p.qty = null;
|
p.qty = 0;
|
||||||
});
|
});
|
||||||
specialCargos.forEach((p) {
|
specialCargos.forEach((p) {
|
||||||
p.isChecked = false;
|
p.isChecked = false;
|
||||||
@@ -61,7 +61,7 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
c.isChecked = !c.isChecked;
|
c.isChecked = !c.isChecked!;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -69,12 +69,12 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
Checkbox(
|
Checkbox(
|
||||||
value: c.isChecked,
|
value: c.isChecked,
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
onChanged: (bool check) {
|
onChanged: (bool? check) {
|
||||||
setState(() {
|
setState(() {
|
||||||
c.isChecked = check;
|
c.isChecked = check;
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
new Text(c.name, style: textStyle),
|
new Text(c.name ?? '', style: textStyle),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -88,9 +88,9 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
getLocalString(context, 'box.cargo.select.btn'),
|
getLocalString(context, 'box.cargo.select.btn'),
|
||||||
callack: () {
|
callack: () {
|
||||||
List<CargoType> _cargos =
|
List<CargoType> _cargos =
|
||||||
this.cargos.where((c) => c.isChecked).toList();
|
this.cargos.where((c) => c.isChecked!).toList();
|
||||||
List<CargoType> _scargos =
|
List<CargoType> _scargos =
|
||||||
this.specialCargos.where((c) => c.isChecked).toList();
|
this.specialCargos.where((c) => c.isChecked!).toList();
|
||||||
_cargos.addAll(_scargos);
|
_cargos.addAll(_scargos);
|
||||||
Navigator.pop(context, _cargos);
|
Navigator.pop(context, _cargos);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class CargoTypeEditor extends StatefulWidget {
|
class CargoTypeEditor extends StatefulWidget {
|
||||||
final CargoType cargo;
|
final CargoType? cargo;
|
||||||
CargoTypeEditor({this.cargo});
|
CargoTypeEditor({this.cargo});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -23,14 +23,14 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
|||||||
TextEditingController _weightController = new TextEditingController();
|
TextEditingController _weightController = new TextEditingController();
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
CargoType _cargo;
|
CargoType? _cargo;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (widget.cargo != null) {
|
if (widget.cargo != null) {
|
||||||
_cargo = widget.cargo;
|
_cargo = widget.cargo;
|
||||||
_weightController.text = _cargo.weight.toStringAsFixed(2);
|
_weightController.text = _cargo!.weight!.toStringAsFixed(2);
|
||||||
} else {
|
} else {
|
||||||
_loadDefalut();
|
_loadDefalut();
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
|||||||
},
|
},
|
||||||
labelKey: "cargo.type",
|
labelKey: "cargo.type",
|
||||||
iconData: Icons.text_format,
|
iconData: Icons.text_format,
|
||||||
selectedValue: _cargo,
|
selectedValue: _cargo!,
|
||||||
values: cargos,
|
values: cargos,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
|||||||
context,
|
context,
|
||||||
getLocalString(context, 'box.cargo.save.btn'),
|
getLocalString(context, 'box.cargo.save.btn'),
|
||||||
callack: () {
|
callack: () {
|
||||||
_cargo.weight = double.tryParse(_weightController.text) ?? 0;
|
_cargo!.weight = double.tryParse(_weightController.text) ?? 0;
|
||||||
Navigator.pop(context, _cargo);
|
Navigator.pop(context, _cargo);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ typedef OnRemove(CargoType cargoType);
|
|||||||
typedef OnUpdate(CargoType cargoType);
|
typedef OnUpdate(CargoType cargoType);
|
||||||
|
|
||||||
class CargoTable extends StatefulWidget {
|
class CargoTable extends StatefulWidget {
|
||||||
final List<CargoType> cargoTypes;
|
final List<CargoType>? cargoTypes;
|
||||||
final bool isNew;
|
final bool? isNew;
|
||||||
final OnRemove onRemove;
|
final OnRemove? onRemove;
|
||||||
final OnUpdate onUpdate;
|
final OnUpdate? onUpdate;
|
||||||
|
|
||||||
const CargoTable(
|
const CargoTable(
|
||||||
{Key key, this.cargoTypes, this.isNew, this.onRemove, this.onUpdate})
|
{Key? key, this.cargoTypes, this.isNew, this.onRemove, this.onUpdate})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -26,14 +26,14 @@ class CargoTable extends StatefulWidget {
|
|||||||
|
|
||||||
class _CargoTableState extends State<CargoTable> {
|
class _CargoTableState extends State<CargoTable> {
|
||||||
double totalWeight = 0;
|
double totalWeight = 0;
|
||||||
List<CargoType> cargoTypes;
|
List<CargoType>? cargoTypes;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
cargoTypes = widget.cargoTypes;
|
cargoTypes = widget.cargoTypes;
|
||||||
if (!widget.isNew) {
|
if (!widget.isNew!) {
|
||||||
totalWeight =
|
totalWeight =
|
||||||
cargoTypes.fold(0, (previous, current) => previous + current.weight);
|
cargoTypes!.fold(0, (previous, current) => previous + current.weight!);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -41,7 +41,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
print("Cargotypes:${cargoTypes.length}");
|
print("Cargotypes:${cargoTypes!.length}");
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
@@ -80,18 +80,18 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
if (cargoTypes == null) {
|
if (cargoTypes == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
var rows = cargoTypes.map((c) {
|
var rows = cargoTypes!.map((c) {
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (bool selected) async {},
|
onSelectChanged: (bool selected) async {},
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(
|
MyDataCell(
|
||||||
new Text(
|
new Text(
|
||||||
c.name == null ? "" : c.name,
|
c.name ??'',
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
MyDataCell(
|
MyDataCell(
|
||||||
c.isCutomDuty
|
c.isCutomDuty!
|
||||||
? GestureDetector(
|
? GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
String _t = await showDialog(
|
String _t = await showDialog(
|
||||||
@@ -103,7 +103,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
c.qty = int.tryParse(_t) ?? 0;
|
c.qty = int.tryParse(_t) ?? 0;
|
||||||
});
|
});
|
||||||
if (widget.onUpdate != null) widget.onUpdate(c);
|
if (widget.onUpdate != null) widget.onUpdate!(c);
|
||||||
},
|
},
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
@@ -144,7 +144,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (_) => DialogInput(
|
builder: (_) => DialogInput(
|
||||||
label: "cargo.weight",
|
label: "cargo.weight",
|
||||||
value: c.weight.toStringAsFixed(2)));
|
value: c.weight!.toStringAsFixed(2)));
|
||||||
|
|
||||||
if (_t == null) return;
|
if (_t == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -153,7 +153,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
if (c.weight != 0) {
|
if (c.weight != 0) {
|
||||||
_cal();
|
_cal();
|
||||||
}
|
}
|
||||||
if (widget.onUpdate != null) widget.onUpdate(c);
|
if (widget.onUpdate != null) widget.onUpdate!(c);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(7.0),
|
padding: const EdgeInsets.all(7.0),
|
||||||
@@ -162,7 +162,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
c.weight == null ? "0.00" : c.weight.toStringAsFixed(2),
|
c.weight == null ? "0.00" : c.weight!.toStringAsFixed(2),
|
||||||
style: textStyle),
|
style: textStyle),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -176,7 +176,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (widget.onRemove != null) widget.onRemove(c);
|
if (widget.onRemove != null) widget.onRemove!(c);
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -237,21 +237,21 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_cal() {
|
_cal() {
|
||||||
var cargoType = autoCalWeight(cargoTypes, totalWeight);
|
var cargoType = autoCalWeight(cargoTypes!, totalWeight);
|
||||||
if (cargoType == null) return;
|
if (cargoType == null) return;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
cargoTypes.remove(cargoType);
|
cargoTypes!.remove(cargoType);
|
||||||
cargoTypes.add(cargoType);
|
cargoTypes!.add(cargoType);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (widget.onUpdate != null) {
|
if (widget.onUpdate != null) {
|
||||||
widget.onUpdate(cargoType);
|
widget.onUpdate!(cargoType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CargoType autoCalWeight(List<CargoType> cargoTypes, double total) {
|
CargoType? autoCalWeight(List<CargoType> cargoTypes, double total) {
|
||||||
if ((cargoTypes?.length ?? 0) == 0 || total == 0) return null;
|
if ((cargoTypes?.length ?? 0) == 0 || total == 0) return null;
|
||||||
List<CargoType> noWeight = cargoTypes.where((c) => c.weight == 0).toList();
|
List<CargoType> noWeight = cargoTypes.where((c) => c.weight == 0).toList();
|
||||||
if (noWeight.length != 1) return null;
|
if (noWeight.length != 1) return null;
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ typedef OnAdd(CargoType cargoType);
|
|||||||
typedef OnRemove(CargoType cargoType);
|
typedef OnRemove(CargoType cargoType);
|
||||||
|
|
||||||
class CargoTable extends StatefulWidget {
|
class CargoTable extends StatefulWidget {
|
||||||
final List<CargoType> cargoTypes;
|
final List<CargoType>? cargoTypes;
|
||||||
final OnAdd onAdd;
|
final OnAdd? onAdd;
|
||||||
final OnRemove onRemove;
|
final OnRemove? onRemove;
|
||||||
|
|
||||||
const CargoTable({Key key, this.cargoTypes, this.onAdd, this.onRemove})
|
const CargoTable({Key? key, this.cargoTypes, this.onAdd, this.onRemove})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -67,15 +67,15 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
List<String> _types = [];
|
List<String> _types = [];
|
||||||
double _total = 0;
|
double _total = 0;
|
||||||
|
|
||||||
var rows = widget.cargoTypes.map((c) {
|
var rows = widget.cargoTypes!.map((c) {
|
||||||
_total += c.weight;
|
_total += c.weight!;
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (bool selected) async {},
|
onSelectChanged: (bool selected) async {},
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(Row(
|
MyDataCell(Row(
|
||||||
children: [
|
children: [
|
||||||
new Text(
|
new Text(
|
||||||
c.name == null ? "" : c.name,
|
c.name ?? "",
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
new Text(
|
new Text(
|
||||||
@@ -88,7 +88,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Text(c.weight.toStringAsFixed(2), style: textStyle),
|
Text(c.weight!.toStringAsFixed(2), style: textStyle),
|
||||||
widget.onRemove == null
|
widget.onRemove == null
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width: 50,
|
width: 50,
|
||||||
@@ -99,7 +99,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (widget.onRemove != null) widget.onRemove(c);
|
if (widget.onRemove != null) widget.onRemove!(c);
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -127,7 +127,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
double _t = await Navigator.of(context).push<double>(
|
double? _t = await Navigator.of(context).push<double>(
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
TotalWeightEdit(totalWeight: totalWeight)));
|
TotalWeightEdit(totalWeight: totalWeight)));
|
||||||
@@ -135,21 +135,21 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
totalWeight = _t;
|
totalWeight = _t;
|
||||||
this.remainingWeight = this.totalWeight - _total;
|
this.remainingWeight = this.totalWeight - _total;
|
||||||
widget.cargoTypes.forEach((c) {
|
widget.cargoTypes!.forEach((c) {
|
||||||
if (c.qty == null) {
|
if (c.qty == null) {
|
||||||
this._cargos.add(c);
|
this._cargos.add(c);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this._cargos.forEach((c) {
|
this._cargos.forEach((c) {
|
||||||
_list.add(c.name);
|
_list.add(c.name!);
|
||||||
});
|
});
|
||||||
widget.cargoTypes.forEach((c) {
|
widget.cargoTypes!.forEach((c) {
|
||||||
_types.add(c.name);
|
_types.add(c.name!);
|
||||||
});
|
});
|
||||||
if (this._cargos.length == widget.cargoTypes.length - 1) {
|
if (this._cargos.length == widget.cargoTypes!.length - 1) {
|
||||||
_types.forEach((t) {
|
_types.forEach((t) {
|
||||||
if (!_list.contains(t)) {
|
if (!_list.contains(t)) {
|
||||||
widget.cargoTypes.forEach((c) {
|
widget.cargoTypes!.forEach((c) {
|
||||||
if (c.name == t) {
|
if (c.name == t) {
|
||||||
c.weight = this.remainingWeight;
|
c.weight = this.remainingWeight;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import 'package:fcs/pages/widgets/local_title.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'cargo_type_addtion.dart';
|
import 'cargo_type_addtion.dart';
|
||||||
import 'carton_cargo_table.dart';
|
import 'carton_cargo_table.dart';
|
||||||
@@ -40,7 +40,7 @@ import 'package_carton_editor.dart';
|
|||||||
import 'widgets.dart';
|
import 'widgets.dart';
|
||||||
|
|
||||||
class CartonEditor extends StatefulWidget {
|
class CartonEditor extends StatefulWidget {
|
||||||
final Carton box;
|
final Carton? box;
|
||||||
CartonEditor({this.box});
|
CartonEditor({this.box});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -54,29 +54,29 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||||
List<CargoType> _cargoTypes = [];
|
List<CargoType> _cargoTypes = [];
|
||||||
|
|
||||||
Carton _carton;
|
Carton? _carton;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool _isNew;
|
bool _isNew = false;
|
||||||
User _user;
|
User? _user;
|
||||||
String _selectedCartonType;
|
String? _selectedCartonType;
|
||||||
|
|
||||||
double volumetricRatio = 0;
|
double volumetricRatio = 0;
|
||||||
double shipmentWeight = 0;
|
double shipmentWeight = 0;
|
||||||
FcsShipment _fcsShipment;
|
FcsShipment? _fcsShipment;
|
||||||
List<FcsShipment> _fcsShipments;
|
List<FcsShipment>? _fcsShipments;
|
||||||
List<Carton> _cartons = [];
|
List<Carton> _cartons = [];
|
||||||
CartonSize selectedCatonSize;
|
CartonSize? selectedCatonSize;
|
||||||
|
|
||||||
//for mix carton
|
//for mix carton
|
||||||
List<Carton> _mixCartons = [];
|
List<Carton> _mixCartons = [];
|
||||||
String _selectedMixBoxType;
|
String? _selectedMixBoxType;
|
||||||
|
|
||||||
//for carton from cargos
|
//for carton from cargos
|
||||||
User consignee;
|
User? consignee;
|
||||||
User sender;
|
User? sender;
|
||||||
List<Carton> _cartonsFromCartons = [];
|
List<Carton> _cartonsFromCartons = [];
|
||||||
|
|
||||||
double totalWeight;
|
double? totalWeight;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -92,28 +92,28 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
|
|
||||||
if (widget.box != null) {
|
if (widget.box != null) {
|
||||||
_carton = widget.box;
|
_carton = widget.box;
|
||||||
_deliveryAddress = _carton.deliveryAddress;
|
_deliveryAddress = _carton!.deliveryAddress;
|
||||||
_widthController.text = _carton.width.toString();
|
_widthController.text = _carton!.width.toString();
|
||||||
_heightController.text = _carton.height.toString();
|
_heightController.text = _carton!.height.toString();
|
||||||
_lengthController.text = _carton.length.toString();
|
_lengthController.text = _carton!.length.toString();
|
||||||
_selectedCartonType = _carton.cartonType;
|
_selectedCartonType = _carton!.cartonType;
|
||||||
|
|
||||||
_cargoTypes = _carton.cargoTypes.map((e) => e.clone()).toList();
|
_cargoTypes = _carton!.cargoTypes.map((e) => e.clone()).toList();
|
||||||
|
|
||||||
_isNew = false;
|
_isNew = false;
|
||||||
_user = User(
|
_user = User(
|
||||||
id: _carton.userID, fcsID: _carton.fcsID, name: _carton.userName);
|
id: _carton!.userID, fcsID: _carton!.fcsID, name: _carton!.userName);
|
||||||
consignee = User(
|
consignee = User(
|
||||||
id: _carton.userID, fcsID: _carton.fcsID, name: _carton.userName);
|
id: _carton!.userID, fcsID: _carton!.fcsID, name: _carton!.userName);
|
||||||
sender = User(
|
sender = User(
|
||||||
id: _carton.senderID,
|
id: _carton!.senderID,
|
||||||
fcsID: _carton.senderFCSID,
|
fcsID: _carton!.senderFCSID,
|
||||||
name: _carton.senderName);
|
name: _carton!.senderName);
|
||||||
_selectedMixBoxType = _carton.mixBoxType ?? "";
|
_selectedMixBoxType = _carton!.mixBoxType;
|
||||||
this._mixCartons =
|
this._mixCartons =
|
||||||
_carton.mixCartons == null ? [] : List.from(_carton.mixCartons);
|
_carton!.mixCartons == null ? [] : List.from(_carton!.mixCartons);
|
||||||
bool isMixBox = _carton.cartonType == carton_mix_box;
|
bool isMixBox = _carton!.cartonType == carton_mix_box;
|
||||||
bool isFromPackages = _carton.cartonType == carton_from_packages;
|
bool isFromPackages = _carton!.cartonType == carton_from_packages;
|
||||||
if (isFromPackages) _loadPackages();
|
if (isFromPackages) _loadPackages();
|
||||||
|
|
||||||
if (!isMixBox) {
|
if (!isMixBox) {
|
||||||
@@ -138,8 +138,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
FcsShipmentModel fcsShipmentModel =
|
FcsShipmentModel fcsShipmentModel =
|
||||||
Provider.of<FcsShipmentModel>(context, listen: false);
|
Provider.of<FcsShipmentModel>(context, listen: false);
|
||||||
var fcsShipments = await fcsShipmentModel.getActiveFcsShipments();
|
var fcsShipments = await fcsShipmentModel.getActiveFcsShipments();
|
||||||
var fcsShipment = fcsShipments
|
var fcsShipment =
|
||||||
.firstWhere((e) => e.id == _carton.fcsShipmentID, orElse: () => null);
|
fcsShipments.firstWhere((e) => e.id == _carton!.fcsShipmentID);
|
||||||
setState(() {
|
setState(() {
|
||||||
_fcsShipments = fcsShipments;
|
_fcsShipments = fcsShipments;
|
||||||
_fcsShipment = fcsShipment;
|
_fcsShipment = fcsShipment;
|
||||||
@@ -151,12 +151,12 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
List<Package> packages = await packageModel.getPackages(
|
List<Package> packages = await packageModel.getPackages(
|
||||||
_user.id, [package_processed_status, package_packed_status]);
|
_user!.id, [package_processed_status, package_packed_status]);
|
||||||
if (_isNew) {
|
if (_isNew) {
|
||||||
String prevCompare;
|
String? prevCompare;
|
||||||
packages.forEach((p) {
|
packages.forEach((p) {
|
||||||
String compare = (p.deliveryAddress?.fullName ?? "") +
|
String compare =
|
||||||
(p.deliveryAddress?.phoneNumber ?? "");
|
(p.deliveryAddress.fullName) + (p.deliveryAddress.phoneNumber);
|
||||||
if (prevCompare != null && compare == prevCompare) {
|
if (prevCompare != null && compare == prevCompare) {
|
||||||
p.isChecked = true;
|
p.isChecked = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -169,8 +169,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
packages.forEach((p) {
|
packages.forEach((p) {
|
||||||
if (_carton.packages.contains(p)) {
|
if (_carton!.packages.contains(p)) {
|
||||||
p.isChecked = _carton.packages.firstWhere((cp) => cp == p).isChecked;
|
p.isChecked = _carton!.packages.firstWhere((cp) => cp == p).isChecked;
|
||||||
} else {
|
} else {
|
||||||
p.isChecked = false;
|
p.isChecked = false;
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_carton.packages = packages;
|
_carton!.packages = packages;
|
||||||
});
|
});
|
||||||
// _populateDeliveryAddress();
|
// _populateDeliveryAddress();
|
||||||
}
|
}
|
||||||
@@ -206,9 +206,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
_getCartonSize() {
|
_getCartonSize() {
|
||||||
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
||||||
cartonSizeModel.cartonSizes.forEach((c) {
|
cartonSizeModel.cartonSizes.forEach((c) {
|
||||||
if (c.length == _carton.length &&
|
if (c.length == _carton!.length &&
|
||||||
c.width == _carton.width &&
|
c.width == _carton!.width &&
|
||||||
c.height == _carton.height) {
|
c.height == _carton!.height) {
|
||||||
selectedCatonSize = CartonSize(
|
selectedCatonSize = CartonSize(
|
||||||
id: c.id,
|
id: c.id,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
@@ -232,7 +232,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
bool isMixBox = _selectedCartonType == carton_mix_box;
|
bool isMixBox = _selectedCartonType == carton_mix_box;
|
||||||
|
|
||||||
final shipmentBox = DisplayText(
|
final shipmentBox = DisplayText(
|
||||||
text: _carton.fcsShipmentNumber,
|
text: _carton!.fcsShipmentNumber,
|
||||||
labelTextKey: "box.fcs_shipment_num",
|
labelTextKey: "box.fcs_shipment_num",
|
||||||
iconData: Ionicons.ios_airplane,
|
iconData: Ionicons.ios_airplane,
|
||||||
);
|
);
|
||||||
@@ -248,8 +248,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
labelKey: "shipment.pack.fcs.shipment",
|
labelKey: "shipment.pack.fcs.shipment",
|
||||||
iconData: Ionicons.ios_airplane,
|
iconData: Ionicons.ios_airplane,
|
||||||
display: (u) => u.shipmentNumber,
|
display: (u) => u.shipmentNumber,
|
||||||
selectedValue: _fcsShipment,
|
selectedValue: _fcsShipment!,
|
||||||
values: _fcsShipments,
|
values: _fcsShipments!,
|
||||||
));
|
));
|
||||||
|
|
||||||
final fcsIDBox = Container(
|
final fcsIDBox = Container(
|
||||||
@@ -297,7 +297,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
readOnly: !_isNew,
|
readOnly: !_isNew,
|
||||||
values: boxModel.cartonTypes,
|
values: boxModel.cartonTypes,
|
||||||
selectedValue: _selectedCartonType,
|
selectedValue: _selectedCartonType,
|
||||||
callback: (v) {
|
callback: (String? v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedCartonType = v;
|
_selectedCartonType = v;
|
||||||
});
|
});
|
||||||
@@ -337,7 +337,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
value: e,
|
value: e,
|
||||||
groupValue: _selectedMixBoxType,
|
groupValue: _selectedMixBoxType,
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
onChanged: (v) {
|
onChanged: (String? v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedMixBoxType = v;
|
_selectedMixBoxType = v;
|
||||||
});
|
});
|
||||||
@@ -407,7 +407,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
List<CargoType> cargos = await Navigator.push<List<CargoType>>(
|
List<CargoType>? cargos = await Navigator.push<List<CargoType>>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
||||||
if (cargos == null) return;
|
if (cargos == null) return;
|
||||||
@@ -462,7 +462,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: consignee != null ? consignee.fcsID : "",
|
text: consignee != null ? consignee!.fcsID : "",
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
)),
|
)),
|
||||||
@@ -477,7 +477,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final consigneeNameBox = DisplayText(
|
final consigneeNameBox = DisplayText(
|
||||||
text: consignee != null ? consignee.name : "",
|
text: consignee != null ? consignee!.name : "",
|
||||||
labelTextKey: "processing.consignee.name",
|
labelTextKey: "processing.consignee.name",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
@@ -496,7 +496,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: sender != null ? sender.fcsID : "",
|
text: sender != null ? sender!.fcsID : "",
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
)),
|
)),
|
||||||
@@ -511,7 +511,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final shipperNamebox = DisplayText(
|
final shipperNamebox = DisplayText(
|
||||||
text: sender != null ? sender.name : "",
|
text: sender != null ? sender!.name : "",
|
||||||
labelTextKey: "processing.shipper.name",
|
labelTextKey: "processing.shipper.name",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
@@ -551,7 +551,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
children: [
|
children: [
|
||||||
_isNew
|
_isNew
|
||||||
? Container()
|
? Container()
|
||||||
: Center(child: getCartonNumberStatus(context, _carton)),
|
: Center(child: getCartonNumberStatus(context, _carton!)),
|
||||||
LocalTitle(textKey: "box.type.title"),
|
LocalTitle(textKey: "box.type.title"),
|
||||||
cartonTypeBox,
|
cartonTypeBox,
|
||||||
LocalTitle(textKey: "box.shipment_info"),
|
LocalTitle(textKey: "box.shipment_info"),
|
||||||
@@ -572,7 +572,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
isFromPackages ? namebox : Container(),
|
isFromPackages ? namebox : Container(),
|
||||||
isFromPackages
|
isFromPackages
|
||||||
? CartonPackageTable(
|
? CartonPackageTable(
|
||||||
packages: _carton.packages,
|
packages: _carton!.packages,
|
||||||
onSelect: (p, checked) {
|
onSelect: (p, checked) {
|
||||||
// if (checked &&
|
// if (checked &&
|
||||||
// _deliveryAddress != null &&
|
// _deliveryAddress != null &&
|
||||||
@@ -623,7 +623,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
deliveryAddress: _deliveryAddress,
|
deliveryAddress: _deliveryAddress,
|
||||||
labelKey: "box.delivery_address",
|
labelKey: "box.delivery_address",
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
DeliveryAddress d =
|
DeliveryAddress? d =
|
||||||
await Navigator.push<DeliveryAddress>(
|
await Navigator.push<DeliveryAddress>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
@@ -631,8 +631,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
DeliveryAddressSelection(
|
DeliveryAddressSelection(
|
||||||
deliveryAddress: _deliveryAddress,
|
deliveryAddress: _deliveryAddress,
|
||||||
user: User(
|
user: User(
|
||||||
id: _carton.userID,
|
id: _carton!.userID,
|
||||||
name: _carton.userName))),
|
name: _carton!.userName))),
|
||||||
);
|
);
|
||||||
if (d == null) return;
|
if (d == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -667,7 +667,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
||||||
if (isFromPackages) {
|
if (isFromPackages) {
|
||||||
_loadPackages();
|
_loadPackages();
|
||||||
c.value.packages = _carton.packages;
|
c.value.packages = _carton!.packages;
|
||||||
Carton _c = await Navigator.push(
|
Carton _c = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
@@ -736,20 +736,20 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
height: 1,
|
height: 1,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
onChanged: (CartonSize newValue) {
|
onChanged: (CartonSize? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (newValue.name == MANAGE_CARTONSIZE) {
|
if (newValue!.name == MANAGE_CARTONSIZE) {
|
||||||
selectedCatonSize = null;
|
selectedCatonSize = null;
|
||||||
_manageCartonSize();
|
_manageCartonSize();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
selectedCatonSize = newValue;
|
selectedCatonSize = newValue;
|
||||||
_widthController.text =
|
_widthController.text =
|
||||||
selectedCatonSize.width.toString();
|
selectedCatonSize!.width.toString();
|
||||||
_heightController.text =
|
_heightController.text =
|
||||||
selectedCatonSize.height.toString();
|
selectedCatonSize!.height.toString();
|
||||||
_lengthController.text =
|
_lengthController.text =
|
||||||
selectedCatonSize.length.toString();
|
selectedCatonSize!.length.toString();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
@@ -757,7 +757,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
.map<DropdownMenuItem<CartonSize>>((CartonSize value) {
|
.map<DropdownMenuItem<CartonSize>>((CartonSize value) {
|
||||||
return DropdownMenuItem<CartonSize>(
|
return DropdownMenuItem<CartonSize>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(value.name ?? "",
|
child: Text(value.name,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: value.name == MANAGE_CARTONSIZE
|
color: value.name == MANAGE_CARTONSIZE
|
||||||
@@ -789,8 +789,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
|
|
||||||
_updateCargo(CargoType cargo) {
|
_updateCargo(CargoType cargo) {
|
||||||
setState(() {
|
setState(() {
|
||||||
var _c =
|
var _c = _cargoTypes.firstWhere((e) => e.id == cargo.id);
|
||||||
_cargoTypes.firstWhere((e) => e.id == cargo.id, orElse: () => null);
|
|
||||||
if (_c != null) {
|
if (_c != null) {
|
||||||
_c.weight = cargo.weight;
|
_c.weight = cargo.weight;
|
||||||
_c.qty = cargo.qty;
|
_c.qty = cargo.qty;
|
||||||
@@ -827,30 +826,30 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
double h = double.parse(_heightController.text, (s) => 0);
|
double h = double.parse(_heightController.text, (s) => 0);
|
||||||
|
|
||||||
Carton carton = Carton();
|
Carton carton = Carton();
|
||||||
carton.id = _carton.id;
|
carton.id = _carton!.id;
|
||||||
carton.cartonType = _selectedCartonType;
|
carton.cartonType = _selectedCartonType!;
|
||||||
carton.fcsShipmentID = _isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
carton.fcsShipmentID = _isNew ? _fcsShipment!.id : _carton!.fcsShipmentID;
|
||||||
if (isFromPackages) {
|
if (isFromPackages) {
|
||||||
carton.userID = _user?.id;
|
carton.userID = _user?.id ?? '';
|
||||||
carton.fcsID = _user?.fcsID;
|
carton.fcsID = _user?.fcsID ?? '';
|
||||||
carton.userName = _user?.name;
|
carton.userName = _user?.name ?? '';
|
||||||
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
carton.packages = _carton!.packages.where((e) => e.isChecked).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFromCartons) {
|
if (isFromCartons) {
|
||||||
carton.userID = consignee?.id;
|
carton.userID = consignee?.id ?? "";
|
||||||
carton.fcsID = consignee?.fcsID;
|
carton.fcsID = consignee?.fcsID ?? "";
|
||||||
carton.userName = consignee?.name;
|
carton.userName = consignee?.name ?? "";
|
||||||
carton.senderID = sender?.id;
|
carton.senderID = sender?.id ?? "";
|
||||||
carton.senderFCSID = sender?.fcsID;
|
carton.senderFCSID = sender?.fcsID ?? "";
|
||||||
carton.senderName = sender?.name;
|
carton.senderName = sender?.name ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
carton.cargoTypes = _carton.cargoTypes;
|
carton.cargoTypes = _carton!.cargoTypes;
|
||||||
carton.length = l;
|
carton.length = l;
|
||||||
carton.width = w;
|
carton.width = w;
|
||||||
carton.height = h;
|
carton.height = h;
|
||||||
carton.deliveryAddress = _carton.deliveryAddress;
|
carton.deliveryAddress = _carton!.deliveryAddress;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Carton _c = await Navigator.push(
|
Carton _c = await Navigator.push(
|
||||||
@@ -898,15 +897,15 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
showMsgDialog(context, "Error", "Please select FCS shipment");
|
showMsgDialog(context, "Error", "Please select FCS shipment");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((this._mixCartons?.length ?? 0) == 0) {
|
if (this._mixCartons.length == 0) {
|
||||||
showMsgDialog(context, "Error", "Expect at least one carton");
|
showMsgDialog(context, "Error", "Expect at least one carton");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Carton carton = Carton();
|
Carton carton = Carton();
|
||||||
carton.id = _carton.id;
|
carton.id = _carton!.id;
|
||||||
carton.cartonType = _selectedCartonType;
|
carton.cartonType = _selectedCartonType!;
|
||||||
carton.fcsShipmentID = _isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
carton.fcsShipmentID = _isNew ? _fcsShipment!.id : _carton!.fcsShipmentID;
|
||||||
carton.mixBoxType = _selectedMixBoxType;
|
carton.mixBoxType = _selectedMixBoxType!;
|
||||||
carton.mixCartons = this._mixCartons;
|
carton.mixCartons = this._mixCartons;
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
@@ -932,11 +931,11 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
_save() async {
|
_save() async {
|
||||||
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||||
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
||||||
if ((_cargoTypes?.length ?? 0) == 0 && (isFromPackages || isFromCartons)) {
|
if (_cargoTypes.length == 0 && (isFromPackages || isFromCartons)) {
|
||||||
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_cargoTypes.where((c) => c.weight <= 0).isNotEmpty) {
|
if (_cargoTypes.where((c) => c.weight! <= 0).isNotEmpty) {
|
||||||
showMsgDialog(context, "Error", "Invalid cargo weight");
|
showMsgDialog(context, "Error", "Invalid cargo weight");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -953,16 +952,16 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Carton carton = Carton();
|
Carton carton = Carton();
|
||||||
carton.id = _carton.id;
|
carton.id = _carton!.id;
|
||||||
carton.cartonType = _selectedCartonType;
|
carton.cartonType = _selectedCartonType!;
|
||||||
carton.fcsShipmentID = _isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
carton.fcsShipmentID = _isNew ? _fcsShipment!.id : _carton!.fcsShipmentID;
|
||||||
if (isFromPackages) {
|
if (isFromPackages) {
|
||||||
carton.userID = _user?.id;
|
carton.userID = _user?.id ?? "";
|
||||||
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
carton.packages = _carton!.packages.where((e) => e.isChecked).toList();
|
||||||
}
|
}
|
||||||
if (isFromCartons) {
|
if (isFromCartons) {
|
||||||
carton.userID = consignee?.id;
|
carton.userID = consignee?.id ?? "";
|
||||||
carton.senderID = sender?.id;
|
carton.senderID = sender?.id ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
carton.cargoTypes = _cargoTypes;
|
carton.cargoTypes = _cargoTypes;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import 'package:fcs/pages/widgets/local_title.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
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';
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ import 'widgets.dart';
|
|||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
|
|
||||||
class CartonInfo extends StatefulWidget {
|
class CartonInfo extends StatefulWidget {
|
||||||
final Carton box;
|
final Carton? box;
|
||||||
CartonInfo({this.box});
|
CartonInfo({this.box});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -42,7 +42,7 @@ class CartonInfo extends StatefulWidget {
|
|||||||
|
|
||||||
class _CartonInfoState extends State<CartonInfo> {
|
class _CartonInfoState extends State<CartonInfo> {
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
Carton _box;
|
Carton? _box;
|
||||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||||
TextEditingController _widthController = new TextEditingController();
|
TextEditingController _widthController = new TextEditingController();
|
||||||
TextEditingController _heightController = new TextEditingController();
|
TextEditingController _heightController = new TextEditingController();
|
||||||
@@ -50,14 +50,14 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
TextEditingController _cartonSizeController = new TextEditingController();
|
TextEditingController _cartonSizeController = new TextEditingController();
|
||||||
double volumetricRatio = 0;
|
double volumetricRatio = 0;
|
||||||
double shipmentWeight = 0;
|
double shipmentWeight = 0;
|
||||||
String selectMixBoxType;
|
String? selectMixBoxType;
|
||||||
|
|
||||||
bool isMixBox;
|
bool isMixBox = false;
|
||||||
bool isFromShipments;
|
bool isFromShipments = false;
|
||||||
bool isFromPackages;
|
bool isFromPackages = false;
|
||||||
bool isSmallBag;
|
bool isSmallBag = false;
|
||||||
bool isFromCartons;
|
bool isFromCartons = false;
|
||||||
bool isEdiable;
|
bool isEdiable = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -77,29 +77,29 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_updateBoxData() {
|
_updateBoxData() {
|
||||||
_widthController.text = _box.width.toString();
|
_widthController.text = _box!.width.toString();
|
||||||
_heightController.text = _box.height.toString();
|
_heightController.text = _box!.height.toString();
|
||||||
_lengthController.text = _box.length.toString();
|
_lengthController.text = _box!.length.toString();
|
||||||
_cartonSizeController.text = _box.cartonSizeName ?? "";
|
_cartonSizeController.text = _box!.cartonSizeName;
|
||||||
_deliveryAddress = _box.deliveryAddress;
|
_deliveryAddress = _box!.deliveryAddress;
|
||||||
isMixBox = _box.cartonType == carton_mix_box;
|
isMixBox = _box!.cartonType == carton_mix_box;
|
||||||
isFromShipments = _box.cartonType == carton_from_shipments;
|
isFromShipments = _box!.cartonType == carton_from_shipments;
|
||||||
isFromPackages = _box.cartonType == carton_from_packages;
|
isFromPackages = _box!.cartonType == carton_from_packages;
|
||||||
isSmallBag = _box.cartonType == carton_small_bag;
|
isSmallBag = _box!.cartonType == carton_small_bag;
|
||||||
isFromCartons = _box.cartonType == carton_from_cartons;
|
isFromCartons = _box!.cartonType == carton_from_cartons;
|
||||||
|
|
||||||
isEdiable = (isFromPackages || isMixBox || isFromCartons) &&
|
isEdiable = (isFromPackages || isMixBox || isFromCartons) &&
|
||||||
_box.status == carton_packed_status;
|
_box!.status == carton_packed_status;
|
||||||
selectMixBoxType = _box.mixBoxType ?? "";
|
selectMixBoxType = _box!.mixBoxType;
|
||||||
getCartonSize();
|
getCartonSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
getCartonSize() {
|
getCartonSize() {
|
||||||
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
||||||
cartonSizeModel.cartonSizes.forEach((c) {
|
cartonSizeModel.cartonSizes.forEach((c) {
|
||||||
if (c.length == _box.length &&
|
if (c.length == _box!.length &&
|
||||||
c.width == _box.width &&
|
c.width == _box!.width &&
|
||||||
c.height == _box.height) {
|
c.height == _box!.height) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_cartonSizeController.text = c.name;
|
_cartonSizeController.text = c.name;
|
||||||
});
|
});
|
||||||
@@ -110,36 +110,37 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
_loadPackages() async {
|
_loadPackages() async {
|
||||||
if (!isFromPackages && !isSmallBag) return;
|
if (!isFromPackages && !isSmallBag) return;
|
||||||
|
|
||||||
if (_box.cartonType == carton_from_packages && _box.userID == null) return;
|
if (_box!.cartonType == carton_from_packages && _box!.userID == null)
|
||||||
|
return;
|
||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
List<Package> packages = await packageModel.getPackages(_box.userID, [
|
List<Package> packages = await packageModel.getPackages(_box!.userID, [
|
||||||
package_processed_status,
|
package_processed_status,
|
||||||
package_packed_status,
|
package_packed_status,
|
||||||
package_shipped_status,
|
package_shipped_status,
|
||||||
package_delivered_status
|
package_delivered_status
|
||||||
]);
|
]);
|
||||||
packages = packages.where((p) => _box.packageIDs.contains(p.id)).toList();
|
packages = packages.where((p) => _box!.packageIDs.contains(p.id)).toList();
|
||||||
packages.forEach((p) {
|
packages.forEach((p) {
|
||||||
p.isChecked = true;
|
p.isChecked = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_box.packages = packages;
|
_box!.packages = packages;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadMixCartons() async {
|
_loadMixCartons() async {
|
||||||
if (_box.cartonType != carton_mix_box) return;
|
if (_box!.cartonType != carton_mix_box) return;
|
||||||
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
|
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||||
List<Carton> catons = [];
|
List<Carton> catons = [];
|
||||||
for (var id in _box.mixCartonIDs) {
|
for (var id in _box!.mixCartonIDs) {
|
||||||
Carton c = await cartonModel.getCarton(id);
|
Carton c = await cartonModel.getCarton(id);
|
||||||
catons.add(c);
|
catons.add(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_box.mixCartons = catons;
|
_box!.mixCartons = catons;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,32 +168,32 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
readOnly: true,
|
readOnly: true,
|
||||||
values: cartonModel.cartonTypesInfo,
|
values: cartonModel.cartonTypesInfo,
|
||||||
selectedValue:
|
selectedValue:
|
||||||
_box.isShipmentCarton ? carton_from_shipments : _box.cartonType);
|
_box!.isShipmentCarton ? carton_from_shipments : _box!.cartonType);
|
||||||
final shipmentBox = DisplayText(
|
final shipmentBox = DisplayText(
|
||||||
text: _box.fcsShipmentNumber,
|
text: _box!.fcsShipmentNumber,
|
||||||
labelTextKey: "box.fcs_shipment_num",
|
labelTextKey: "box.fcs_shipment_num",
|
||||||
iconData: Ionicons.ios_airplane,
|
iconData: Ionicons.ios_airplane,
|
||||||
);
|
);
|
||||||
final fcsIDBox = DisplayText(
|
final fcsIDBox = DisplayText(
|
||||||
text: _box.fcsID == null ? "" : _box.fcsID,
|
text: _box!.fcsID == null ? "" : _box!.fcsID,
|
||||||
labelTextKey: "box.fcs.id",
|
labelTextKey: "box.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
);
|
);
|
||||||
|
|
||||||
final customerNameBox = DisplayText(
|
final customerNameBox = DisplayText(
|
||||||
text: _box.userName == null ? "" : _box.userName,
|
text: _box!.userName == null ? "" : _box!.userName,
|
||||||
labelTextKey: "box.name",
|
labelTextKey: "box.name",
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
);
|
);
|
||||||
|
|
||||||
final consigneefcsIDBox = DisplayText(
|
final consigneefcsIDBox = DisplayText(
|
||||||
text: _box.fcsID != null ? _box.fcsID : "",
|
text: _box!.fcsID != null ? _box!.fcsID : "",
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
);
|
);
|
||||||
|
|
||||||
final consigneeNameBox = DisplayText(
|
final consigneeNameBox = DisplayText(
|
||||||
text: _box.userName != null ? _box.userName : "",
|
text: _box!.userName != null ? _box!.userName : "",
|
||||||
labelTextKey: "processing.consignee.name",
|
labelTextKey: "processing.consignee.name",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
@@ -211,7 +212,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: _box.senderFCSID != null ? _box.senderFCSID : "",
|
text: _box!.senderFCSID,
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
)),
|
)),
|
||||||
@@ -219,7 +220,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final shipperNamebox = DisplayText(
|
final shipperNamebox = DisplayText(
|
||||||
text: _box.senderName != null ? _box.senderName : "",
|
text: _box!.senderName,
|
||||||
labelTextKey: "processing.shipper.name",
|
labelTextKey: "processing.shipper.name",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
@@ -269,10 +270,10 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
iconData: AntDesign.CodeSandbox,
|
iconData: AntDesign.CodeSandbox,
|
||||||
);
|
);
|
||||||
final cargoTableBox = CargoTable(
|
final cargoTableBox = CargoTable(
|
||||||
cargoTypes: _box.cargoTypes,
|
cargoTypes: _box!.cargoTypes,
|
||||||
);
|
);
|
||||||
final mixCartonNumberBox = DisplayText(
|
final mixCartonNumberBox = DisplayText(
|
||||||
text: _box.mixCartonNumber,
|
text: _box!.mixCartonNumber,
|
||||||
labelTextKey: "box.mix.carton",
|
labelTextKey: "box.mix.carton",
|
||||||
iconData: MaterialCommunityIcons.package,
|
iconData: MaterialCommunityIcons.package,
|
||||||
);
|
);
|
||||||
@@ -300,7 +301,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(selectMixBoxType)
|
Text(selectMixBoxType ?? "")
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@@ -340,7 +341,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: ListView(shrinkWrap: true, children: <Widget>[
|
child: ListView(shrinkWrap: true, children: <Widget>[
|
||||||
Center(child: getCartonNumberStatus(context, _box)),
|
Center(child: getCartonNumberStatus(context, _box!)),
|
||||||
LocalTitle(textKey: "box.type.title"),
|
LocalTitle(textKey: "box.type.title"),
|
||||||
cartonTypeBox,
|
cartonTypeBox,
|
||||||
LocalTitle(textKey: "box.shipment_info"),
|
LocalTitle(textKey: "box.shipment_info"),
|
||||||
@@ -367,11 +368,11 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
isMixBox ? mixTypeBox : Container(),
|
isMixBox ? mixTypeBox : Container(),
|
||||||
isMixBox ? LocalTitle(textKey: "box.mix_caton_title") : Container(),
|
isMixBox ? LocalTitle(textKey: "box.mix_caton_title") : Container(),
|
||||||
isMixBox
|
isMixBox
|
||||||
? Column(children: _getCartons(context, _box.mixCartons))
|
? Column(children: _getCartons(context, _box!.mixCartons))
|
||||||
: Container(),
|
: Container(),
|
||||||
isFromPackages || isSmallBag
|
isFromPackages || isSmallBag
|
||||||
? CartonPackageTable(
|
? CartonPackageTable(
|
||||||
packages: _box.packages,
|
packages: _box!.packages,
|
||||||
)
|
)
|
||||||
: Container(),
|
: Container(),
|
||||||
isMixBox ? Container() : LocalTitle(textKey: "box.cargo.type"),
|
isMixBox ? Container() : LocalTitle(textKey: "box.cargo.type"),
|
||||||
@@ -408,14 +409,14 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_gotoEditor() async {
|
_gotoEditor() async {
|
||||||
_box.mixCartons = _box.mixCartons;
|
_box!.mixCartons = _box!.mixCartons;
|
||||||
bool updated = await Navigator.push<bool>(
|
bool? updated = await Navigator.push<bool>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (context) => CartonEditor(box: _box)),
|
CupertinoPageRoute(builder: (context) => CartonEditor(box: _box)),
|
||||||
);
|
);
|
||||||
if (updated ?? false) {
|
if (updated ?? false) {
|
||||||
var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||||
var c = await cartonModel.getCarton(widget.box.id);
|
var c = await cartonModel.getCarton(widget.box!.id);
|
||||||
setState(() {
|
setState(() {
|
||||||
_box = c;
|
_box = c;
|
||||||
_loadPackages();
|
_loadPackages();
|
||||||
@@ -437,7 +438,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||||
await cartonModel.deleteCarton(widget.box);
|
await cartonModel.deleteCarton(widget.box!);
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_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;
|
||||||
CartonListRow({Key key, this.box}) : super(key: key);
|
CartonListRow({Key? key, this.box}) : super(key: key);
|
||||||
|
|
||||||
final double dotSize = 15.0;
|
final double dotSize = 15.0;
|
||||||
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||||
@@ -47,7 +47,7 @@ class CartonListRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
box.cartonNumber ?? "",
|
box!.cartonNumber ,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -55,7 +55,7 @@ class CartonListRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
box.userName ?? "",
|
box!.userName,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.grey),
|
fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
@@ -71,14 +71,14 @@ class CartonListRow extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
child: getStatus(box.status == null ? "" : box.status),
|
child: getStatus(box!.status == null ? "" : box!.status),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Text(
|
new Text(
|
||||||
"${box.cartonWeight?.toStringAsFixed(2) ?? ''} lb",
|
"${box!.cartonWeight.toStringAsFixed(2)} lb",
|
||||||
style:
|
style:
|
||||||
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import 'package:flutter/material.dart';
|
|||||||
typedef OnSelect = Function(Carton carton, bool checked);
|
typedef OnSelect = Function(Carton carton, bool checked);
|
||||||
|
|
||||||
class CartonMixTable extends StatelessWidget {
|
class CartonMixTable extends StatelessWidget {
|
||||||
final List<Carton> cartons;
|
final List<Carton>? cartons;
|
||||||
final OnSelect onSelect;
|
final OnSelect? onSelect;
|
||||||
|
|
||||||
const CartonMixTable({Key key, this.cartons, this.onSelect})
|
const CartonMixTable({Key? key, this.cartons, this.onSelect})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -32,21 +32,21 @@ class CartonMixTable extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final rows = cartons == null
|
final rows = cartons == null
|
||||||
? []
|
? [Container()]
|
||||||
: cartons.asMap().entries.map((p) {
|
: cartons!.asMap().entries.map((p) {
|
||||||
return Container(
|
return Container(
|
||||||
color: p.value.isChecked
|
color: p.value.isChecked
|
||||||
? Colors.grey.withOpacity(0.2)
|
? Colors.grey.withOpacity(0.2)
|
||||||
: Colors.grey[50].withOpacity(0.2),
|
: Colors.grey.shade50.withOpacity(0.2),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(
|
bottom: BorderSide(
|
||||||
color: p.key == cartons.length - 1
|
color: p.key == cartons!.length - 1
|
||||||
? Colors.white
|
? Colors.white
|
||||||
: Colors.grey[350],
|
: Colors.grey.shade300,
|
||||||
width: 1),
|
width: 1),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -55,16 +55,16 @@ class CartonMixTable extends StatelessWidget {
|
|||||||
Checkbox(
|
Checkbox(
|
||||||
value: p.value.isChecked,
|
value: p.value.isChecked,
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
onChanged: (bool check) {
|
onChanged: (bool? check) {
|
||||||
if (onSelect != null) onSelect(p.value, check);
|
if (onSelect != null) onSelect!(p.value, check!);
|
||||||
}),
|
}),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: new Text(
|
child: new Text(
|
||||||
p.value.cartonNumber ?? "",
|
p.value.cartonNumber,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
)),
|
||||||
new Text(
|
new Text(
|
||||||
p.value?.actualWeight?.toString() ?? "",
|
p.value.actualWeight.toString(),
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import 'package:flutter/material.dart';
|
|||||||
typedef OnSelect = Function(Package package, bool checked);
|
typedef OnSelect = Function(Package package, bool checked);
|
||||||
|
|
||||||
class CartonPackageTable extends StatelessWidget {
|
class CartonPackageTable extends StatelessWidget {
|
||||||
final List<Package> packages;
|
final List<Package>? packages;
|
||||||
final OnSelect onSelect;
|
final OnSelect? onSelect;
|
||||||
|
|
||||||
const CartonPackageTable({Key key, this.packages, this.onSelect})
|
const CartonPackageTable({Key? key, this.packages, this.onSelect})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -34,20 +34,20 @@ class CartonPackageTable extends StatelessWidget {
|
|||||||
|
|
||||||
final rows = packages == null
|
final rows = packages == null
|
||||||
? [Container()]
|
? [Container()]
|
||||||
: packages.asMap().entries.map((p) {
|
: packages!.asMap().entries.map((p) {
|
||||||
return Container(
|
return Container(
|
||||||
color: p.value.isChecked
|
color: p.value.isChecked
|
||||||
? Colors.grey.withOpacity(0.2)
|
? Colors.grey.withOpacity(0.2)
|
||||||
: Colors.grey[50].withOpacity(0.2),
|
: Colors.grey.shade50.withOpacity(0.2),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(
|
bottom: BorderSide(
|
||||||
color: p.key == packages.length - 1
|
color: p.key == packages!.length - 1
|
||||||
? Colors.white
|
? Colors.white
|
||||||
: Colors.grey[350],
|
: Colors.grey.shade300,
|
||||||
width: 1),
|
width: 1),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -62,8 +62,8 @@ class CartonPackageTable extends StatelessWidget {
|
|||||||
: Checkbox(
|
: Checkbox(
|
||||||
value: p.value.isChecked,
|
value: p.value.isChecked,
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
onChanged: (bool check) {
|
onChanged: (bool? check) {
|
||||||
if (onSelect != null) onSelect(p.value, check);
|
if (onSelect != null) onSelect!(p.value, check!);
|
||||||
}),
|
}),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -74,11 +74,11 @@ class CartonPackageTable extends StatelessWidget {
|
|||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
p.value.deliveryAddress?.fullName ?? "",
|
p.value.deliveryAddress.fullName,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
p.value.deliveryAddress?.phoneNumber ?? "",
|
p.value.deliveryAddress.phoneNumber,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -88,11 +88,11 @@ class CartonPackageTable extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
new Text(
|
new Text(
|
||||||
p.value?.desc ?? "",
|
p.value.desc,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
new Text(
|
new Text(
|
||||||
"(${p.value?.market ?? ""})",
|
"(${p.value.market})",
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ import 'package:fcs/domain/entities/carton.dart';
|
|||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
typedef OnRemove(Carton carton);
|
typedef OnRemove(Carton carton);
|
||||||
|
|
||||||
class CartonRow extends StatelessWidget {
|
class CartonRow extends StatelessWidget {
|
||||||
final Carton box;
|
final Carton? box;
|
||||||
final OnRemove onRemove;
|
final OnRemove? onRemove;
|
||||||
CartonRow({Key key, this.box, this.onRemove}) : super(key: key);
|
CartonRow({Key? key, this.box, this.onRemove}) : super(key: key);
|
||||||
|
|
||||||
final double dotSize = 15.0;
|
final double dotSize = 15.0;
|
||||||
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||||
@@ -20,7 +20,7 @@ class CartonRow extends StatelessWidget {
|
|||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(color: Colors.grey[300]),
|
bottom: BorderSide(color: Colors.grey.shade300),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -45,7 +45,7 @@ class CartonRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
box.cartonNumber ?? "",
|
box!.cartonNumber,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -53,7 +53,7 @@ class CartonRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
box.userName ?? "",
|
box!.userName,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.grey),
|
fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
@@ -75,16 +75,16 @@ class CartonRow extends StatelessWidget {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (onRemove != null) onRemove(box);
|
if (onRemove != null) onRemove!(box!);
|
||||||
}),
|
}),
|
||||||
box.actualWeight == 0
|
box!.actualWeight == 0
|
||||||
? Container()
|
? Container()
|
||||||
: Padding(
|
: Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0, bottom: 5),
|
padding: const EdgeInsets.only(left: 8.0, bottom: 5),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Text(
|
new Text(
|
||||||
"${box.actualWeight?.toStringAsFixed(2) ?? ''} lb",
|
"${box!.actualWeight.toStringAsFixed(2)} lb",
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.grey),
|
fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import 'package:flutter/material.dart';
|
|||||||
typedef OnAdd(String value);
|
typedef OnAdd(String value);
|
||||||
|
|
||||||
class InputTextBorder extends StatelessWidget {
|
class InputTextBorder extends StatelessWidget {
|
||||||
final OnAdd onAdd;
|
final OnAdd? onAdd;
|
||||||
final TextEditingController controller;
|
final TextEditingController? controller;
|
||||||
|
|
||||||
const InputTextBorder({Key key, this.onAdd, this.controller})
|
const InputTextBorder({Key? key, this.onAdd, this.controller})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -14,7 +14,7 @@ class InputTextBorder extends StatelessWidget {
|
|||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
onChanged: (v) {
|
onChanged: (v) {
|
||||||
if (onAdd != null) onAdd(v);
|
if (onAdd != null) onAdd!(v);
|
||||||
},
|
},
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
decoration: new InputDecoration(
|
decoration: new InputDecoration(
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import 'package:fcs/pages/widgets/local_title.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'cargo_type_addtion.dart';
|
import 'cargo_type_addtion.dart';
|
||||||
@@ -29,9 +29,9 @@ import 'carton_cargo_table.dart';
|
|||||||
import 'model/carton_model.dart';
|
import 'model/carton_model.dart';
|
||||||
|
|
||||||
class PackageCartonEditor extends StatefulWidget {
|
class PackageCartonEditor extends StatefulWidget {
|
||||||
final Carton carton;
|
final Carton? carton;
|
||||||
final bool isNew;
|
final bool? isNew;
|
||||||
final User consignee;
|
final User? consignee;
|
||||||
PackageCartonEditor({this.carton, this.isNew, this.consignee});
|
PackageCartonEditor({this.carton, this.isNew, this.consignee});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -43,13 +43,13 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
TextEditingController _widthCtl = new TextEditingController();
|
TextEditingController _widthCtl = new TextEditingController();
|
||||||
TextEditingController _heightCtl = new TextEditingController();
|
TextEditingController _heightCtl = new TextEditingController();
|
||||||
|
|
||||||
Carton _carton;
|
Carton? _carton;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||||
List<CargoType> _cargoTypes = [];
|
List<CargoType> _cargoTypes = [];
|
||||||
CartonSize selectedCatonSize;
|
CartonSize? selectedCatonSize;
|
||||||
bool isFromPackages;
|
bool isFromPackages = false;
|
||||||
bool isFromCartons;
|
bool isFromCartons = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -59,19 +59,19 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
|
|
||||||
_load() {
|
_load() {
|
||||||
_carton = widget.carton;
|
_carton = widget.carton;
|
||||||
isFromPackages = _carton.cartonType == carton_from_packages;
|
isFromPackages = _carton!.cartonType == carton_from_packages;
|
||||||
isFromCartons = _carton.cartonType == carton_from_cartons;
|
isFromCartons = _carton!.cartonType == carton_from_cartons;
|
||||||
|
|
||||||
if (widget.isNew) {
|
if (widget.isNew!) {
|
||||||
_lengthCtl.text = "0";
|
_lengthCtl.text = "0";
|
||||||
_widthCtl.text = "0";
|
_widthCtl.text = "0";
|
||||||
_heightCtl.text = "0";
|
_heightCtl.text = "0";
|
||||||
} else {
|
} else {
|
||||||
_cargoTypes = widget.carton.cargoTypes.map((e) => e.clone()).toList();
|
_cargoTypes = widget.carton!.cargoTypes.map((e) => e.clone()).toList();
|
||||||
_lengthCtl.text = _carton.length.toString();
|
_lengthCtl.text = _carton!.length.toString();
|
||||||
_widthCtl.text = _carton.width.toString();
|
_widthCtl.text = _carton!.width.toString();
|
||||||
_heightCtl.text = _carton.height.toString();
|
_heightCtl.text = _carton!.height.toString();
|
||||||
_deliveryAddress = _carton.deliveryAddress;
|
_deliveryAddress = _carton!.deliveryAddress;
|
||||||
_getCartonSize();
|
_getCartonSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,9 +79,9 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
_getCartonSize() {
|
_getCartonSize() {
|
||||||
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
||||||
cartonSizeModel.cartonSizes.forEach((c) {
|
cartonSizeModel.cartonSizes.forEach((c) {
|
||||||
if (c.length == _carton.length &&
|
if (c.length == _carton!.length &&
|
||||||
c.width == _carton.width &&
|
c.width == _carton!.width &&
|
||||||
c.height == _carton.height) {
|
c.height == _carton!.height) {
|
||||||
selectedCatonSize = CartonSize(
|
selectedCatonSize = CartonSize(
|
||||||
id: c.id,
|
id: c.id,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
@@ -122,7 +122,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
final createBtn = LocalButton(
|
final createBtn = LocalButton(
|
||||||
textKey: widget.isNew ? "box.new_carton_btn" : "box.cargo.save.btn",
|
textKey: widget.isNew! ? "box.new_carton_btn" : "box.cargo.save.btn",
|
||||||
callBack: _creatCarton,
|
callBack: _creatCarton,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -134,11 +134,10 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
List<CargoType> cargos = await Navigator.push<List<CargoType>>(
|
List<CargoType>? cargos = await Navigator.push<List<CargoType>>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
||||||
if (cargos == null) return;
|
if (cargos == null) return;
|
||||||
if (cargos == null) return;
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_cargoTypes.addAll(
|
_cargoTypes.addAll(
|
||||||
cargos.where((e) => !_cargoTypes.contains(e)).toList());
|
cargos.where((e) => !_cargoTypes.contains(e)).toList());
|
||||||
@@ -168,7 +167,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
title: LocalText(
|
title: LocalText(
|
||||||
context,
|
context,
|
||||||
widget.isNew ? "boxes.create.title" : "box.edit.title",
|
widget.isNew! ? "boxes.create.title" : "box.edit.title",
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
@@ -187,13 +186,14 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
deliveryAddress: _deliveryAddress,
|
deliveryAddress: _deliveryAddress,
|
||||||
labelKey: "box.delivery_address",
|
labelKey: "box.delivery_address",
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
|
DeliveryAddress? d = await Navigator.push<DeliveryAddress>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => DeliveryAddressSelection(
|
builder: (context) => DeliveryAddressSelection(
|
||||||
deliveryAddress: _deliveryAddress,
|
deliveryAddress: _deliveryAddress,
|
||||||
user: User(
|
user: User(
|
||||||
id: _carton.userID, name: _carton.userName),
|
id: _carton!.userID,
|
||||||
|
name: _carton!.userName),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
if (d == null) return;
|
if (d == null) return;
|
||||||
@@ -245,17 +245,17 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
height: 1,
|
height: 1,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
onChanged: (CartonSize newValue) {
|
onChanged: (CartonSize? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (newValue.name == MANAGE_CARTONSIZE) {
|
if (newValue!.name == MANAGE_CARTONSIZE) {
|
||||||
selectedCatonSize = null;
|
selectedCatonSize = null;
|
||||||
_manageCartonSize();
|
_manageCartonSize();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
selectedCatonSize = newValue;
|
selectedCatonSize = newValue;
|
||||||
_widthCtl.text = selectedCatonSize.width.toString();
|
_widthCtl.text = selectedCatonSize!.width.toString();
|
||||||
_heightCtl.text = selectedCatonSize.height.toString();
|
_heightCtl.text = selectedCatonSize!.height.toString();
|
||||||
_lengthCtl.text = selectedCatonSize.length.toString();
|
_lengthCtl.text = selectedCatonSize!.length.toString();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
@@ -263,7 +263,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
.map<DropdownMenuItem<CartonSize>>((CartonSize value) {
|
.map<DropdownMenuItem<CartonSize>>((CartonSize value) {
|
||||||
return DropdownMenuItem<CartonSize>(
|
return DropdownMenuItem<CartonSize>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(value.name ?? "",
|
child: Text(value.name,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: value.name == MANAGE_CARTONSIZE
|
color: value.name == MANAGE_CARTONSIZE
|
||||||
@@ -295,8 +295,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
|
|
||||||
_updateCargo(CargoType cargo) {
|
_updateCargo(CargoType cargo) {
|
||||||
setState(() {
|
setState(() {
|
||||||
var _c =
|
var _c = _cargoTypes.firstWhere((e) => e.id == cargo.id);
|
||||||
_cargoTypes.firstWhere((e) => e.id == cargo.id, orElse: () => null);
|
|
||||||
if (_c != null) {
|
if (_c != null) {
|
||||||
_c.weight = cargo.weight;
|
_c.weight = cargo.weight;
|
||||||
_c.qty = cargo.qty;
|
_c.qty = cargo.qty;
|
||||||
@@ -305,13 +304,13 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_creatCarton() async {
|
_creatCarton() async {
|
||||||
if ((_cargoTypes?.length ?? 0) == 0) {
|
if (_cargoTypes.length == 0) {
|
||||||
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double l = double.parse(_lengthCtl.text, (s) => 0);
|
double l = double.parse(_lengthCtl.text);
|
||||||
double w = double.parse(_widthCtl.text, (s) => 0);
|
double w = double.parse(_widthCtl.text);
|
||||||
double h = double.parse(_heightCtl.text, (s) => 0);
|
double h = double.parse(_heightCtl.text);
|
||||||
if ((l <= 0 || w <= 0 || h <= 0)) {
|
if ((l <= 0 || w <= 0 || h <= 0)) {
|
||||||
showMsgDialog(context, "Error", "Invalid dimension");
|
showMsgDialog(context, "Error", "Invalid dimension");
|
||||||
return;
|
return;
|
||||||
@@ -322,22 +321,22 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Carton carton = Carton();
|
Carton carton = Carton();
|
||||||
carton.id = _carton.id;
|
carton.id = _carton!.id;
|
||||||
carton.cartonType = _carton.cartonType;
|
carton.cartonType = _carton!.cartonType;
|
||||||
carton.fcsShipmentID = _carton.fcsShipmentID;
|
carton.fcsShipmentID = _carton!.fcsShipmentID;
|
||||||
carton.cargoTypes = _cargoTypes;
|
carton.cargoTypes = _cargoTypes;
|
||||||
if (isFromPackages) {
|
if (isFromPackages) {
|
||||||
carton.userID = _carton.userID;
|
carton.userID = _carton!.userID;
|
||||||
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
carton.packages = _carton!.packages.where((e) => e.isChecked).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFromCartons) {
|
if (isFromCartons) {
|
||||||
carton.userID = _carton.userID;
|
carton.userID = _carton!.userID;
|
||||||
carton.fcsID = _carton.fcsID;
|
carton.fcsID = _carton!.fcsID;
|
||||||
carton.userName = _carton.userName;
|
carton.userName = _carton!.userName;
|
||||||
carton.senderID = _carton.senderID;
|
carton.senderID = _carton!.senderID;
|
||||||
carton.senderFCSID = _carton.senderFCSID;
|
carton.senderFCSID = _carton!.senderFCSID;
|
||||||
carton.senderName = _carton.senderName;
|
carton.senderName = _carton!.senderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
carton.length = l;
|
carton.length = l;
|
||||||
@@ -350,12 +349,12 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
try {
|
try {
|
||||||
CartonModel cartonModel =
|
CartonModel cartonModel =
|
||||||
Provider.of<CartonModel>(context, listen: false);
|
Provider.of<CartonModel>(context, listen: false);
|
||||||
if (widget.isNew) {
|
if (widget.isNew!) {
|
||||||
Carton _c = await cartonModel.createCarton(carton);
|
Carton _c = await cartonModel.createCarton(carton);
|
||||||
Navigator.pop(context, _c);
|
Navigator.pop(context, _c);
|
||||||
} else {
|
} else {
|
||||||
await cartonModel.updateCarton(carton);
|
await cartonModel.updateCarton(carton);
|
||||||
Carton _c = await cartonModel.getCarton(_carton.id);
|
Carton _c = await cartonModel.getCarton(_carton!.id);
|
||||||
Navigator.pop(context, _c);
|
Navigator.pop(context, _c);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import 'package:fcs/pages/main/util.dart';
|
|||||||
typedef void ProfileCallback();
|
typedef void ProfileCallback();
|
||||||
|
|
||||||
class TotalWeightEdit extends StatefulWidget {
|
class TotalWeightEdit extends StatefulWidget {
|
||||||
final double totalWeight;
|
final double? totalWeight;
|
||||||
|
|
||||||
const TotalWeightEdit({Key key, this.totalWeight}) : super(key: key);
|
const TotalWeightEdit({Key? key, this.totalWeight}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_TotalWeightEditState createState() => _TotalWeightEditState();
|
_TotalWeightEditState createState() => _TotalWeightEditState();
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ class _TotalWeightEditState extends State<TotalWeightEdit> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
totalController.text = widget.totalWeight.toStringAsFixed(2);
|
totalController.text = widget.totalWeight!.toStringAsFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ Widget getCartonNumberStatus(BuildContext context, Carton carton) {
|
|||||||
LocalText(
|
LocalText(
|
||||||
context,
|
context,
|
||||||
'',
|
'',
|
||||||
text: carton.cartonNumber ?? "",
|
text: carton.cartonNumber ,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: Chip(label: Text(carton.status ?? "")),
|
child: Chip(label: Text(carton.status)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import 'package:fcs/domain/entities/carton.dart';
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
|
|
||||||
import 'carton_search.dart';
|
import 'carton_search.dart';
|
||||||
|
|
||||||
class CartonListRow extends StatefulWidget {
|
class CartonListRow extends StatefulWidget {
|
||||||
final CallbackCartonSelect callbackCartonSelect;
|
final CallbackCartonSelect? callbackCartonSelect;
|
||||||
final Carton carton;
|
final Carton? carton;
|
||||||
|
|
||||||
// const CartonListRow({this.carton, this.callbackCartonSelect});
|
// const CartonListRow({this.carton, this.callbackCartonSelect});
|
||||||
CartonListRow(
|
CartonListRow(
|
||||||
{Key key, this.carton, this.callbackCartonSelect})
|
{Key? key, this.carton, this.callbackCartonSelect})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -20,7 +20,7 @@ class CartonListRow extends StatefulWidget {
|
|||||||
|
|
||||||
class _CartonListRowState extends State<CartonListRow> {
|
class _CartonListRowState extends State<CartonListRow> {
|
||||||
final double dotSize = 15.0;
|
final double dotSize = 15.0;
|
||||||
Carton _carton;
|
Carton? _carton;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -32,14 +32,14 @@ class _CartonListRowState extends State<CartonListRow> {
|
|||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(color: Colors.grey[300]),
|
bottom: BorderSide(color: Colors.grey.shade300),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
if (widget.callbackCartonSelect != null)
|
if (widget.callbackCartonSelect != null)
|
||||||
widget.callbackCartonSelect(widget.carton);
|
widget.callbackCartonSelect!(widget.carton!);
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -64,7 +64,7 @@ class _CartonListRowState extends State<CartonListRow> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
_carton.cartonNumber ?? "",
|
_carton!.cartonNumber,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -72,7 +72,7 @@ class _CartonListRowState extends State<CartonListRow> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
_carton.userName ?? "",
|
_carton!.userName,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.grey),
|
fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
@@ -86,7 +86,7 @@ class _CartonListRowState extends State<CartonListRow> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Text(
|
new Text(
|
||||||
"${_carton.cartonWeight?.toStringAsFixed(2) ?? ''} lb",
|
"${_carton!.cartonWeight.toStringAsFixed(2)} lb",
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.grey),
|
fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/popupmenu.dart';
|
import 'package:fcs/pages/widgets/popupmenu.dart';
|
||||||
import 'package:fcs/pagination/paginator_listview.dart';
|
import 'package:fcs/pagination/paginator_listview.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@@ -18,15 +18,15 @@ import 'carton_list_row.dart';
|
|||||||
|
|
||||||
typedef CallbackCartonSelect(Carton carton);
|
typedef CallbackCartonSelect(Carton carton);
|
||||||
|
|
||||||
Future<Carton> searchCarton(BuildContext context,
|
Future<Carton?> searchCarton(BuildContext context,
|
||||||
{CallbackCartonSelect callbackCartonSelect}) async =>
|
{CallbackCartonSelect? callbackCartonSelect}) async =>
|
||||||
await showSearch<Carton>(
|
await showSearch<Carton>(
|
||||||
context: context,
|
context: context,
|
||||||
delegate: PartSearchDelegate(callbackCartonSelect: callbackCartonSelect),
|
delegate: PartSearchDelegate(callbackCartonSelect: callbackCartonSelect),
|
||||||
);
|
);
|
||||||
|
|
||||||
class PartSearchDelegate extends SearchDelegate<Carton> {
|
class PartSearchDelegate extends SearchDelegate<Carton> {
|
||||||
final CallbackCartonSelect callbackCartonSelect;
|
final CallbackCartonSelect? callbackCartonSelect;
|
||||||
PartSearchDelegate({this.callbackCartonSelect});
|
PartSearchDelegate({this.callbackCartonSelect});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -38,10 +38,10 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
|
|||||||
return theme.copyWith(
|
return theme.copyWith(
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
color: theme.primaryTextTheme.caption.color, fontSize: 14)),
|
color: theme.primaryTextTheme.caption!.color, fontSize: 14)),
|
||||||
textTheme: theme.textTheme.copyWith(
|
textTheme: theme.textTheme.copyWith(
|
||||||
title: theme.textTheme.title.copyWith(
|
title: theme.textTheme.title!.copyWith(
|
||||||
color: theme.primaryTextTheme.title.color, fontSize: 16)),
|
color: theme.primaryTextTheme.title!.color, fontSize: 16)),
|
||||||
primaryColor: primaryColor,
|
primaryColor: primaryColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
|
|||||||
Widget buildLeading(BuildContext context) {
|
Widget buildLeading(BuildContext context) {
|
||||||
return IconButton(
|
return IconButton(
|
||||||
icon: Icon(Icons.arrow_back),
|
icon: Icon(Icons.arrow_back),
|
||||||
onPressed: () => close(context, null),
|
onPressed: () => close(context, new Carton()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
|
|||||||
future: cartonModel.searchCarton(query),
|
future: cartonModel.searchCarton(query),
|
||||||
builder: (context, AsyncSnapshot<List<Carton>> snapshot) {
|
builder: (context, AsyncSnapshot<List<Carton>> snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
if (snapshot.data.length == 0) {
|
if (snapshot.data!.length == 0) {
|
||||||
return Container(
|
return Container(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -109,7 +109,7 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
|
|||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(top: 15),
|
padding: EdgeInsets.only(top: 15),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: snapshot.data
|
children: snapshot.data!
|
||||||
.map((u) => CartonListRow(
|
.map((u) => CartonListRow(
|
||||||
key: ValueKey(u.id),
|
key: ValueKey(u.id),
|
||||||
carton: u,
|
carton: u,
|
||||||
@@ -158,17 +158,17 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_scan(BuildContext context) async {
|
_scan(BuildContext context) async {
|
||||||
PermissionStatus permission =
|
// PermissionStatus permission =
|
||||||
await PermissionHandler().checkPermissionStatus(PermissionGroup.camera);
|
// await PermissionHandler().checkPermissionStatus(PermissionGroup.camera);
|
||||||
if (permission != PermissionStatus.granted) {
|
// if (permission != PermissionStatus.granted) {
|
||||||
Map<PermissionGroup, PermissionStatus> permissions =
|
// Map<PermissionGroup, PermissionStatus> permissions =
|
||||||
await PermissionHandler()
|
// await PermissionHandler()
|
||||||
.requestPermissions([PermissionGroup.camera]);
|
// .requestPermissions([PermissionGroup.camera]);
|
||||||
if (permissions[PermissionGroup.camera] != PermissionStatus.granted) {
|
// if (permissions[PermissionGroup.camera] != PermissionStatus.granted) {
|
||||||
showMsgDialog(context, "Error", "Camera permission is not granted");
|
// showMsgDialog(context, "Error", "Camera permission is not granted");
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String barcode = await scanBarcode();
|
String barcode = await scanBarcode();
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'model/carton_size_model.dart';
|
import 'model/carton_size_model.dart';
|
||||||
|
|
||||||
class CartonSizeEditor extends StatefulWidget {
|
class CartonSizeEditor extends StatefulWidget {
|
||||||
final CartonSize cartonSize;
|
final CartonSize? cartonSize;
|
||||||
CartonSizeEditor({this.cartonSize});
|
CartonSizeEditor({this.cartonSize});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -27,8 +27,8 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
|||||||
TextEditingController _lengthController = new TextEditingController();
|
TextEditingController _lengthController = new TextEditingController();
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
CartonSize _cartonSize;
|
CartonSize? _cartonSize;
|
||||||
bool _isNew;
|
bool _isNew = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -36,10 +36,10 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
|||||||
if (widget.cartonSize != null) {
|
if (widget.cartonSize != null) {
|
||||||
_cartonSize = widget.cartonSize;
|
_cartonSize = widget.cartonSize;
|
||||||
_isNew = false;
|
_isNew = false;
|
||||||
_nameController.text = _cartonSize.name;
|
_nameController.text = _cartonSize!.name;
|
||||||
_widthController.text = _cartonSize.width.toString();
|
_widthController.text = _cartonSize!.width.toString();
|
||||||
_heightController.text = _cartonSize.height.toString();
|
_heightController.text = _cartonSize!.height.toString();
|
||||||
_lengthController.text = _cartonSize.length.toString();
|
_lengthController.text = _cartonSize!.length.toString();
|
||||||
} else {
|
} else {
|
||||||
_lengthController.text = "12";
|
_lengthController.text = "12";
|
||||||
_widthController.text = "12";
|
_widthController.text = "12";
|
||||||
@@ -110,7 +110,7 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
|||||||
await cartonSizeModel.addCartonSize(_cartonSize);
|
await cartonSizeModel.addCartonSize(_cartonSize);
|
||||||
} else {
|
} else {
|
||||||
CartonSize _cartonSize = CartonSize(
|
CartonSize _cartonSize = CartonSize(
|
||||||
id: widget.cartonSize.id,
|
id: widget.cartonSize!.id,
|
||||||
name: _nameController.text,
|
name: _nameController.text,
|
||||||
length: l,
|
length: l,
|
||||||
width: w,
|
width: w,
|
||||||
@@ -184,7 +184,7 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
|||||||
CartonSize _cartonSize = CartonSize(
|
CartonSize _cartonSize = CartonSize(
|
||||||
name: _nameController.text, length: l, width: w, height: h);
|
name: _nameController.text, length: l, width: w, height: h);
|
||||||
|
|
||||||
return widget.cartonSize.isChangedForEdit(_cartonSize);
|
return widget.cartonSize!.isChangedForEdit(_cartonSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import 'package:provider/provider.dart';
|
|||||||
typedef void FindCallBack();
|
typedef void FindCallBack();
|
||||||
|
|
||||||
class CustomerEditor extends StatefulWidget {
|
class CustomerEditor extends StatefulWidget {
|
||||||
final User customer;
|
final User? customer;
|
||||||
const CustomerEditor({this.customer});
|
const CustomerEditor({this.customer});
|
||||||
@override
|
@override
|
||||||
_CustomerEditorState createState() => _CustomerEditorState();
|
_CustomerEditorState createState() => _CustomerEditorState();
|
||||||
@@ -34,17 +34,17 @@ class _CustomerEditorState extends State<CustomerEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: widget.customer.phoneNumber,
|
text: widget.customer!.phoneNumber,
|
||||||
labelTextKey: "customer.phone",
|
labelTextKey: "customer.phone",
|
||||||
iconData: Icons.phone,
|
iconData: Icons.phone,
|
||||||
)),
|
)),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.open_in_new, color: primaryColor),
|
icon: Icon(Icons.open_in_new, color: primaryColor),
|
||||||
onPressed: () => call(context, widget.customer.phoneNumber)),
|
onPressed: () => call(context, widget.customer!.phoneNumber)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final enabled = widget.customer.status != user_disabled_status;
|
final enabled = widget.customer!.status != user_disabled_status;
|
||||||
final enableBox = LocalButton(
|
final enableBox = LocalButton(
|
||||||
textKey: enabled ? "customer.disable.btn" : "customer.enable.btn",
|
textKey: enabled ? "customer.disable.btn" : "customer.enable.btn",
|
||||||
iconData: enabled ? Icons.lock : Icons.lock_open,
|
iconData: enabled ? Icons.lock : Icons.lock_open,
|
||||||
@@ -68,7 +68,7 @@ class _CustomerEditorState extends State<CustomerEditor> {
|
|||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
widget.customer.name,
|
widget.customer!.name,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
@@ -81,26 +81,26 @@ class _CustomerEditorState extends State<CustomerEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
phoneNumberBox,
|
phoneNumberBox,
|
||||||
DisplayText(
|
DisplayText(
|
||||||
text: widget.customer.fcsID,
|
text: widget.customer!.fcsID,
|
||||||
labelTextKey: "customer.fcs.id",
|
labelTextKey: "customer.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
),
|
),
|
||||||
DisplayText(
|
DisplayText(
|
||||||
text: widget.customer.status,
|
text: widget.customer!.status,
|
||||||
labelTextKey: "customer.status",
|
labelTextKey: "customer.status",
|
||||||
iconData: Icons.add_alarm,
|
iconData: Icons.add_alarm,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
widget.customer.requested
|
widget.customer!.requested
|
||||||
? fcsButton(
|
? fcsButton(
|
||||||
context,
|
context,
|
||||||
getLocalString(
|
getLocalString(
|
||||||
context, "customer.invitation.request.confirm"),
|
context, "customer.invitation.request.confirm"),
|
||||||
callack: _add)
|
callack: _add)
|
||||||
: Container(),
|
: Container(),
|
||||||
widget.customer.joined || widget.customer.disabled
|
widget.customer!.joined || widget.customer!.disabled
|
||||||
? enableBox
|
? enableBox
|
||||||
: Container()
|
: Container()
|
||||||
],
|
],
|
||||||
@@ -119,7 +119,7 @@ class _CustomerEditorState extends State<CustomerEditor> {
|
|||||||
CustomerModel customerModel =
|
CustomerModel customerModel =
|
||||||
Provider.of<CustomerModel>(context, listen: false);
|
Provider.of<CustomerModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
await customerModel.acceptRequest(widget.customer.id);
|
await customerModel.acceptRequest(widget.customer!.id);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
@@ -139,7 +139,7 @@ class _CustomerEditorState extends State<CustomerEditor> {
|
|||||||
CustomerModel customerModel =
|
CustomerModel customerModel =
|
||||||
Provider.of<CustomerModel>(context, listen: false);
|
Provider.of<CustomerModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
await customerModel.enableUser(widget.customer, enabled);
|
await customerModel.enableUser(widget.customer!, enabled);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -233,11 +233,11 @@ class _CustomerListState extends State<CustomerList> {
|
|||||||
_share(User user) async {
|
_share(User user) async {
|
||||||
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
||||||
String appUrl = mainModel.setting.appUrl;
|
String appUrl = mainModel.setting.appUrl;
|
||||||
final RenderBox box = context.findRenderObject();
|
final RenderBox? box = context.findRenderObject() as RenderBox;
|
||||||
await Share.share(
|
await Share.share(
|
||||||
"Join us on FCS Logistics App. Here is the link:\n $appUrl\n" +
|
"Join us on FCS Logistics App. Here is the link:\n $appUrl\n" +
|
||||||
user.share,
|
user.share,
|
||||||
subject: "Invitation to FCS Logistics App",
|
subject: "Invitation to FCS Logistics App",
|
||||||
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
|
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class _InvitationCreateState extends State<InvitationCreate> {
|
|||||||
TextEditingController _phoneController = new TextEditingController();
|
TextEditingController _phoneController = new TextEditingController();
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
String dialCode;
|
late String dialCode;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -85,7 +85,7 @@ class _InvitationCreateState extends State<InvitationCreate> {
|
|||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: Colors.grey[400], width: 1),
|
border: Border.all(color: Colors.grey.shade400, width: 1),
|
||||||
borderRadius: BorderRadius.all(Radius.circular(12.0))),
|
borderRadius: BorderRadius.all(Radius.circular(12.0))),
|
||||||
child: CountryCodePicker(
|
child: CountryCodePicker(
|
||||||
onChanged: _countryChange,
|
onChanged: _countryChange,
|
||||||
@@ -140,7 +140,7 @@ class _InvitationCreateState extends State<InvitationCreate> {
|
|||||||
|
|
||||||
_countryChange(CountryCode countryCode) {
|
_countryChange(CountryCode countryCode) {
|
||||||
setState(() {
|
setState(() {
|
||||||
dialCode = countryCode.dialCode;
|
dialCode = countryCode.dialCode!;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import 'package:provider/provider.dart';
|
|||||||
typedef void FindCallBack();
|
typedef void FindCallBack();
|
||||||
|
|
||||||
class InvitationEditor extends StatefulWidget {
|
class InvitationEditor extends StatefulWidget {
|
||||||
final User customer;
|
final User? customer;
|
||||||
const InvitationEditor({this.customer});
|
const InvitationEditor({this.customer});
|
||||||
@override
|
@override
|
||||||
_InvitationEditorState createState() => _InvitationEditorState();
|
_InvitationEditorState createState() => _InvitationEditorState();
|
||||||
@@ -31,13 +31,13 @@ class _InvitationEditorState extends State<InvitationEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: widget.customer.phoneNumber,
|
text: widget.customer!.phoneNumber,
|
||||||
labelTextKey: getLocalString(context, "customer.phone"),
|
labelTextKey: getLocalString(context, "customer.phone"),
|
||||||
iconData: Icons.phone,
|
iconData: Icons.phone,
|
||||||
)),
|
)),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.open_in_new, color: primaryColor),
|
icon: Icon(Icons.open_in_new, color: primaryColor),
|
||||||
onPressed: () => call(context, widget.customer.phoneNumber)),
|
onPressed: () => call(context, widget.customer!.phoneNumber)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ class _InvitationEditorState extends State<InvitationEditor> {
|
|||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
widget.customer.name,
|
widget.customer!.name,
|
||||||
style: TextStyle(fontSize: 20, color: primaryColor),
|
style: TextStyle(fontSize: 20, color: primaryColor),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -87,7 +87,7 @@ class _InvitationEditorState extends State<InvitationEditor> {
|
|||||||
CustomerModel customerModel =
|
CustomerModel customerModel =
|
||||||
Provider.of<CustomerModel>(context, listen: false);
|
Provider.of<CustomerModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
await customerModel.deleteInvite(widget.customer.phoneNumber);
|
await customerModel.deleteInvite(widget.customer!.phoneNumber);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ class CustomerModel extends BaseModel {
|
|||||||
|
|
||||||
List<User> customers = [];
|
List<User> customers = [];
|
||||||
List<User> invitations = [];
|
List<User> invitations = [];
|
||||||
StreamSubscription<QuerySnapshot> customerListener;
|
late StreamSubscription<QuerySnapshot?> customerListener;
|
||||||
StreamSubscription<QuerySnapshot> invitationListener;
|
late StreamSubscription<QuerySnapshot?> invitationListener;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void privilegeChanged() {
|
void privilegeChanged() {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@@ -20,7 +20,7 @@ import 'package:provider/provider.dart';
|
|||||||
import '../main/util.dart';
|
import '../main/util.dart';
|
||||||
|
|
||||||
class FcsShipmentEditor extends StatefulWidget {
|
class FcsShipmentEditor extends StatefulWidget {
|
||||||
final FcsShipment shipment;
|
final FcsShipment? shipment;
|
||||||
FcsShipmentEditor({this.shipment});
|
FcsShipmentEditor({this.shipment});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -40,7 +40,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
|
|
||||||
FcsShipment _shipment = new FcsShipment();
|
FcsShipment _shipment = new FcsShipment();
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
String _currentShipmentType;
|
String? _currentShipmentType;
|
||||||
bool _isNew = false;
|
bool _isNew = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -48,7 +48,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
_isNew = widget.shipment == null;
|
_isNew = widget.shipment == null;
|
||||||
if (widget.shipment != null) {
|
if (widget.shipment != null) {
|
||||||
_shipment = widget.shipment;
|
_shipment = widget.shipment!;
|
||||||
_shipmentNumberController.text = _shipment.shipmentNumber;
|
_shipmentNumberController.text = _shipment.shipmentNumber;
|
||||||
_cutoffDateController.text = dateFormatter.format(_shipment.cutoffDate);
|
_cutoffDateController.text = dateFormatter.format(_shipment.cutoffDate);
|
||||||
_arrivalDateController.text = dateFormatter.format(_shipment.arrivalDate);
|
_arrivalDateController.text = dateFormatter.format(_shipment.arrivalDate);
|
||||||
@@ -149,7 +149,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
items: mainModel.setting.shipmentTypes
|
items: mainModel.setting.shipmentTypes
|
||||||
.map((e) => DropdownMenuItem(child: Text(e), value: e))
|
.map((e) => DropdownMenuItem(child: Text(e), value: e))
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (selected) => {
|
onChanged: (String? selected) => {
|
||||||
setState(() {
|
setState(() {
|
||||||
_currentShipmentType = selected;
|
_currentShipmentType = selected;
|
||||||
})
|
})
|
||||||
@@ -188,7 +188,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
FcsShipment fcsShipment = FcsShipment();
|
FcsShipment fcsShipment = FcsShipment();
|
||||||
fcsShipment.id = _shipment.id;
|
fcsShipment.id = _shipment.id;
|
||||||
fcsShipment.shipmentNumber = _shipmentNumberController.text;
|
fcsShipment.shipmentNumber = _shipmentNumberController.text;
|
||||||
fcsShipment.shipType = _currentShipmentType;
|
fcsShipment.shipType = _currentShipmentType!;
|
||||||
fcsShipment.consignee = _consigneeController.text;
|
fcsShipment.consignee = _consigneeController.text;
|
||||||
fcsShipment.port = _portController.text;
|
fcsShipment.port = _portController.text;
|
||||||
fcsShipment.destination = _destinationController.text;
|
fcsShipment.destination = _destinationController.text;
|
||||||
@@ -197,9 +197,9 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
var arrivalDate = _arrivalDateController.text;
|
var arrivalDate = _arrivalDateController.text;
|
||||||
// var depDate = _departureDateControler.text;
|
// var depDate = _departureDateControler.text;
|
||||||
fcsShipment.cutoffDate =
|
fcsShipment.cutoffDate =
|
||||||
cutoffDate == "" ? null : dateFormatter.parse(cutoffDate);
|
(cutoffDate == "" ? null : dateFormatter.parse(cutoffDate))!;
|
||||||
fcsShipment.arrivalDate =
|
fcsShipment.arrivalDate =
|
||||||
arrivalDate == "" ? null : dateFormatter.parse(arrivalDate);
|
(arrivalDate == "" ? null : dateFormatter.parse(arrivalDate))!;
|
||||||
// fcsShipment.departureDate =
|
// fcsShipment.departureDate =
|
||||||
// depDate == "" ? null : dateFormatter.parse(depDate);
|
// depDate == "" ? null : dateFormatter.parse(depDate);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -288,7 +288,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
_currentShipmentType != mainModel.setting.shipmentTypes[0];
|
_currentShipmentType != mainModel.setting.shipmentTypes[0];
|
||||||
} else {
|
} else {
|
||||||
FcsShipment fcsShipment = _getPayload();
|
FcsShipment fcsShipment = _getPayload();
|
||||||
return widget.shipment.isChangedForEdit(fcsShipment);
|
return widget.shipment!.isChangedForEdit(fcsShipment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import 'package:fcs/pages/widgets/popupmenu.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@@ -19,7 +19,7 @@ import 'package:provider/provider.dart';
|
|||||||
import 'fcs_shipment_editor.dart';
|
import 'fcs_shipment_editor.dart';
|
||||||
|
|
||||||
class FcsShipmentInfo extends StatefulWidget {
|
class FcsShipmentInfo extends StatefulWidget {
|
||||||
final FcsShipment fcsShipment;
|
final FcsShipment? fcsShipment;
|
||||||
FcsShipmentInfo({this.fcsShipment});
|
FcsShipmentInfo({this.fcsShipment});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -28,7 +28,7 @@ class FcsShipmentInfo extends StatefulWidget {
|
|||||||
|
|
||||||
class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||||
FcsShipment _fcsShipment;
|
FcsShipment? _fcsShipment;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
TextEditingController _shipmentNumberController = new TextEditingController();
|
TextEditingController _shipmentNumberController = new TextEditingController();
|
||||||
TextEditingController _cutoffDateController = new TextEditingController();
|
TextEditingController _cutoffDateController = new TextEditingController();
|
||||||
@@ -48,17 +48,17 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_load() {
|
_load() {
|
||||||
_shipmentNumberController.text = _fcsShipment.shipmentNumber;
|
_shipmentNumberController.text = _fcsShipment!.shipmentNumber;
|
||||||
_cutoffDateController.text = dateFormatter.format(_fcsShipment.cutoffDate);
|
_cutoffDateController.text = dateFormatter.format(_fcsShipment!.cutoffDate);
|
||||||
_arrivalDateController.text =
|
_arrivalDateController.text =
|
||||||
dateFormatter.format(_fcsShipment.arrivalDate);
|
dateFormatter.format(_fcsShipment!.arrivalDate);
|
||||||
_departureDateControler.text =
|
_departureDateControler.text =
|
||||||
dateFormatter.format(_fcsShipment.departureDate);
|
dateFormatter.format(_fcsShipment!.departureDate);
|
||||||
_shipmentTypeControler.text = _fcsShipment.shipType;
|
_shipmentTypeControler.text = _fcsShipment!.shipType;
|
||||||
_consigneeController.text = _fcsShipment.consignee;
|
_consigneeController.text = _fcsShipment!.consignee;
|
||||||
_portController.text = _fcsShipment.port;
|
_portController.text = _fcsShipment!.port;
|
||||||
_destinationController.text = _fcsShipment.destination;
|
_destinationController.text = _fcsShipment!.destination;
|
||||||
_statusController.text = _fcsShipment.status;
|
_statusController.text = _fcsShipment!.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -166,7 +166,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
|||||||
portBox,
|
portBox,
|
||||||
destinationBox,
|
destinationBox,
|
||||||
statusBox,
|
statusBox,
|
||||||
_fcsShipment.status == fcs_shipment_confirmed_status
|
_fcsShipment!.status == fcs_shipment_confirmed_status
|
||||||
? shipBtn
|
? shipBtn
|
||||||
: Container(),
|
: Container(),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -182,14 +182,14 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_edit() async {
|
_edit() async {
|
||||||
bool updated = await Navigator.push<bool>(
|
bool? updated = await Navigator.push<bool>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => FcsShipmentEditor(shipment: _fcsShipment)),
|
builder: (context) => FcsShipmentEditor(shipment: _fcsShipment)),
|
||||||
);
|
);
|
||||||
if (updated ?? false) {
|
if (updated ?? false) {
|
||||||
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
|
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
|
||||||
var f = await shipmentModel.getFcsShipment(_fcsShipment.id);
|
var f = await shipmentModel.getFcsShipment(_fcsShipment!.id);
|
||||||
setState(() {
|
setState(() {
|
||||||
_fcsShipment = f;
|
_fcsShipment = f;
|
||||||
});
|
});
|
||||||
@@ -238,7 +238,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
|||||||
try {
|
try {
|
||||||
FcsShipmentModel fcsShipmentModel =
|
FcsShipmentModel fcsShipmentModel =
|
||||||
Provider.of<FcsShipmentModel>(context, listen: false);
|
Provider.of<FcsShipmentModel>(context, listen: false);
|
||||||
await fcsShipmentModel.ship(_fcsShipment);
|
await fcsShipmentModel.ship(_fcsShipment!);
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
@@ -264,11 +264,11 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
|||||||
} else if (id == 4) {
|
} else if (id == 4) {
|
||||||
reportName = "manifest";
|
reportName = "manifest";
|
||||||
}
|
}
|
||||||
_fcsShipment.reportName = reportName;
|
_fcsShipment!.reportName = reportName;
|
||||||
|
|
||||||
FcsShipmentModel fcsShipmentModel =
|
FcsShipmentModel fcsShipmentModel =
|
||||||
Provider.of<FcsShipmentModel>(context, listen: false);
|
Provider.of<FcsShipmentModel>(context, listen: false);
|
||||||
String url = await fcsShipmentModel.report(_fcsShipment);
|
String url = await fcsShipmentModel.report(_fcsShipment!);
|
||||||
Navigator.of(context).push(CupertinoPageRoute(
|
Navigator.of(context).push(CupertinoPageRoute(
|
||||||
builder: (context) => PDFScreen(
|
builder: (context) => PDFScreen(
|
||||||
title: "",
|
title: "",
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'fcs_shipment_info.dart';
|
import 'fcs_shipment_info.dart';
|
||||||
|
|
||||||
class FcsShipmentListRow extends StatelessWidget {
|
class FcsShipmentListRow extends StatelessWidget {
|
||||||
final FcsShipment shipment;
|
final FcsShipment? shipment;
|
||||||
final dateFormatter = new DateFormat('dd MMM yyyy');
|
final dateFormatter = new DateFormat('dd MMM yyyy');
|
||||||
FcsShipmentListRow({Key key, this.shipment}) : super(key: key);
|
FcsShipmentListRow({Key? key, this.shipment}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -43,9 +43,9 @@ class FcsShipmentListRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
shipment.shipmentNumber == null
|
shipment!.shipmentNumber == null
|
||||||
? ''
|
? ''
|
||||||
: shipment.shipmentNumber,
|
: shipment!.shipmentNumber,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -53,7 +53,7 @@ class FcsShipmentListRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
dateFormatter.format(shipment.cutoffDate),
|
dateFormatter.format(shipment!.cutoffDate),
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.grey),
|
fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
@@ -67,7 +67,7 @@ class FcsShipmentListRow extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
child: getStatus(shipment.status),
|
child: getStatus(shipment!.status),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class BoxAddition extends StatefulWidget {
|
class BoxAddition extends StatefulWidget {
|
||||||
final Carton box;
|
final Carton? box;
|
||||||
BoxAddition({this.box});
|
BoxAddition({this.box});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -23,7 +23,7 @@ class _BoxAdditionState extends State<BoxAddition> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (widget.box != null) {
|
if (widget.box != null) {
|
||||||
_box = widget.box;
|
_box = widget.box!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ class _BoxAdditionState extends State<BoxAddition> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: ListView(children: <Widget>[
|
child: ListView(children: <Widget>[
|
||||||
DropdownButtonFormField(
|
DropdownButtonFormField<Object>(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
labelText: 'Box Number',
|
labelText: 'Box Number',
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ import 'package:flutter/material.dart';
|
|||||||
typedef OnSelect = Function(Carton carton, bool checked);
|
typedef OnSelect = Function(Carton carton, bool checked);
|
||||||
|
|
||||||
class InvoiceCartonTable extends StatelessWidget {
|
class InvoiceCartonTable extends StatelessWidget {
|
||||||
final List<Carton> cartons;
|
final List<Carton>? cartons;
|
||||||
final OnSelect onSelect;
|
final OnSelect? onSelect;
|
||||||
final Rate rate;
|
final Rate? rate;
|
||||||
|
|
||||||
const InvoiceCartonTable({Key key, this.cartons, this.onSelect, this.rate})
|
const InvoiceCartonTable({Key? key, this.cartons, this.onSelect, this.rate})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -36,20 +36,20 @@ class InvoiceCartonTable extends StatelessWidget {
|
|||||||
|
|
||||||
final rows = cartons == null
|
final rows = cartons == null
|
||||||
? [Container()]
|
? [Container()]
|
||||||
: cartons.asMap().entries.map((p) {
|
: cartons!.asMap().entries.map((p) {
|
||||||
return Container(
|
return Container(
|
||||||
color: p.value.isChecked
|
color: p.value.isChecked
|
||||||
? Colors.grey.withOpacity(0.2)
|
? Colors.grey.withOpacity(0.2)
|
||||||
: Colors.grey[50].withOpacity(0.2),
|
: Colors.grey.shade50.withOpacity(0.2),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(
|
bottom: BorderSide(
|
||||||
color: p.key == cartons.length - 1
|
color: p.key == cartons!.length - 1
|
||||||
? Colors.white
|
? Colors.white
|
||||||
: Colors.grey[350],
|
: Colors.grey.shade300,
|
||||||
width: 1),
|
width: 1),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -64,8 +64,8 @@ class InvoiceCartonTable extends StatelessWidget {
|
|||||||
: Checkbox(
|
: Checkbox(
|
||||||
value: p.value.isChecked,
|
value: p.value.isChecked,
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
onChanged: (bool check) {
|
onChanged: (bool? check) {
|
||||||
if (onSelect != null) onSelect(p.value, check);
|
if (onSelect != null) onSelect!(p.value, check!);
|
||||||
}),
|
}),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -82,15 +82,15 @@ class InvoiceCartonTable extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
new Text(
|
new Text(
|
||||||
"${p.value?.length ?? ""} x ${p.value?.width ?? ""} x ${p.value?.height ?? ""}",
|
"${p.value.length} x ${p.value.width} x ${p.value.height}",
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
new Text(
|
new Text(
|
||||||
"${p.value?.getShipmentWeight(rate.volumetricRatio)?.toStringAsFixed(2) ?? "0"} lb",
|
"${p.value.getShipmentWeight(rate!.volumetricRatio).toStringAsFixed(2)} lb",
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
new Text(
|
new Text(
|
||||||
"${p.value?.actualWeight?.toStringAsFixed(2) ?? "0"} lb (Actual)",
|
"${p.value.actualWeight.toStringAsFixed(2)} lb (Actual)",
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class InvoiceDiscountList extends StatelessWidget {
|
class InvoiceDiscountList extends StatelessWidget {
|
||||||
final List<Discount> discounts;
|
final List<Discount>? discounts;
|
||||||
|
|
||||||
const InvoiceDiscountList({
|
const InvoiceDiscountList({
|
||||||
Key key,
|
Key? key,
|
||||||
this.discounts,
|
this.discounts,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@@ -63,19 +63,19 @@ class InvoiceDiscountList extends StatelessWidget {
|
|||||||
if (discounts == null) {
|
if (discounts == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
var rows = discounts.map((c) {
|
var rows = discounts!.map((c) {
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (value) => Navigator.pop(context, c),
|
onSelectChanged: (value) => Navigator.pop(context, c),
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(new Text(
|
MyDataCell(new Text(
|
||||||
c.code ?? "",
|
c.code,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
)),
|
||||||
MyDataCell(
|
MyDataCell(
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Text(c.amount?.toStringAsFixed(2) ?? "0", style: textStyle),
|
Text(c.amount.toStringAsFixed(2), style: textStyle),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -31,15 +31,15 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class InvoiceEditor extends StatefulWidget {
|
class InvoiceEditor extends StatefulWidget {
|
||||||
final Invoice invoice;
|
final Invoice? invoice;
|
||||||
final User customer;
|
final User? customer;
|
||||||
final FcsShipment fcsShipment;
|
final FcsShipment? fcsShipment;
|
||||||
InvoiceEditor({this.invoice, this.customer, this.fcsShipment});
|
InvoiceEditor({this.invoice, this.customer, this.fcsShipment});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -49,10 +49,10 @@ class InvoiceEditor extends StatefulWidget {
|
|||||||
class _InvoiceEditorState extends State<InvoiceEditor> {
|
class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||||
|
|
||||||
Invoice _invoice;
|
Invoice? _invoice;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool _isNew;
|
bool _isNew = false;
|
||||||
User _user;
|
User? _user;
|
||||||
|
|
||||||
bool _showCartons = false;
|
bool _showCartons = false;
|
||||||
@override
|
@override
|
||||||
@@ -91,12 +91,12 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
_loadCartons() async {
|
_loadCartons() async {
|
||||||
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
|
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||||
List<Carton> cartons = await cartonModel.getCartonsForInvoice(
|
List<Carton> cartons = await cartonModel.getCartonsForInvoice(
|
||||||
widget.fcsShipment.id, widget.customer.id);
|
widget.fcsShipment!.id, widget.customer!.id);
|
||||||
cartons.forEach((c) {
|
cartons.forEach((c) {
|
||||||
c.isChecked = true;
|
c.isChecked = true;
|
||||||
});
|
});
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.cartons = cartons;
|
_invoice!.cartons = cartons;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,12 +104,12 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
ShipmentModel shipmentModel =
|
ShipmentModel shipmentModel =
|
||||||
Provider.of<ShipmentModel>(context, listen: false);
|
Provider.of<ShipmentModel>(context, listen: false);
|
||||||
List<Shipment> shipments = await shipmentModel.getShipmentWithHandlingFee(
|
List<Shipment> shipments = await shipmentModel.getShipmentWithHandlingFee(
|
||||||
widget.fcsShipment.id, widget.customer.id);
|
widget.fcsShipment!.id, widget.customer!.id);
|
||||||
shipments.forEach((s) {
|
shipments.forEach((s) {
|
||||||
s.isSelected = true;
|
s.isSelected = true;
|
||||||
});
|
});
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.shipments = shipments;
|
_invoice!.shipments = shipments;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,10 +117,10 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
_loadDiscount() async {
|
_loadDiscount() async {
|
||||||
DiscountModel discountModel =
|
DiscountModel discountModel =
|
||||||
Provider.of<DiscountModel>(context, listen: false);
|
Provider.of<DiscountModel>(context, listen: false);
|
||||||
discounts = await discountModel.getDiscount(widget.customer.id);
|
discounts = await discountModel.getDiscount(widget.customer!.id);
|
||||||
if (discounts != null && discounts.length > 0) {
|
if (discounts != null && discounts.length > 0) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.discount = discounts.first;
|
_invoice!.discount = discounts.first;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
iconData: Icons.av_timer,
|
iconData: Icons.av_timer,
|
||||||
labelTextKey: 'invoice.status');
|
labelTextKey: 'invoice.status');
|
||||||
final cartonTable = InvoiceCartonTable(
|
final cartonTable = InvoiceCartonTable(
|
||||||
cartons: _invoice.cartons,
|
cartons: _invoice!.cartons,
|
||||||
rate: rate,
|
rate: rate,
|
||||||
onSelect: (c, checked) {
|
onSelect: (c, checked) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -157,30 +157,30 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
final paymentTypesBox = LocalDropdown<PaymentMethod>(
|
final paymentTypesBox = LocalDropdown<PaymentMethod>(
|
||||||
callback: (v) {
|
callback: (v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.paymentMethod = v;
|
_invoice!.paymentMethod = v;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
labelKey: "invoice.payment_method",
|
labelKey: "invoice.payment_method",
|
||||||
iconData: FontAwesome.money,
|
iconData: FontAwesome.money,
|
||||||
display: (u) => u.name,
|
display: (u) => u.name,
|
||||||
selectedValue: _invoice.paymentMethod,
|
selectedValue: _invoice!.paymentMethod,
|
||||||
values: paymentMethodModel.paymentMethods,
|
values: paymentMethodModel.paymentMethods,
|
||||||
);
|
);
|
||||||
final invoiceTableBox = InvoiceTable(
|
final invoiceTableBox = InvoiceTable(
|
||||||
invoice: _invoice,
|
invoice: _invoice!,
|
||||||
rate: rate,
|
rate: rate,
|
||||||
deliveryFeeSelected: (selected) {
|
deliveryFeeSelected: (selected) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
_invoice.deliveryFee = rate.deliveryFee;
|
_invoice!.deliveryFee = rate.deliveryFee;
|
||||||
} else {
|
} else {
|
||||||
_invoice.deliveryFee = 0;
|
_invoice!.deliveryFee = 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
discountSelected: (discount) {
|
discountSelected: (discount) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.discount = discount;
|
_invoice!.discount = discount;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onRemove: (i) {
|
onRemove: (i) {
|
||||||
@@ -189,12 +189,12 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
}
|
}
|
||||||
if (i.invoiceDataType == InvoiceDataType.DiscountDataType) {
|
if (i.invoiceDataType == InvoiceDataType.DiscountDataType) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.discount = null;
|
_invoice!.discount = new Discount();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (i.invoiceDataType == InvoiceDataType.DeliveryFeeType) {
|
if (i.invoiceDataType == InvoiceDataType.DeliveryFeeType) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.deliveryFee = 0;
|
_invoice!.deliveryFee = 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (i.invoiceDataType == InvoiceDataType.HandlingFeeType) {
|
if (i.invoiceDataType == InvoiceDataType.HandlingFeeType) {
|
||||||
@@ -254,7 +254,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
Shipment shipment = await Navigator.of(context).push(
|
Shipment shipment = await Navigator.of(context).push(
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
InvoiceHandlingFeeList(shipments: _invoice.shipments)));
|
InvoiceHandlingFeeList(shipments: _invoice!.shipments)));
|
||||||
_addShipment(shipment);
|
_addShipment(shipment);
|
||||||
} else if (p.id == 3) {
|
} else if (p.id == 3) {
|
||||||
Discount discount =
|
Discount discount =
|
||||||
@@ -264,12 +264,12 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
)));
|
)));
|
||||||
if (discount != null) {
|
if (discount != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.discount = discount;
|
_invoice!.discount = discount;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (p.id == 4) {
|
} else if (p.id == 4) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.deliveryFee = rate.deliveryFee;
|
_invoice!.deliveryFee = rate.deliveryFee;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -281,7 +281,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(dateFormatter.format(_invoice.invoiceDate)),
|
Text(dateFormatter.format(_invoice!.invoiceDate)),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
@@ -371,8 +371,8 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
_addCustom(CustomDuty customDuty) {
|
_addCustom(CustomDuty customDuty) {
|
||||||
if (customDuty == null) return;
|
if (customDuty == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.customDuties.remove(customDuty);
|
_invoice!.customDuties.remove(customDuty);
|
||||||
_invoice.customDuties.add(customDuty);
|
_invoice!.customDuties.add(customDuty);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,8 +380,8 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
if (shipment == null) return;
|
if (shipment == null) return;
|
||||||
shipment.isSelected = true;
|
shipment.isSelected = true;
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.shipments.remove(shipment);
|
_invoice!.shipments.remove(shipment);
|
||||||
_invoice.shipments.add(shipment);
|
_invoice!.shipments.add(shipment);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,30 +389,30 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
if (shipment == null) return;
|
if (shipment == null) return;
|
||||||
shipment.isSelected = false;
|
shipment.isSelected = false;
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.shipments.remove(shipment);
|
_invoice!.shipments.remove(shipment);
|
||||||
_invoice.shipments.add(shipment);
|
_invoice!.shipments.add(shipment);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_removeCustom(CustomDuty customDuty) {
|
_removeCustom(CustomDuty customDuty) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.customDuties.remove(customDuty);
|
_invoice!.customDuties.remove(customDuty);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_save() async {
|
_save() async {
|
||||||
var rateModel = Provider.of<ShipmentRateModel>(context, listen: false);
|
var rateModel = Provider.of<ShipmentRateModel>(context, listen: false);
|
||||||
double amount = _invoice.getNetAmount(rateModel.rate);
|
double amount = _invoice!.getNetAmount(rateModel.rate);
|
||||||
if (_invoice.paymentMethod == null) {
|
if (_invoice!.paymentMethod == null) {
|
||||||
showMsgDialog(context, "Error", "Payment method required");
|
showMsgDialog(context, "Error", "Payment method required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<CargoType> cargoTypes = _invoice.getCargoTypes(rateModel.rate);
|
List<CargoType> cargoTypes = _invoice!.getCargoTypes(rateModel.rate);
|
||||||
if (cargoTypes == null || cargoTypes.length == 0) {
|
if (cargoTypes == null || cargoTypes.length == 0) {
|
||||||
showMsgDialog(context, "Error", "Expected at least one cargo type");
|
showMsgDialog(context, "Error", "Expected at least one cargo type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((amount ?? 0) <= 0) {
|
if ((amount ) <= 0) {
|
||||||
showMsgDialog(context, "Error", "Expected positive amount");
|
showMsgDialog(context, "Error", "Expected positive amount");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -428,18 +428,18 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
Invoice invoice = Invoice();
|
Invoice invoice = Invoice();
|
||||||
invoice.cargoTypes = cargoTypes;
|
invoice.cargoTypes = cargoTypes;
|
||||||
invoice.amount = amount;
|
invoice.amount = amount;
|
||||||
invoice.handlingFee = _invoice.getHandlingFee();
|
invoice.handlingFee = _invoice!.getHandlingFee();
|
||||||
invoice.cartons = _invoice.cartons.where((c) => c.isChecked).toList();
|
invoice.cartons = _invoice!.cartons.where((c) => c.isChecked).toList();
|
||||||
invoice.shipments =
|
invoice.shipments =
|
||||||
_invoice.shipments.where((s) => s.isSelected).toList();
|
_invoice!.shipments.where((s) => s.isSelected).toList();
|
||||||
invoice.discount = _invoice.discount;
|
invoice.discount = _invoice!.discount;
|
||||||
invoice.deliveryFee = _invoice.deliveryFee;
|
invoice.deliveryFee = _invoice!.deliveryFee;
|
||||||
|
|
||||||
invoice.userID = widget.customer.id;
|
invoice.userID = widget.customer!.id;
|
||||||
invoice.fcsShipmentID = widget.fcsShipment.id;
|
invoice.fcsShipmentID = widget.fcsShipment!.id;
|
||||||
invoice.invoiceDate = _invoice.invoiceDate;
|
invoice.invoiceDate = _invoice!.invoiceDate;
|
||||||
invoice.paymentMethod = _invoice.paymentMethod;
|
invoice.paymentMethod = _invoice!.paymentMethod;
|
||||||
invoice.customDuties = _invoice.customDuties;
|
invoice.customDuties = _invoice!.customDuties;
|
||||||
|
|
||||||
await invoiceModel.createInvoice(invoice);
|
await invoiceModel.createInvoice(invoice);
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ typedef OnAdd(Shipment shipment);
|
|||||||
typedef OnRemove(Shipment shipment);
|
typedef OnRemove(Shipment shipment);
|
||||||
|
|
||||||
class InvoiceHandlingFeeList extends StatelessWidget {
|
class InvoiceHandlingFeeList extends StatelessWidget {
|
||||||
final List<Shipment> shipments;
|
final List<Shipment>? shipments;
|
||||||
final OnAdd onAdd;
|
final OnAdd? onAdd;
|
||||||
final OnRemove onRemove;
|
final OnRemove? onRemove;
|
||||||
|
|
||||||
const InvoiceHandlingFeeList(
|
const InvoiceHandlingFeeList(
|
||||||
{Key key, this.shipments, this.onAdd, this.onRemove})
|
{Key? key, this.shipments, this.onAdd, this.onRemove})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -67,20 +67,19 @@ class InvoiceHandlingFeeList extends StatelessWidget {
|
|||||||
if (shipments == null) {
|
if (shipments == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
var rows = shipments.map((c) {
|
var rows = shipments!.map((c) {
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (value) => Navigator.pop(context, c),
|
onSelectChanged: (value) => Navigator.pop(context, c),
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(new Text(
|
MyDataCell(new Text(
|
||||||
c.shipmentNumber ?? "",
|
c.shipmentNumber,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
)),
|
||||||
MyDataCell(
|
MyDataCell(
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Text(c.handlingFee?.toStringAsFixed(2) ?? "0",
|
Text(c.handlingFee.toStringAsFixed(2), style: textStyle),
|
||||||
style: textStyle),
|
|
||||||
onRemove == null
|
onRemove == null
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width: 50,
|
width: 50,
|
||||||
@@ -91,7 +90,7 @@ class InvoiceHandlingFeeList extends StatelessWidget {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (onRemove != null) onRemove(c);
|
if (onRemove != null) onRemove!(c);
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import 'package:intl/intl.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class InvoiceCustomerList extends StatefulWidget {
|
class InvoiceCustomerList extends StatefulWidget {
|
||||||
final FcsShipment fcsShipment;
|
final FcsShipment? fcsShipment;
|
||||||
|
|
||||||
const InvoiceCustomerList({Key key, this.fcsShipment}) : super(key: key);
|
const InvoiceCustomerList({Key? key, this.fcsShipment}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_InvoiceCustomerListState createState() => _InvoiceCustomerListState();
|
_InvoiceCustomerListState createState() => _InvoiceCustomerListState();
|
||||||
@@ -33,7 +33,7 @@ class _InvoiceCustomerListState extends State<InvoiceCustomerList> {
|
|||||||
_load() async {
|
_load() async {
|
||||||
CustomerModel customerModel =
|
CustomerModel customerModel =
|
||||||
Provider.of<CustomerModel>(context, listen: false);
|
Provider.of<CustomerModel>(context, listen: false);
|
||||||
var users = await customerModel.getInvoiceUsers(widget.fcsShipment.id);
|
var users = await customerModel.getInvoiceUsers(widget.fcsShipment!.id);
|
||||||
setState(() {
|
setState(() {
|
||||||
_users = users;
|
_users = users;
|
||||||
});
|
});
|
||||||
@@ -88,7 +88,7 @@ class _InvoiceCustomerListState extends State<InvoiceCustomerList> {
|
|||||||
customer: customer,
|
customer: customer,
|
||||||
fcsShipment: widget.fcsShipment,
|
fcsShipment: widget.fcsShipment,
|
||||||
)));
|
)));
|
||||||
if (created ?? false) {
|
if (created) {
|
||||||
_load();
|
_load();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import 'package:intl/intl.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class InvoiceInfo extends StatefulWidget {
|
class InvoiceInfo extends StatefulWidget {
|
||||||
final Invoice invoice;
|
final Invoice? invoice;
|
||||||
final bool forCustomer;
|
final bool? forCustomer;
|
||||||
InvoiceInfo({this.invoice, this.forCustomer});
|
InvoiceInfo({this.invoice, this.forCustomer});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -31,15 +31,15 @@ class InvoiceInfo extends StatefulWidget {
|
|||||||
class _InvoiceInfoState extends State<InvoiceInfo> {
|
class _InvoiceInfoState extends State<InvoiceInfo> {
|
||||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||||
|
|
||||||
Invoice _invoice;
|
Invoice? _invoice;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
|
||||||
bool _showCartons = false;
|
bool _showCartons = false;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_invoice = widget.invoice;
|
_invoice = widget.invoice!;
|
||||||
_invoice.shipments?.forEach((s) {
|
_invoice!.shipments.forEach((s) {
|
||||||
s.isSelected = true;
|
s.isSelected = true;
|
||||||
});
|
});
|
||||||
_loadCartons();
|
_loadCartons();
|
||||||
@@ -54,7 +54,7 @@ class _InvoiceInfoState extends State<InvoiceInfo> {
|
|||||||
cartons.add(_carton);
|
cartons.add(_carton);
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.cartons = cartons;
|
_invoice!.cartons = cartons;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,31 +65,31 @@ class _InvoiceInfoState extends State<InvoiceInfo> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
bool isCanceled = _invoice.status == invoice_cancel_status;
|
bool isCanceled = _invoice!.status == invoice_cancel_status;
|
||||||
bool isPaid = _invoice.status == invoice_paid_status;
|
bool isPaid = _invoice!.status == invoice_paid_status;
|
||||||
var rateModel = Provider.of<ShipmentRateModel>(context);
|
var rateModel = Provider.of<ShipmentRateModel>(context);
|
||||||
var rate = rateModel.rate;
|
var rate = rateModel.rate;
|
||||||
|
|
||||||
final cartonTable = InvoiceCartonTable(
|
final cartonTable = InvoiceCartonTable(
|
||||||
cartons: _invoice.cartons,
|
cartons: _invoice!.cartons,
|
||||||
rate: rate,
|
rate: rate,
|
||||||
);
|
);
|
||||||
|
|
||||||
final invoiceTableBox = InvoiceTable(
|
final invoiceTableBox = InvoiceTable(
|
||||||
invoice: _invoice,
|
invoice: _invoice!,
|
||||||
rate: rate,
|
rate: rate,
|
||||||
deliveryFeeSelected: (selected) {
|
deliveryFeeSelected: (selected) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
_invoice.deliveryFee = rate.deliveryFee;
|
_invoice!.deliveryFee = rate.deliveryFee;
|
||||||
} else {
|
} else {
|
||||||
_invoice.deliveryFee = 0;
|
_invoice!.deliveryFee = 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
discountSelected: (discount) {
|
discountSelected: (discount) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice.discount = discount;
|
_invoice!.discount = discount;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -118,7 +118,7 @@ class _InvoiceInfoState extends State<InvoiceInfo> {
|
|||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(dateFormatter.format(_invoice.invoiceDate)),
|
Text(dateFormatter.format(_invoice!.invoiceDate)),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 5,
|
height: 5,
|
||||||
),
|
),
|
||||||
@@ -140,7 +140,7 @@ class _InvoiceInfoState extends State<InvoiceInfo> {
|
|||||||
);
|
);
|
||||||
final paymentMethodBox = DisplayText(
|
final paymentMethodBox = DisplayText(
|
||||||
labelTextKey: "invoice.payment_method",
|
labelTextKey: "invoice.payment_method",
|
||||||
text: _invoice.paymentMethod.name,
|
text: _invoice!.paymentMethod.name,
|
||||||
);
|
);
|
||||||
|
|
||||||
final cancelBtn = LocalButton(
|
final cancelBtn = LocalButton(
|
||||||
@@ -166,7 +166,7 @@ class _InvoiceInfoState extends State<InvoiceInfo> {
|
|||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
getInvoiceStatus(context, _invoice),
|
getInvoiceStatus(context, _invoice!),
|
||||||
headerBox,
|
headerBox,
|
||||||
_showCartons ? cartonTable : Container(),
|
_showCartons ? cartonTable : Container(),
|
||||||
_showCartons
|
_showCartons
|
||||||
@@ -183,7 +183,7 @@ class _InvoiceInfoState extends State<InvoiceInfo> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
isCanceled || isPaid || widget.forCustomer
|
isCanceled || isPaid || widget.forCustomer!
|
||||||
? Container()
|
? Container()
|
||||||
: cancelBtn,
|
: cancelBtn,
|
||||||
],
|
],
|
||||||
@@ -206,7 +206,7 @@ class _InvoiceInfoState extends State<InvoiceInfo> {
|
|||||||
InvoiceModel invoiceModel =
|
InvoiceModel invoiceModel =
|
||||||
Provider.of<InvoiceModel>(context, listen: false);
|
Provider.of<InvoiceModel>(context, listen: false);
|
||||||
|
|
||||||
await invoiceModel.cancelInvoice(_invoice);
|
await invoiceModel.cancelInvoice(_invoice!);
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import 'package:provider/provider.dart';
|
|||||||
import 'invoice_list_row.dart';
|
import 'invoice_list_row.dart';
|
||||||
|
|
||||||
class InvoiceList extends StatefulWidget {
|
class InvoiceList extends StatefulWidget {
|
||||||
final bool forCustomer;
|
final bool? forCustomer;
|
||||||
|
|
||||||
const InvoiceList({Key key, this.forCustomer}) : super(key: key);
|
const InvoiceList({Key? key, this.forCustomer}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_InvoiceListState createState() => _InvoiceListState();
|
_InvoiceListState createState() => _InvoiceListState();
|
||||||
}
|
}
|
||||||
@@ -29,13 +29,13 @@ class _InvoiceListState extends State<InvoiceList> {
|
|||||||
_controller.addListener(() async {
|
_controller.addListener(() async {
|
||||||
if (_controller.position.pixels == _controller.position.maxScrollExtent) {
|
if (_controller.position.pixels == _controller.position.maxScrollExtent) {
|
||||||
Provider.of<InvoiceModel>(context, listen: false)
|
Provider.of<InvoiceModel>(context, listen: false)
|
||||||
.loadMore(isCustomer: widget.forCustomer);
|
.loadMore(isCustomer: widget.forCustomer!);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
InvoiceModel invoiceModel =
|
InvoiceModel invoiceModel =
|
||||||
Provider.of<InvoiceModel>(context, listen: false);
|
Provider.of<InvoiceModel>(context, listen: false);
|
||||||
invoiceModel.initData(widget.forCustomer, true, false);
|
invoiceModel.initData(widget.forCustomer!, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -66,13 +66,13 @@ class _InvoiceListState extends State<InvoiceList> {
|
|||||||
invoiceModel.selectedIndex = p.id;
|
invoiceModel.selectedIndex = p.id;
|
||||||
if (p.id == 2) {
|
if (p.id == 2) {
|
||||||
Provider.of<InvoiceModel>(context, listen: false)
|
Provider.of<InvoiceModel>(context, listen: false)
|
||||||
.initData(widget.forCustomer, false, true);
|
.initData(widget.forCustomer!, false, true);
|
||||||
} else if (p.id == 3) {
|
} else if (p.id == 3) {
|
||||||
Provider.of<InvoiceModel>(context, listen: false)
|
Provider.of<InvoiceModel>(context, listen: false)
|
||||||
.initData(widget.forCustomer, true, false);
|
.initData(widget.forCustomer!, true, false);
|
||||||
} else {
|
} else {
|
||||||
Provider.of<InvoiceModel>(context, listen: false)
|
Provider.of<InvoiceModel>(context, listen: false)
|
||||||
.initData(widget.forCustomer, true, false);
|
.initData(widget.forCustomer!, true, false);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -93,7 +93,7 @@ class _InvoiceListState extends State<InvoiceList> {
|
|||||||
color: Colors.white, fontSize: 20),
|
color: Colors.white, fontSize: 20),
|
||||||
actions: <Widget>[popupMenu],
|
actions: <Widget>[popupMenu],
|
||||||
),
|
),
|
||||||
floatingActionButton: widget.forCustomer
|
floatingActionButton: widget.forCustomer!
|
||||||
? null
|
? null
|
||||||
: FloatingActionButton.extended(
|
: FloatingActionButton.extended(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import '../widgets/pdf_screen.dart';
|
|||||||
|
|
||||||
class InvoiceListRow extends StatelessWidget {
|
class InvoiceListRow extends StatelessWidget {
|
||||||
final dateFormatter = new DateFormat('dd MMM yyyy');
|
final dateFormatter = new DateFormat('dd MMM yyyy');
|
||||||
final Invoice invoice;
|
final Invoice? invoice;
|
||||||
final bool forCustomer;
|
final bool? forCustomer;
|
||||||
InvoiceListRow({Key key, this.invoice, this.forCustomer}) : super(key: key);
|
InvoiceListRow({Key? key, this.invoice, this.forCustomer}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -22,8 +22,8 @@ class InvoiceListRow extends StatelessWidget {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).push(CupertinoPageRoute(
|
Navigator.of(context).push(CupertinoPageRoute(
|
||||||
builder: (context) => PDFScreen(
|
builder: (context) => PDFScreen(
|
||||||
title: invoice.invoiceNumber,
|
title: invoice!.invoiceNumber,
|
||||||
url: invoice.invoiceURL,
|
url: invoice!.invoiceURL,
|
||||||
)));
|
)));
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -48,17 +48,17 @@ class InvoiceListRow extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Text(
|
new Text(
|
||||||
invoice.invoiceNumber ?? "",
|
invoice!.invoiceNumber ?? "",
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
new Text(
|
new Text(
|
||||||
invoice.status ?? "",
|
invoice!.status ?? "",
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 13.0, color: primaryColor),
|
fontSize: 13.0, color: primaryColor),
|
||||||
),
|
),
|
||||||
new Text(
|
new Text(
|
||||||
dateFormatter.format(invoice.invoiceDate),
|
dateFormatter.format(invoice!.invoiceDate),
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.grey),
|
fontSize: 15.0, color: Colors.grey),
|
||||||
)
|
)
|
||||||
@@ -70,7 +70,7 @@ class InvoiceListRow extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
invoice.status == invoice_issued_status
|
invoice!.status == invoice_issued_status
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.only(left: 10.0),
|
padding: const EdgeInsets.only(left: 10.0),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import 'package:fcs/domain/entities/fcs_shipment.dart';
|
|||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import '../main/util.dart';
|
import '../main/util.dart';
|
||||||
@@ -11,8 +11,8 @@ import 'invoice_customer_list.dart';
|
|||||||
typedef OnSelect(FcsShipment fcsShipment);
|
typedef OnSelect(FcsShipment fcsShipment);
|
||||||
|
|
||||||
class InvoiceShipmentListRow extends StatefulWidget {
|
class InvoiceShipmentListRow extends StatefulWidget {
|
||||||
final OnSelect onSelect;
|
final OnSelect? onSelect;
|
||||||
final FcsShipment fcsShipment;
|
final FcsShipment? fcsShipment;
|
||||||
const InvoiceShipmentListRow({this.fcsShipment, this.onSelect});
|
const InvoiceShipmentListRow({this.fcsShipment, this.onSelect});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -28,7 +28,7 @@ class _InvoiceShipmentListRowState extends State<InvoiceShipmentListRow> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (widget.fcsShipment != null) {
|
if (widget.fcsShipment != null) {
|
||||||
_fcsShipment = widget.fcsShipment;
|
_fcsShipment = widget.fcsShipment!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ class _InvoiceShipmentListRowState extends State<InvoiceShipmentListRow> {
|
|||||||
padding: EdgeInsets.only(left: 15, right: 15),
|
padding: EdgeInsets.only(left: 15, right: 15),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (widget.onSelect != null) widget.onSelect(widget.fcsShipment);
|
if (widget.onSelect != null) widget.onSelect!(widget.fcsShipment!);
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ enum InvoiceDataType {
|
|||||||
|
|
||||||
class InvoiceTableRow {
|
class InvoiceTableRow {
|
||||||
final dynamic data;
|
final dynamic data;
|
||||||
final String id;
|
final String? id;
|
||||||
final InvoiceDataType invoiceDataType;
|
final InvoiceDataType? invoiceDataType;
|
||||||
final String desc;
|
final String? desc;
|
||||||
final String rate;
|
final String? rate;
|
||||||
final String amount;
|
final String? amount;
|
||||||
|
|
||||||
InvoiceTableRow(
|
InvoiceTableRow(
|
||||||
{this.id,
|
{this.id,
|
||||||
@@ -39,14 +39,14 @@ class InvoiceTableRow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class InvoiceTable extends StatelessWidget {
|
class InvoiceTable extends StatelessWidget {
|
||||||
final Invoice invoice;
|
final Invoice? invoice;
|
||||||
final Rate rate;
|
final Rate? rate;
|
||||||
final OnDiscountSelected discountSelected;
|
final OnDiscountSelected? discountSelected;
|
||||||
final OnDeliveryFeeSelected deliveryFeeSelected;
|
final OnDeliveryFeeSelected? deliveryFeeSelected;
|
||||||
final OnRemove onRemove;
|
final OnRemove? onRemove;
|
||||||
|
|
||||||
const InvoiceTable(
|
const InvoiceTable(
|
||||||
{Key key,
|
{Key? key,
|
||||||
this.invoice,
|
this.invoice,
|
||||||
this.discountSelected,
|
this.discountSelected,
|
||||||
this.deliveryFeeSelected,
|
this.deliveryFeeSelected,
|
||||||
@@ -61,16 +61,16 @@ class InvoiceTable extends StatelessWidget {
|
|||||||
List<InvoiceTableRow> getTableRows() {
|
List<InvoiceTableRow> getTableRows() {
|
||||||
List<InvoiceTableRow> tableRows = [];
|
List<InvoiceTableRow> tableRows = [];
|
||||||
// add cargo types
|
// add cargo types
|
||||||
List<CargoType> _cargoTypes = invoice.getCargoTypes(rate) ?? [];
|
List<CargoType> _cargoTypes = invoice!.getCargoTypes(rate!) ?? [];
|
||||||
_cargoTypes.forEach((c) {
|
_cargoTypes.forEach((c) {
|
||||||
tableRows.add(InvoiceTableRow(
|
tableRows.add(InvoiceTableRow(
|
||||||
invoiceDataType: InvoiceDataType.CargoDataType,
|
invoiceDataType: InvoiceDataType.CargoDataType,
|
||||||
desc: c.name,
|
desc: c.name,
|
||||||
rate:
|
rate:
|
||||||
"${c.calWeight.toStringAsFixed(2)} x ${c.calRate.toStringAsFixed(2)}",
|
"${c.calWeight!.toStringAsFixed(2)} x ${c.calRate!.toStringAsFixed(2)}",
|
||||||
amount: "${c.calAmount.toStringAsFixed(2)}"));
|
amount: "${c.calAmount.toStringAsFixed(2)}"));
|
||||||
});
|
});
|
||||||
invoice.shipments.where((ss) => (ss.isSelected ?? false)).forEach((s) {
|
invoice!.shipments.where((ss) => (ss.isSelected ?? false)).forEach((s) {
|
||||||
tableRows.add(InvoiceTableRow(
|
tableRows.add(InvoiceTableRow(
|
||||||
data: s,
|
data: s,
|
||||||
invoiceDataType: InvoiceDataType.HandlingFeeType,
|
invoiceDataType: InvoiceDataType.HandlingFeeType,
|
||||||
@@ -79,7 +79,7 @@ class InvoiceTable extends StatelessWidget {
|
|||||||
amount: "${s.handlingFee.toStringAsFixed(2)}"));
|
amount: "${s.handlingFee.toStringAsFixed(2)}"));
|
||||||
});
|
});
|
||||||
// // add custom fee
|
// // add custom fee
|
||||||
invoice.customDuties.forEach((c) {
|
invoice!.customDuties.forEach((c) {
|
||||||
tableRows.add(InvoiceTableRow(
|
tableRows.add(InvoiceTableRow(
|
||||||
data: c,
|
data: c,
|
||||||
invoiceDataType: InvoiceDataType.CustomFeeDataType,
|
invoiceDataType: InvoiceDataType.CustomFeeDataType,
|
||||||
@@ -89,18 +89,18 @@ class InvoiceTable extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
// // add delivery fee
|
// // add delivery fee
|
||||||
tableRows.add(InvoiceTableRow(
|
tableRows.add(InvoiceTableRow(
|
||||||
data: invoice.deliveryFee == null || invoice.deliveryFee == 0
|
data: invoice!.deliveryFee == null || invoice!.deliveryFee == 0
|
||||||
? null
|
? null
|
||||||
: invoice.deliveryFee,
|
: invoice!.deliveryFee,
|
||||||
invoiceDataType: InvoiceDataType.DeliveryFeeType,
|
invoiceDataType: InvoiceDataType.DeliveryFeeType,
|
||||||
desc: "Delivery fee",
|
desc: "Delivery fee",
|
||||||
rate: "",
|
rate: "",
|
||||||
amount: "${invoice?.deliveryFee?.toStringAsFixed(2) ?? '0'}"));
|
amount: "${invoice?.deliveryFee?.toStringAsFixed(2) ?? '0'}"));
|
||||||
|
|
||||||
// // add discounts
|
// // add discounts
|
||||||
if (invoice.discount != null) {
|
if (invoice!.discount != null) {
|
||||||
tableRows.add(InvoiceTableRow(
|
tableRows.add(InvoiceTableRow(
|
||||||
data: invoice.discount,
|
data: invoice!.discount,
|
||||||
invoiceDataType: InvoiceDataType.DiscountDataType,
|
invoiceDataType: InvoiceDataType.DiscountDataType,
|
||||||
desc: "Discount\n${invoice?.discount?.code ?? ""}",
|
desc: "Discount\n${invoice?.discount?.code ?? ""}",
|
||||||
rate: "",
|
rate: "",
|
||||||
@@ -132,7 +132,7 @@ class InvoiceTable extends StatelessWidget {
|
|||||||
r.data == null || onRemove == null
|
r.data == null || onRemove == null
|
||||||
? Container()
|
? Container()
|
||||||
: InkWell(
|
: InkWell(
|
||||||
onTap: () => onRemove(r),
|
onTap: () => onRemove!(r),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.remove_circle,
|
Icons.remove_circle,
|
||||||
color: Colors.black45,
|
color: Colors.black45,
|
||||||
@@ -217,7 +217,7 @@ class InvoiceTable extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
SizedBox(width: 20),
|
SizedBox(width: 20),
|
||||||
Text(
|
Text(
|
||||||
'\$ ${invoice.getNetAmount(rate).toStringAsFixed(2)}',
|
'\$ ${invoice!.getNetAmount(rate!).toStringAsFixed(2)}',
|
||||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
|
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import 'package:intl/intl.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class PaymentPage extends StatefulWidget {
|
class PaymentPage extends StatefulWidget {
|
||||||
final Invoice invoice;
|
final Invoice? invoice;
|
||||||
final bool forCustomer;
|
final bool? forCustomer;
|
||||||
PaymentPage({this.invoice, this.forCustomer});
|
PaymentPage({this.invoice, this.forCustomer});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -35,15 +35,15 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
Invoice _invoice = new Invoice();
|
Invoice _invoice = new Invoice();
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
|
||||||
bool isNew;
|
bool isNew = false;
|
||||||
File _file;
|
File? _file;
|
||||||
bool _hasBalance;
|
bool _hasBalance = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_invoice = widget.invoice;
|
_invoice = widget.invoice!;
|
||||||
_hasBalance = widget.invoice.balance > 0;
|
_hasBalance = widget.invoice!.balance > 0;
|
||||||
_loadInvoice();
|
_loadInvoice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
getCustomFeeRows(BuildContext context) {
|
getCustomFeeRows(BuildContext context) {
|
||||||
List<Widget> dataRow = [];
|
List<Widget> dataRow = [];
|
||||||
|
|
||||||
dataRow = _invoice?.payments?.map((p) {
|
dataRow = _invoice.payments.map((p) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(bottom: BorderSide(color: Colors.grey))),
|
border: Border(bottom: BorderSide(color: Colors.grey))),
|
||||||
@@ -165,7 +165,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [Text('\$ ${p.amount}'), Text('${p.status}')],
|
children: [Text('\$ ${p.amount}'), Text('${p.status}')],
|
||||||
))),
|
))),
|
||||||
widget.forCustomer
|
widget.forCustomer!
|
||||||
? Container()
|
? Container()
|
||||||
: Expanded(
|
: Expanded(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -197,8 +197,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
})?.toList() ??
|
}).toList() ;
|
||||||
[];
|
|
||||||
|
|
||||||
dataRow.insert(
|
dataRow.insert(
|
||||||
0,
|
0,
|
||||||
@@ -217,7 +216,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
child: Text('Amount',
|
child: Text('Amount',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(color: Colors.grey))),
|
style: TextStyle(color: Colors.grey))),
|
||||||
widget.forCustomer
|
widget.forCustomer!
|
||||||
? Container()
|
? Container()
|
||||||
: Expanded(
|
: Expanded(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -250,11 +249,11 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'\$ ${widget.invoice.balance.toStringAsFixed(2)}',
|
'\$ ${widget.invoice!.balance.toStringAsFixed(2)}',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold, fontSize: 16.0)))),
|
fontWeight: FontWeight.bold, fontSize: 16.0)))),
|
||||||
widget.forCustomer
|
widget.forCustomer!
|
||||||
? Container()
|
? Container()
|
||||||
: Expanded(
|
: Expanded(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -279,7 +278,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_updatePayment(Payment payment) async {
|
_updatePayment(Payment payment) async {
|
||||||
payment.invoiceID = widget.invoice.id;
|
payment.invoiceID = widget.invoice!.id;
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
@@ -314,7 +313,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
try {
|
try {
|
||||||
InvoiceModel invoiceModel =
|
InvoiceModel invoiceModel =
|
||||||
Provider.of<InvoiceModel>(context, listen: false);
|
Provider.of<InvoiceModel>(context, listen: false);
|
||||||
await invoiceModel.pay(payment, _file);
|
await invoiceModel.pay(payment, _file!);
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import 'package:intl/intl.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class PaymentPageEdit extends StatefulWidget {
|
class PaymentPageEdit extends StatefulWidget {
|
||||||
final Receipt receipt;
|
final Receipt? receipt;
|
||||||
PaymentPageEdit({this.receipt});
|
PaymentPageEdit({this.receipt});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -33,14 +33,14 @@ class _PaymentPageEditState extends State<PaymentPageEdit> {
|
|||||||
|
|
||||||
Receipt _receipt = new Receipt();
|
Receipt _receipt = new Receipt();
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
File _file;
|
File? _file;
|
||||||
|
|
||||||
bool isNew;
|
bool isNew = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
if (widget.receipt != null) {
|
if (widget.receipt != null) {
|
||||||
_receipt = widget.receipt;
|
_receipt = widget.receipt!;
|
||||||
}
|
}
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
@@ -185,11 +185,11 @@ class _PaymentPageEditState extends State<PaymentPageEdit> {
|
|||||||
return initialImage();
|
return initialImage();
|
||||||
} else {
|
} else {
|
||||||
Widget _widget;
|
Widget _widget;
|
||||||
if (widget.receipt.fileUrl == null) {
|
if (widget.receipt!.fileUrl == null) {
|
||||||
_widget = initialImage();
|
_widget = initialImage();
|
||||||
} else {
|
} else {
|
||||||
_widget = InkWell(
|
_widget = InkWell(
|
||||||
child: Image.asset(widget.receipt.fileUrl, fit: BoxFit.cover),
|
child: Image.asset(widget.receipt!.fileUrl, fit: BoxFit.cover),
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -209,13 +209,13 @@ class _PaymentPageEditState extends State<PaymentPageEdit> {
|
|||||||
|
|
||||||
Widget enableUpload(BuildContext context) {
|
Widget enableUpload(BuildContext context) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
child: Image.file(_file, fit: BoxFit.cover),
|
child: Image.file(_file!, fit: BoxFit.cover),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
ShowImage(imageFile: _file, url: null, fileName: 'image')));
|
ShowImage(imageFile: _file!, url: '', fileName: 'image')));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import 'package:fcs/pages/widgets/right_left_page_rout.dart';
|
|||||||
import 'package:fcs/pages/widgets/task_button.dart';
|
import 'package:fcs/pages/widgets/task_button.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
@@ -94,7 +94,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
String notiUserID, notiUserName;
|
late String notiUserID, notiUserName;
|
||||||
_showNotiContent(Map<String, dynamic> message) {
|
_showNotiContent(Map<String, dynamic> message) {
|
||||||
try {
|
try {
|
||||||
Map<String, dynamic> map = Map<String, dynamic>.from(message["data"]);
|
Map<String, dynamic> map = Map<String, dynamic>.from(message["data"]);
|
||||||
@@ -291,7 +291,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
|
|
||||||
final staffBtn = TaskButton(
|
final staffBtn = TaskButton(
|
||||||
"staff.title",
|
"staff.title",
|
||||||
icon: MaterialCommunityIcons.worker,
|
icon: MaterialCommunityIcons.account_tie,
|
||||||
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
|
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
|
||||||
builder: (context) => StaffList(),
|
builder: (context) => StaffList(),
|
||||||
)),
|
)),
|
||||||
@@ -350,7 +350,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
selectedColor: Colors.white,
|
selectedColor: Colors.white,
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Icon(MaterialCommunityIcons.worker),
|
Icon(MaterialCommunityIcons.account_tie),
|
||||||
],
|
],
|
||||||
onPressed: (i) => this.setState(() {
|
onPressed: (i) => this.setState(() {
|
||||||
isFcs[0] = !isFcs[0];
|
isFcs[0] = !isFcs[0];
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ class _InitialLanguageSelectionPageState
|
|||||||
languagesList[1]: languageCodesList[1],
|
languagesList[1]: languageCodesList[1],
|
||||||
};
|
};
|
||||||
|
|
||||||
String selectedLanguage;
|
late String selectedLanguage;
|
||||||
int selectedIndex;
|
late int selectedIndex;
|
||||||
bool _isLoading;
|
bool _isLoading = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -102,8 +102,8 @@ class _InitialLanguageSelectionPageState
|
|||||||
? BoxDecoration()
|
? BoxDecoration()
|
||||||
: BoxDecoration(
|
: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom:
|
bottom: BorderSide(
|
||||||
BorderSide(color: Colors.grey[300]),
|
color: Colors.grey.shade300),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
@@ -134,7 +134,7 @@ class _InitialLanguageSelectionPageState
|
|||||||
child: Radio(
|
child: Radio(
|
||||||
value: key,
|
value: key,
|
||||||
groupValue: selectedIndex,
|
groupValue: selectedIndex,
|
||||||
onChanged: (int i) =>
|
onChanged: (int? i) =>
|
||||||
_select(key, language),
|
_select(key, language),
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
),
|
),
|
||||||
@@ -178,7 +178,7 @@ class _InitialLanguageSelectionPageState
|
|||||||
setState(() {
|
setState(() {
|
||||||
selectedIndex = index;
|
selectedIndex = index;
|
||||||
selectedLanguage = lang;
|
selectedLanguage = lang;
|
||||||
Translation().onLocaleChanged(Locale(languagesMap[lang]));
|
Translation().onLocaleChanged!(Locale(languagesMap[lang]));
|
||||||
Provider.of<LanguageModel>(context, listen: false)
|
Provider.of<LanguageModel>(context, listen: false)
|
||||||
.saveLanguage(selectedLanguage);
|
.saveLanguage(selectedLanguage);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class _SplashScreenState extends State<SplashScreen> {
|
|||||||
bool _loaded = false;
|
bool _loaded = false;
|
||||||
bool _isSupport = false;
|
bool _isSupport = false;
|
||||||
bool _isOnline = true;
|
bool _isOnline = true;
|
||||||
Timer timer;
|
late Timer timer;
|
||||||
|
|
||||||
startTime() async {
|
startTime() async {
|
||||||
var _duration = new Duration(milliseconds: 3000);
|
var _duration = new Duration(milliseconds: 3000);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ Future showMsgDialog(BuildContext context, String title, String msg) {
|
|||||||
|
|
||||||
Future<void> showConfirmDialog(
|
Future<void> showConfirmDialog(
|
||||||
BuildContext context, String translationKey, ok(),
|
BuildContext context, String translationKey, ok(),
|
||||||
{List<String> translationVariables}) async {
|
{List<String>? translationVariables}) async {
|
||||||
await showDialog(
|
await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) {
|
builder: (_) {
|
||||||
@@ -42,7 +42,7 @@ Future<void> showConfirmDialog(
|
|||||||
child: LocalText(
|
child: LocalText(
|
||||||
context,
|
context,
|
||||||
translationKey,
|
translationKey,
|
||||||
translationVariables: translationVariables,
|
translationVariables: translationVariables!,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -188,7 +188,7 @@ Widget getStatus(String status) {
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Text(
|
: Text(
|
||||||
status ?? "",
|
status,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
@@ -230,10 +230,10 @@ Widget phoneWidget(BuildContext context, String phone) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget fcsInput(String label, IconData iconData,
|
Widget fcsInput(String label, IconData iconData,
|
||||||
{TextEditingController controller,
|
{required TextEditingController controller,
|
||||||
String value,
|
required String value,
|
||||||
bool autoFocus = false,
|
bool autoFocus = false,
|
||||||
TextInputType textInputType}) {
|
TextInputType? textInputType}) {
|
||||||
return TextFormField(
|
return TextFormField(
|
||||||
initialValue: value,
|
initialValue: value,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
@@ -257,7 +257,7 @@ Widget fcsInput(String label, IconData iconData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget fcsInputReadOnly(String label, IconData iconData,
|
Widget fcsInputReadOnly(String label, IconData iconData,
|
||||||
{TextEditingController controller, String value}) {
|
{required TextEditingController controller, required String value}) {
|
||||||
return TextFormField(
|
return TextFormField(
|
||||||
initialValue: value,
|
initialValue: value,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
@@ -279,7 +279,7 @@ Widget fcsInputReadOnly(String label, IconData iconData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget fcsDropDown(String label, IconData iconData,
|
Widget fcsDropDown(String label, IconData iconData,
|
||||||
{TextEditingController controller}) {
|
{required TextEditingController controller}) {
|
||||||
return Row(
|
return Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
@@ -308,7 +308,7 @@ Widget _dropDown() {
|
|||||||
height: 2,
|
height: 2,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onChanged: (String newValue) {},
|
onChanged: (String? newValue) {},
|
||||||
items: <String>['Ko Nge', 'Two', 'Free', 'Four']
|
items: <String>['Ko Nge', 'Two', 'Free', 'Four']
|
||||||
.map<DropdownMenuItem<String>>((String value) {
|
.map<DropdownMenuItem<String>>((String value) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
@@ -320,7 +320,7 @@ Widget _dropDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget fcsButton(BuildContext context, String text,
|
Widget fcsButton(BuildContext context, String text,
|
||||||
{Function callack, IconData iconData}) {
|
{Function? callack, IconData? iconData}) {
|
||||||
var languageModel = Provider.of<LanguageModel>(context);
|
var languageModel = Provider.of<LanguageModel>(context);
|
||||||
|
|
||||||
var style = languageModel.isEng
|
var style = languageModel.isEng
|
||||||
@@ -344,7 +344,7 @@ Widget fcsButton(BuildContext context, String text,
|
|||||||
minWidth: 900.0,
|
minWidth: 900.0,
|
||||||
height: 100.0,
|
height: 100.0,
|
||||||
child: FlatButton(
|
child: FlatButton(
|
||||||
onPressed: callack,
|
onPressed: callack == null ? null : () => callack(),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@@ -371,7 +371,7 @@ String getLocalString(BuildContext context, String key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showToast(GlobalKey key, String text) {
|
void showToast(GlobalKey key, String text) {
|
||||||
final ScaffoldState scaffold = key.currentState;
|
final ScaffoldState scaffold = key.currentState as ScaffoldState;
|
||||||
scaffold.showSnackBar(
|
scaffold.showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(text),
|
content: Text(text),
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ typedef BtnCallback();
|
|||||||
class _WelcomePageState extends State<WelcomePage> {
|
class _WelcomePageState extends State<WelcomePage> {
|
||||||
final log = Logger('_HomePageWelcomeState');
|
final log = Logger('_HomePageWelcomeState');
|
||||||
|
|
||||||
String pin;
|
late String pin;
|
||||||
List<bool> isSelected = [true, false];
|
List<bool> isSelected = [true, false];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ class _MarketEditorState extends State<MarketEditor> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
icon:
|
||||||
|
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
),
|
),
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
@@ -150,37 +151,39 @@ class _MarketEditorState extends State<MarketEditor> {
|
|||||||
_showDialog(BuildContext context) async {
|
_showDialog(BuildContext context) async {
|
||||||
await showDialog<String>(
|
await showDialog<String>(
|
||||||
context: context,
|
context: context,
|
||||||
child: new AlertDialog(
|
builder: (BuildContext context) {
|
||||||
contentPadding: const EdgeInsets.all(16.0),
|
return new AlertDialog(
|
||||||
content: new Row(
|
contentPadding: const EdgeInsets.all(16.0),
|
||||||
children: <Widget>[
|
content: new Row(
|
||||||
new Expanded(
|
children: <Widget>[
|
||||||
child: InputText(
|
new Expanded(
|
||||||
labelTextKey: "market.edit.name",
|
child: InputText(
|
||||||
controller: _marketNameCtl,
|
labelTextKey: "market.edit.name",
|
||||||
autoFocus: true,
|
controller: _marketNameCtl,
|
||||||
),
|
autoFocus: true,
|
||||||
)
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
new FlatButton(
|
||||||
|
child: LocalText(context, "btn.cancel", color: primaryColor),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}),
|
||||||
|
new FlatButton(
|
||||||
|
child: LocalText(
|
||||||
|
context,
|
||||||
|
"btn.save",
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
_add();
|
||||||
|
})
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
actions: <Widget>[
|
},
|
||||||
new FlatButton(
|
|
||||||
child: LocalText(context, "btn.cancel", color: primaryColor),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
}),
|
|
||||||
new FlatButton(
|
|
||||||
child: LocalText(
|
|
||||||
context,
|
|
||||||
"btn.save",
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
_add();
|
|
||||||
})
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ import 'package:fcs/pages/widgets/multi_img_file.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
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';
|
||||||
|
|
||||||
class PackageEditorPage extends StatefulWidget {
|
class PackageEditorPage extends StatefulWidget {
|
||||||
final Package package;
|
final Package? package;
|
||||||
PackageEditorPage({this.package});
|
PackageEditorPage({this.package});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -30,17 +30,17 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
|
|||||||
TextEditingController _remarkCtl = new TextEditingController();
|
TextEditingController _remarkCtl = new TextEditingController();
|
||||||
TextEditingController _descCtl = new TextEditingController();
|
TextEditingController _descCtl = new TextEditingController();
|
||||||
|
|
||||||
Package _package;
|
Package? _package;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_package = widget.package;
|
_package = widget.package!;
|
||||||
selectedMarket = _package.market ?? "";
|
selectedMarket = _package!.market;
|
||||||
_descCtl.text = _package.desc;
|
_descCtl.text = _package!.desc;
|
||||||
_remarkCtl.text = _package.remark;
|
_remarkCtl.text = _package!.remark;
|
||||||
multiImgController.setImageUrls = _package.photoUrls;
|
multiImgController.setImageUrls = _package!.photoUrls;
|
||||||
}
|
}
|
||||||
|
|
||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
@@ -51,17 +51,17 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final trackingIdBox = DisplayText(
|
final trackingIdBox = DisplayText(
|
||||||
text: _package.trackingID,
|
text: _package != null ? _package!.trackingID : "",
|
||||||
labelTextKey: "package.tracking.id",
|
labelTextKey: "package.tracking.id",
|
||||||
iconData: MaterialCommunityIcons.barcode_scan,
|
iconData: MaterialCommunityIcons.barcode_scan,
|
||||||
);
|
);
|
||||||
final statusBox = DisplayText(
|
final statusBox = DisplayText(
|
||||||
text: _package.status,
|
text: _package != null ? _package!.status : "",
|
||||||
labelTextKey: "package.edit.status",
|
labelTextKey: "package.edit.status",
|
||||||
iconData: AntDesign.exclamationcircleo,
|
iconData: AntDesign.exclamationcircleo,
|
||||||
);
|
);
|
||||||
final customerNameBox = DisplayText(
|
final customerNameBox = DisplayText(
|
||||||
text: _package.userName,
|
text: _package != null ? _package!.userName : "",
|
||||||
labelTextKey: "package.create.name",
|
labelTextKey: "package.create.name",
|
||||||
iconData: Icons.perm_identity,
|
iconData: Icons.perm_identity,
|
||||||
);
|
);
|
||||||
@@ -154,13 +154,13 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String selectedMarket;
|
String? selectedMarket;
|
||||||
Widget marketDropdown() {
|
Widget marketDropdown() {
|
||||||
List<Market> _markets = Provider.of<MarketModel>(context).markets;
|
List<Market> _markets = Provider.of<MarketModel>(context).markets;
|
||||||
List<String> markets = _markets.map((e) => e.name).toList();
|
List<String> markets = _markets.map((e) => e.name).toList();
|
||||||
markets.insert(0, MANAGE_MARKET);
|
markets.insert(0, MANAGE_MARKET);
|
||||||
if (!markets.contains(selectedMarket)) {
|
if (!markets.contains(selectedMarket)) {
|
||||||
markets.insert(0, selectedMarket);
|
markets.insert(0, selectedMarket!);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
@@ -183,7 +183,7 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
|
|||||||
height: 1,
|
height: 1,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
onChanged: (String newValue) {
|
onChanged: (String? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (newValue == MANAGE_MARKET) {
|
if (newValue == MANAGE_MARKET) {
|
||||||
selectedMarket = null;
|
selectedMarket = null;
|
||||||
@@ -197,7 +197,7 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
|
|||||||
items: markets.map<DropdownMenuItem<String>>((String value) {
|
items: markets.map<DropdownMenuItem<String>>((String value) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(value ?? "",
|
child: Text(value,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: value == MANAGE_MARKET
|
color: value == MANAGE_MARKET
|
||||||
@@ -229,9 +229,9 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
|
|||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
_package.desc = _descCtl.text;
|
_package!.desc = _descCtl.text;
|
||||||
_package.remark = _remarkCtl.text;
|
_package!.remark = _remarkCtl.text;
|
||||||
_package.market = selectedMarket;
|
_package!.market = selectedMarket!;
|
||||||
// await packageModel.completeProcessing(_package,
|
// await packageModel.completeProcessing(_package,
|
||||||
// multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
// multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import 'package:fcs/pages/widgets/progress.dart';
|
|||||||
import 'package:fcs/pages/widgets/status_tree.dart';
|
import 'package:fcs/pages/widgets/status_tree.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
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';
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
|||||||
class PackageInfo extends StatefulWidget {
|
class PackageInfo extends StatefulWidget {
|
||||||
final isCustomer;
|
final isCustomer;
|
||||||
final isSearchResult;
|
final isSearchResult;
|
||||||
final Package package;
|
final Package? package;
|
||||||
|
|
||||||
PackageInfo(
|
PackageInfo(
|
||||||
{this.package, this.isSearchResult = false, this.isCustomer = false});
|
{this.package, this.isSearchResult = false, this.isCustomer = false});
|
||||||
@@ -38,14 +38,14 @@ class PackageInfo extends StatefulWidget {
|
|||||||
|
|
||||||
class _PackageInfoState extends State<PackageInfo> {
|
class _PackageInfoState extends State<PackageInfo> {
|
||||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||||
Package _package;
|
Package? _package;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
MultiImgController multiImgController = MultiImgController();
|
MultiImgController multiImgController = MultiImgController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
initPackage(widget.package);
|
initPackage(widget.package!);
|
||||||
}
|
}
|
||||||
|
|
||||||
initPackage(Package pkg) async {
|
initPackage(Package pkg) async {
|
||||||
@@ -113,21 +113,21 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
callBack: _return,
|
callBack: _return,
|
||||||
);
|
);
|
||||||
final deliveryAddressBox = DefaultDeliveryAddress(
|
final deliveryAddressBox = DefaultDeliveryAddress(
|
||||||
deliveryAddress: _package?.deliveryAddress,
|
deliveryAddress: _package!.deliveryAddress,
|
||||||
labelKey: "package.delivery.address",
|
labelKey: "package.delivery.address",
|
||||||
onTap: owner && canChangeDeliveryAddress
|
onTap: owner && canChangeDeliveryAddress
|
||||||
? () async {
|
? () async {
|
||||||
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
|
DeliveryAddress? d = await Navigator.push<DeliveryAddress>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => DeliveryAddressSelection(
|
builder: (context) => DeliveryAddressSelection(
|
||||||
deliveryAddress: _package.deliveryAddress,
|
deliveryAddress: _package!.deliveryAddress,
|
||||||
user: mainModel.user)),
|
user: mainModel.user)),
|
||||||
);
|
);
|
||||||
if (d == null) return;
|
if (d == null) return;
|
||||||
_changeDeliverayAddress(d);
|
_changeDeliverayAddress(d);
|
||||||
}
|
}
|
||||||
: null,
|
: () {},
|
||||||
);
|
);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
@@ -159,7 +159,7 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
widget.isSearchResult ? Container() : fcsIDBox,
|
widget.isSearchResult ? Container() : fcsIDBox,
|
||||||
widget.isSearchResult ? Container() : customerNameBox,
|
widget.isSearchResult ? Container() : customerNameBox,
|
||||||
widget.isSearchResult ? Container() : marketBox,
|
widget.isSearchResult ? Container() : marketBox,
|
||||||
_package == null || _package.photoUrls.length == 0
|
_package == null || _package!.photoUrls.length == 0
|
||||||
? Container()
|
? Container()
|
||||||
: img,
|
: img,
|
||||||
widget.isSearchResult ? Container() : descBox,
|
widget.isSearchResult ? Container() : descBox,
|
||||||
@@ -172,8 +172,8 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
widget.isSearchResult
|
widget.isSearchResult
|
||||||
? Container()
|
? Container()
|
||||||
: StatusTree(
|
: StatusTree(
|
||||||
shipmentHistory: _package?.shipmentHistory,
|
shipmentHistory: _package!.shipmentHistory,
|
||||||
currentStatus: _package?.status),
|
currentStatus: _package!.status),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
)
|
)
|
||||||
@@ -197,11 +197,11 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
Provider.of<DeliveryAddressModel>(context, listen: false);
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await packageModel.changeDeliveryAddress(_package, deliveryAddress);
|
await packageModel.changeDeliveryAddress(_package!, deliveryAddress);
|
||||||
var da =
|
var da =
|
||||||
await deliveryAddressModel.getDeliveryAddress(deliveryAddress.id);
|
await deliveryAddressModel.getDeliveryAddress(deliveryAddress.id);
|
||||||
setState(() {
|
setState(() {
|
||||||
_package.deliveryAddress = da;
|
_package!.deliveryAddress = da;
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
@@ -223,7 +223,7 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
try {
|
try {
|
||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
await packageModel.packageReturn(_package);
|
await packageModel.packageReturn(_package!);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import 'package:provider/provider.dart';
|
|||||||
class PackageList extends StatefulWidget {
|
class PackageList extends StatefulWidget {
|
||||||
final bool forCustomer;
|
final bool forCustomer;
|
||||||
|
|
||||||
const PackageList({Key key, this.forCustomer = true}) : super(key: key);
|
const PackageList({Key? key, this.forCustomer = true}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_PackageListState createState() => _PackageListState();
|
_PackageListState createState() => _PackageListState();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,20 +4,23 @@ import 'package:fcs/pages/main/util.dart';
|
|||||||
import 'package:fcs/pages/package/package_info.dart';
|
import 'package:fcs/pages/package/package_info.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
typedef CallbackPackageSelect(Package package);
|
typedef CallbackPackageSelect(Package package);
|
||||||
|
|
||||||
class PackageListRow extends StatelessWidget {
|
class PackageListRow extends StatelessWidget {
|
||||||
final bool isCustomer;
|
final bool isCustomer;
|
||||||
final Package package;
|
final Package? package;
|
||||||
final CallbackPackageSelect callbackPackageSelect;
|
final CallbackPackageSelect? callbackPackageSelect;
|
||||||
final double dotSize = 15.0;
|
final double dotSize = 15.0;
|
||||||
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||||
|
|
||||||
PackageListRow(
|
PackageListRow(
|
||||||
{Key key, this.package, this.callbackPackageSelect, this.isCustomer})
|
{Key? key,
|
||||||
|
this.package,
|
||||||
|
this.callbackPackageSelect,
|
||||||
|
this.isCustomer = false})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -25,7 +28,7 @@ class PackageListRow extends StatelessWidget {
|
|||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (callbackPackageSelect != null) {
|
if (callbackPackageSelect != null) {
|
||||||
callbackPackageSelect(package);
|
callbackPackageSelect!(package!);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
@@ -57,7 +60,7 @@ class PackageListRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
package.id == null ? '' : package.trackingID,
|
package!.id == null ? '' : package!.trackingID,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -65,7 +68,7 @@ class PackageListRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
package.market == null ? '' : package.market,
|
package!.market == null ? '' : package!.market,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -81,12 +84,12 @@ class PackageListRow extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(3.0),
|
padding: const EdgeInsets.all(3.0),
|
||||||
child: getStatus(package.status),
|
child: getStatus(package!.status),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
dateFormat.format(package.currentStatusDate),
|
dateFormat.format(package!.currentStatusDate),
|
||||||
style:
|
style:
|
||||||
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class PackageNew extends StatefulWidget {
|
|||||||
|
|
||||||
class _PackageNewState extends State<PackageNew> {
|
class _PackageNewState extends State<PackageNew> {
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
User user;
|
User? user;
|
||||||
|
|
||||||
List<Package> packages = [];
|
List<Package> packages = [];
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ class _PackageNewState extends State<PackageNew> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: user != null ? user.fcsID : "",
|
text: user != null ? user!.fcsID : "",
|
||||||
labelTextKey: "package.create.fcs.id",
|
labelTextKey: "package.create.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
)),
|
)),
|
||||||
@@ -55,12 +55,12 @@ class _PackageNewState extends State<PackageNew> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
final namebox = DisplayText(
|
final namebox = DisplayText(
|
||||||
text: user != null ? user.name : "",
|
text: user != null ? user!.name : "",
|
||||||
labelTextKey: "package.create.name",
|
labelTextKey: "package.create.name",
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
);
|
);
|
||||||
final phoneNumberBox = DisplayText(
|
final phoneNumberBox = DisplayText(
|
||||||
text: user != null ? user.phoneNumber : "",
|
text: user != null ? user!.phoneNumber : "",
|
||||||
labelTextKey: "package.create.phone",
|
labelTextKey: "package.create.phone",
|
||||||
iconData: Icons.phone,
|
iconData: Icons.phone,
|
||||||
);
|
);
|
||||||
@@ -144,7 +144,7 @@ class _PackageNewState extends State<PackageNew> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(packages[index].market ?? ""),
|
Text(packages[index].market),
|
||||||
Text(packages[index].trackingID),
|
Text(packages[index].trackingID),
|
||||||
// DisplayText(
|
// DisplayText(
|
||||||
// labelText: "Tracking ID",
|
// labelText: "Tracking ID",
|
||||||
@@ -170,7 +170,7 @@ class _PackageNewState extends State<PackageNew> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_addPackage() async {
|
_addPackage() async {
|
||||||
Package package = await Navigator.push<Package>(
|
Package? package = await Navigator.push<Package>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (context) => TrackingIDPage()),
|
CupertinoPageRoute(builder: (context) => TrackingIDPage()),
|
||||||
);
|
);
|
||||||
@@ -197,7 +197,7 @@ class _PackageNewState extends State<PackageNew> {
|
|||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
await packageModel.createPackages(user, packages);
|
await packageModel.createPackages(user!, packages);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:barcode_scan/barcode_scan.dart';
|
|
||||||
import 'package:fcs/domain/entities/market.dart';
|
import 'package:fcs/domain/entities/market.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';
|
||||||
@@ -12,7 +11,7 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ const MANAGE_MARKET = "Manage Market";
|
|||||||
const SELECT_MARKET = "Select Market";
|
const SELECT_MARKET = "Select Market";
|
||||||
|
|
||||||
class TrackingIDPage extends StatefulWidget {
|
class TrackingIDPage extends StatefulWidget {
|
||||||
const TrackingIDPage({Key key}) : super(key: key);
|
const TrackingIDPage({Key? key}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_TrackingIDPageState createState() => _TrackingIDPageState();
|
_TrackingIDPageState createState() => _TrackingIDPageState();
|
||||||
}
|
}
|
||||||
@@ -85,7 +84,7 @@ class _TrackingIDPageState extends State<TrackingIDPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String selectedMarket;
|
String? selectedMarket;
|
||||||
Widget dropDown() {
|
Widget dropDown() {
|
||||||
List<Market> _markets = Provider.of<MarketModel>(context).markets;
|
List<Market> _markets = Provider.of<MarketModel>(context).markets;
|
||||||
List<String> markets = _markets.map((e) => e.name).toList();
|
List<String> markets = _markets.map((e) => e.name).toList();
|
||||||
@@ -112,7 +111,7 @@ class _TrackingIDPageState extends State<TrackingIDPage> {
|
|||||||
height: 1,
|
height: 1,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
onChanged: (String newValue) {
|
onChanged: (String? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (newValue == MANAGE_MARKET) {
|
if (newValue == MANAGE_MARKET) {
|
||||||
selectedMarket = null;
|
selectedMarket = null;
|
||||||
@@ -152,17 +151,17 @@ class _TrackingIDPageState extends State<TrackingIDPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_scan() async {
|
_scan() async {
|
||||||
PermissionStatus permission =
|
// PermissionStatus permission =
|
||||||
await PermissionHandler().checkPermissionStatus(PermissionGroup.camera);
|
// await PermissionHandler().checkPermissionStatus(PermissionGroup.camera);
|
||||||
if (permission != PermissionStatus.granted) {
|
// if (permission != PermissionStatus.granted) {
|
||||||
Map<PermissionGroup, PermissionStatus> permissions =
|
// Map<PermissionGroup, PermissionStatus> permissions =
|
||||||
await PermissionHandler()
|
// await PermissionHandler()
|
||||||
.requestPermissions([PermissionGroup.camera]);
|
// .requestPermissions([PermissionGroup.camera]);
|
||||||
if (permissions[PermissionGroup.camera] != PermissionStatus.granted) {
|
// if (permissions[PermissionGroup.camera] != PermissionStatus.granted) {
|
||||||
showMsgDialog(context, "Error", "Camera permission is not granted");
|
// showMsgDialog(context, "Error", "Camera permission is not granted");
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String barcode = await scanBarcode();
|
String barcode = await scanBarcode();
|
||||||
@@ -179,6 +178,6 @@ class _TrackingIDPageState extends State<TrackingIDPage> {
|
|||||||
_select() {
|
_select() {
|
||||||
if (_transcationIDCtl.text == "" && selectedMarket == null) return;
|
if (_transcationIDCtl.text == "" && selectedMarket == null) return;
|
||||||
Navigator.pop(context,
|
Navigator.pop(context,
|
||||||
Package(trackingID: _transcationIDCtl.text, market: selectedMarket));
|
Package(trackingID: _transcationIDCtl.text, market: selectedMarket!));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:barcode_scan/barcode_scan.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/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
@@ -6,12 +5,12 @@ import 'package:fcs/pages/package/model/package_model.dart';
|
|||||||
import 'package:fcs/pages/package/package_list_row.dart';
|
import 'package:fcs/pages/package/package_list_row.dart';
|
||||||
import 'package:fcs/pages/widgets/barcode_scanner.dart';
|
import 'package:fcs/pages/widgets/barcode_scanner.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
Future<Package> searchPackage(BuildContext context,
|
Future<Package?> searchPackage(BuildContext context,
|
||||||
{CallbackPackageSelect callbackPackageSelect}) async =>
|
{CallbackPackageSelect? callbackPackageSelect}) async =>
|
||||||
await showSearch<Package>(
|
await showSearch<Package>(
|
||||||
context: context,
|
context: context,
|
||||||
delegate:
|
delegate:
|
||||||
@@ -19,7 +18,7 @@ Future<Package> searchPackage(BuildContext context,
|
|||||||
);
|
);
|
||||||
|
|
||||||
class PackageSearchDelegate extends SearchDelegate<Package> {
|
class PackageSearchDelegate extends SearchDelegate<Package> {
|
||||||
final CallbackPackageSelect callbackPackageSelect;
|
final CallbackPackageSelect? callbackPackageSelect;
|
||||||
|
|
||||||
PackageSearchDelegate({this.callbackPackageSelect});
|
PackageSearchDelegate({this.callbackPackageSelect});
|
||||||
|
|
||||||
@@ -32,10 +31,10 @@ class PackageSearchDelegate extends SearchDelegate<Package> {
|
|||||||
return theme.copyWith(
|
return theme.copyWith(
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
color: theme.primaryTextTheme.caption.color, fontSize: 14)),
|
color: theme.primaryTextTheme.caption!.color, fontSize: 14)),
|
||||||
textTheme: theme.textTheme.copyWith(
|
textTheme: theme.textTheme.copyWith(
|
||||||
title: theme.textTheme.title.copyWith(
|
title: theme.textTheme.title!.copyWith(
|
||||||
color: theme.primaryTextTheme.title.color, fontSize: 16)),
|
color: theme.primaryTextTheme.title!.color, fontSize: 16)),
|
||||||
primaryColor: primaryColor,
|
primaryColor: primaryColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -59,7 +58,7 @@ class PackageSearchDelegate extends SearchDelegate<Package> {
|
|||||||
Widget buildLeading(BuildContext context) {
|
Widget buildLeading(BuildContext context) {
|
||||||
return IconButton(
|
return IconButton(
|
||||||
icon: Icon(Icons.arrow_back),
|
icon: Icon(Icons.arrow_back),
|
||||||
onPressed: () => close(context, null),
|
onPressed: () => close(context, new Package()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +69,7 @@ class PackageSearchDelegate extends SearchDelegate<Package> {
|
|||||||
future: packageModel.searchPackage(query),
|
future: packageModel.searchPackage(query),
|
||||||
builder: (context, AsyncSnapshot<List<Package>> snapshot) {
|
builder: (context, AsyncSnapshot<List<Package>> snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
if (snapshot.data.length == 0) {
|
if (snapshot.data!.length == 0) {
|
||||||
return Container(
|
return Container(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -83,7 +82,7 @@ class PackageSearchDelegate extends SearchDelegate<Package> {
|
|||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(top: 15),
|
padding: EdgeInsets.only(top: 15),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: snapshot.data
|
children: snapshot.data!
|
||||||
.map((u) => PackageListRow(
|
.map((u) => PackageListRow(
|
||||||
package: u,
|
package: u,
|
||||||
callbackPackageSelect: callbackPackageSelect,
|
callbackPackageSelect: callbackPackageSelect,
|
||||||
@@ -124,17 +123,17 @@ class PackageSearchDelegate extends SearchDelegate<Package> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_scan(BuildContext context) async {
|
_scan(BuildContext context) async {
|
||||||
PermissionStatus permission =
|
// PermissionStatus permission =
|
||||||
await PermissionHandler().checkPermissionStatus(PermissionGroup.camera);
|
// await PermissionHandler().checkPermissionStatus(PermissionGroup.camera);
|
||||||
if (permission != PermissionStatus.granted) {
|
// if (permission != PermissionStatus.granted) {
|
||||||
Map<PermissionGroup, PermissionStatus> permissions =
|
// Map<PermissionGroup, PermissionStatus> permissions =
|
||||||
await PermissionHandler()
|
// await PermissionHandler()
|
||||||
.requestPermissions([PermissionGroup.camera]);
|
// .requestPermissions([PermissionGroup.camera]);
|
||||||
if (permissions[PermissionGroup.camera] != PermissionStatus.granted) {
|
// if (permissions[PermissionGroup.camera] != PermissionStatus.granted) {
|
||||||
showMsgDialog(context, "Error", "Camera permission is not granted");
|
// showMsgDialog(context, "Error", "Camera permission is not granted");
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// PickedFile pickedFile =
|
// PickedFile pickedFile =
|
||||||
|
|||||||
@@ -8,20 +8,20 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class PaymentMethodEditor extends StatefulWidget {
|
class PaymentMethodEditor extends StatefulWidget {
|
||||||
final PaymentMethod paymentMethod;
|
final PaymentMethod? paymentMethod;
|
||||||
|
|
||||||
const PaymentMethodEditor({Key key, this.paymentMethod}) : super(key: key);
|
const PaymentMethodEditor({Key? key, this.paymentMethod}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_PaymentMethodEditorState createState() => _PaymentMethodEditorState();
|
_PaymentMethodEditorState createState() => _PaymentMethodEditorState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
|
class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
PaymentMethod _paymentMethod;
|
PaymentMethod? _paymentMethod;
|
||||||
TextEditingController _nameController = new TextEditingController();
|
TextEditingController _nameController = new TextEditingController();
|
||||||
TextEditingController _accountNameController = new TextEditingController();
|
TextEditingController _accountNameController = new TextEditingController();
|
||||||
TextEditingController _accountNumberController = new TextEditingController();
|
TextEditingController _accountNumberController = new TextEditingController();
|
||||||
@@ -29,7 +29,7 @@ class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
|
|||||||
TextEditingController _phoneController = new TextEditingController();
|
TextEditingController _phoneController = new TextEditingController();
|
||||||
TextEditingController _linkController = new TextEditingController();
|
TextEditingController _linkController = new TextEditingController();
|
||||||
|
|
||||||
bool isNew;
|
late bool isNew;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -38,12 +38,12 @@ class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
|
|||||||
|
|
||||||
if (widget.paymentMethod != null) {
|
if (widget.paymentMethod != null) {
|
||||||
_paymentMethod = widget.paymentMethod;
|
_paymentMethod = widget.paymentMethod;
|
||||||
_nameController.text = _paymentMethod.name;
|
_nameController.text = _paymentMethod!.name;
|
||||||
_accountNameController.text = _paymentMethod.accountName;
|
_accountNameController.text = _paymentMethod!.accountName;
|
||||||
_accountNumberController.text = _paymentMethod.account;
|
_accountNumberController.text = _paymentMethod!.account;
|
||||||
_mailController.text = _paymentMethod.email;
|
_mailController.text = _paymentMethod!.email;
|
||||||
_phoneController.text = _paymentMethod.phone;
|
_phoneController.text = _paymentMethod!.phone;
|
||||||
_linkController.text = _paymentMethod.link;
|
_linkController.text = _paymentMethod!.link;
|
||||||
} else {
|
} else {
|
||||||
_paymentMethod = new PaymentMethod();
|
_paymentMethod = new PaymentMethod();
|
||||||
_nameController.text = '';
|
_nameController.text = '';
|
||||||
@@ -179,7 +179,7 @@ class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
PaymentMethod pm = PaymentMethod(
|
PaymentMethod pm = PaymentMethod(
|
||||||
id: _paymentMethod.id,
|
id: _paymentMethod!.id,
|
||||||
name: _nameController.text,
|
name: _nameController.text,
|
||||||
accountName: _accountNameController.text,
|
accountName: _accountNameController.text,
|
||||||
account: _accountNumberController.text,
|
account: _accountNumberController.text,
|
||||||
@@ -208,7 +208,7 @@ class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await Provider.of<PaymentMethodModel>(context, listen: false)
|
await Provider.of<PaymentMethodModel>(context, listen: false)
|
||||||
.deletePaymentMethod(_paymentMethod.id);
|
.deletePaymentMethod(_paymentMethod!.id);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import 'package:fcs/pages/widgets/progress.dart';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class PaymentMethodPage extends StatefulWidget {
|
class PaymentMethodPage extends StatefulWidget {
|
||||||
@@ -127,7 +127,7 @@ class _PaymentMethodPageState extends State<PaymentMethodPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_itemRow(String text, String labelKey, {IconData iconData}) {
|
_itemRow(String text, String labelKey, {IconData? iconData}) {
|
||||||
return text == null || text == ""
|
return text == null || text == ""
|
||||||
? Container()
|
? Container()
|
||||||
: Row(
|
: Row(
|
||||||
@@ -153,7 +153,7 @@ class _PaymentMethodPageState extends State<PaymentMethodPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _showToast(String title) {
|
void _showToast(String title) {
|
||||||
final ScaffoldState scaffold = key.currentState;
|
final ScaffoldState scaffold = key.currentState as ScaffoldState;
|
||||||
scaffold.showSnackBar(
|
scaffold.showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text('copied "$title" data to clipboard'),
|
content: Text('copied "$title" data to clipboard'),
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ import 'package:fcs/pages/widgets/multi_img_file.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class PackageEditor extends StatefulWidget {
|
class PackageEditor extends StatefulWidget {
|
||||||
final Package package;
|
final Package? package;
|
||||||
final User consignee;
|
final User? consignee;
|
||||||
final User sender;
|
final User? sender;
|
||||||
PackageEditor({this.package, this.consignee, this.sender});
|
PackageEditor({this.package, this.consignee, this.sender});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -38,13 +38,13 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
MultiImgController multiImgController = MultiImgController();
|
MultiImgController multiImgController = MultiImgController();
|
||||||
Package _package;
|
Package? _package;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_package = Package();
|
_package = Package();
|
||||||
_loadPackageData(null);
|
_loadPackageData(widget.package!.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadPackageData(String id) async {
|
_loadPackageData(String id) async {
|
||||||
@@ -64,10 +64,10 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedMarket = _package.market ?? "";
|
selectedMarket = _package!.market ?? "";
|
||||||
_descCtl.text = _package.desc;
|
_descCtl.text = _package!.desc;
|
||||||
_remarkCtl.text = _package.remark;
|
_remarkCtl.text = _package!.remark;
|
||||||
multiImgController.setImageUrls = _package.photoUrls;
|
multiImgController.setImageUrls = _package!.photoUrls;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: _package.trackingID,
|
text: _package!.trackingID != null ? _package!.trackingID : "",
|
||||||
labelTextKey: "processing.tracking.id",
|
labelTextKey: "processing.tracking.id",
|
||||||
iconData: MaterialCommunityIcons.barcode_scan,
|
iconData: MaterialCommunityIcons.barcode_scan,
|
||||||
)),
|
)),
|
||||||
@@ -174,13 +174,13 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String selectedMarket;
|
String? selectedMarket;
|
||||||
Widget marketDropdown() {
|
Widget marketDropdown() {
|
||||||
List<Market> _markets = Provider.of<MarketModel>(context).markets;
|
List<Market> _markets = Provider.of<MarketModel>(context).markets;
|
||||||
List<String> markets = _markets.map((e) => e.name).toList();
|
List<String> markets = _markets.map((e) => e.name).toList();
|
||||||
markets.insert(0, MANAGE_MARKET);
|
markets.insert(0, MANAGE_MARKET);
|
||||||
if (!markets.contains(selectedMarket)) {
|
if (!markets.contains(selectedMarket)) {
|
||||||
markets.insert(0, selectedMarket);
|
markets.insert(0, selectedMarket!);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
@@ -210,7 +210,7 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
height: 1,
|
height: 1,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
onChanged: (String newValue) {
|
onChanged: (String? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (newValue == MANAGE_MARKET) {
|
if (newValue == MANAGE_MARKET) {
|
||||||
selectedMarket = null;
|
selectedMarket = null;
|
||||||
@@ -254,14 +254,15 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
_package.market = selectedMarket;
|
_package!.market = selectedMarket!;
|
||||||
_package.desc = _descCtl.text;
|
_package!.desc = _descCtl.text;
|
||||||
_package.remark = _remarkCtl.text;
|
_package!.remark = _remarkCtl.text;
|
||||||
_package.photoFiles = multiImgController.getUpdatedFile;
|
_package!.photoFiles = multiImgController.getUpdatedFile;
|
||||||
_package.fcsID = widget.consignee.fcsID;
|
_package!.fcsID = widget.consignee!.fcsID;
|
||||||
_package.senderFCSID = widget.sender?.fcsID;
|
_package!.senderFCSID =
|
||||||
|
widget.sender!.fcsID != null ? widget.sender!.fcsID : "";
|
||||||
|
|
||||||
await packageModel.updateProcessing(_package,
|
await packageModel.updateProcessing(_package!,
|
||||||
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
||||||
|
|
||||||
Navigator.pop<Package>(context, _package);
|
Navigator.pop<Package>(context, _package);
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ import 'package:fcs/pages/widgets/multi_img_file.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
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';
|
||||||
|
|
||||||
class ProcessingEditEditor extends StatefulWidget {
|
class ProcessingEditEditor extends StatefulWidget {
|
||||||
final Package package;
|
final Package? package;
|
||||||
ProcessingEditEditor({this.package});
|
ProcessingEditEditor({this.package});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -33,22 +33,22 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
TextEditingController _remarkCtl = new TextEditingController();
|
TextEditingController _remarkCtl = new TextEditingController();
|
||||||
TextEditingController _descCtl = new TextEditingController();
|
TextEditingController _descCtl = new TextEditingController();
|
||||||
|
|
||||||
Package _package;
|
Package? _package;
|
||||||
User _user;
|
User? _user;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_package = widget.package;
|
_package = widget.package;
|
||||||
selectedMarket = _package.market ?? "";
|
selectedMarket = _package!.market ?? "";
|
||||||
_descCtl.text = _package.desc;
|
_descCtl.text = _package!.desc;
|
||||||
_remarkCtl.text = _package.remark;
|
_remarkCtl.text = _package!.remark;
|
||||||
multiImgController.setImageUrls = _package.photoUrls;
|
multiImgController.setImageUrls = _package!.photoUrls;
|
||||||
_user = User(
|
_user = User(
|
||||||
fcsID: _package.fcsID ?? "",
|
fcsID: _package!.fcsID ?? "",
|
||||||
name: _package.userName ?? "",
|
name: _package!.userName ?? "",
|
||||||
phoneNumber: _package.phoneNumber ?? "");
|
phoneNumber: _package!.phoneNumber ?? "");
|
||||||
}
|
}
|
||||||
|
|
||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
@@ -62,7 +62,7 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: _user.fcsID,
|
text: _user!.fcsID,
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
)),
|
)),
|
||||||
@@ -76,18 +76,18 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
final namebox = DisplayText(
|
final namebox = DisplayText(
|
||||||
text: _user.name,
|
text: _user!.name,
|
||||||
labelTextKey: "processing.name",
|
labelTextKey: "processing.name",
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
);
|
);
|
||||||
final phoneNumberBox = DisplayText(
|
final phoneNumberBox = DisplayText(
|
||||||
text: _user.phoneNumber,
|
text: _user!.phoneNumber,
|
||||||
labelTextKey: "processing.phone",
|
labelTextKey: "processing.phone",
|
||||||
iconData: Icons.phone,
|
iconData: Icons.phone,
|
||||||
);
|
);
|
||||||
|
|
||||||
final trackingIdBox = DisplayText(
|
final trackingIdBox = DisplayText(
|
||||||
text: _package.trackingID,
|
text: _package!.trackingID,
|
||||||
labelTextKey: "processing.tracking.id",
|
labelTextKey: "processing.tracking.id",
|
||||||
iconData: MaterialCommunityIcons.barcode_scan,
|
iconData: MaterialCommunityIcons.barcode_scan,
|
||||||
);
|
);
|
||||||
@@ -159,13 +159,13 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String selectedMarket;
|
String? selectedMarket;
|
||||||
Widget marketDropdown() {
|
Widget marketDropdown() {
|
||||||
List<Market> _markets = Provider.of<MarketModel>(context).markets;
|
List<Market> _markets = Provider.of<MarketModel>(context).markets;
|
||||||
List<String> markets = _markets.map((e) => e.name).toList();
|
List<String> markets = _markets.map((e) => e.name).toList();
|
||||||
markets.insert(0, MANAGE_MARKET);
|
markets.insert(0, MANAGE_MARKET);
|
||||||
if (!markets.contains(selectedMarket)) {
|
if (!markets.contains(selectedMarket)) {
|
||||||
markets.insert(0, selectedMarket);
|
markets.insert(0, selectedMarket!);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
@@ -197,7 +197,7 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
height: 1,
|
height: 1,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
onChanged: (String newValue) {
|
onChanged: (String? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (newValue == MANAGE_MARKET) {
|
if (newValue == MANAGE_MARKET) {
|
||||||
selectedMarket = null;
|
selectedMarket = null;
|
||||||
@@ -236,7 +236,7 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_completeProcessing() async {
|
_completeProcessing() async {
|
||||||
if (_user.fcsID == null || _user.fcsID == "") {
|
if (_user!.fcsID == null || _user!.fcsID == "") {
|
||||||
showMsgDialog(context, "Error", "Expected FCS-ID");
|
showMsgDialog(context, "Error", "Expected FCS-ID");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -246,11 +246,11 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
_package.fcsID = _user.fcsID;
|
_package!.fcsID = _user!.fcsID;
|
||||||
_package.desc = _descCtl.text;
|
_package!.desc = _descCtl.text;
|
||||||
_package.remark = _remarkCtl.text;
|
_package!.remark = _remarkCtl.text;
|
||||||
_package.market = selectedMarket;
|
_package!.market = selectedMarket!;
|
||||||
await packageModel.updateProcessing(_package,
|
await packageModel.updateProcessing(_package!,
|
||||||
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -264,20 +264,20 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
|
|
||||||
isDataChanged() {
|
isDataChanged() {
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
return _user.fcsID != "" ||
|
return _user!.fcsID != "" ||
|
||||||
selectedMarket != null ||
|
selectedMarket != null ||
|
||||||
_descCtl.text != "" ||
|
_descCtl.text != "" ||
|
||||||
_remarkCtl.text != "" ||
|
_remarkCtl.text != "" ||
|
||||||
multiImgController.getAddedFile.isNotEmpty;
|
multiImgController.getAddedFile.isNotEmpty;
|
||||||
} else {
|
} else {
|
||||||
var _package = Package(
|
var _package = Package(
|
||||||
trackingID: widget.package.trackingID,
|
trackingID: widget.package!.trackingID,
|
||||||
fcsID: _user.fcsID,
|
fcsID: _user!.fcsID,
|
||||||
market: selectedMarket,
|
market: selectedMarket!,
|
||||||
desc: _descCtl.text,
|
desc: _descCtl.text,
|
||||||
remark: _remarkCtl.text,
|
remark: _remarkCtl.text,
|
||||||
photoUrls: widget.package.photoUrls);
|
photoUrls: widget.package!.photoUrls);
|
||||||
return widget.package.isChangedForEditProcessing(_package) ||
|
return widget.package!.isChangedForEditProcessing(_package) ||
|
||||||
multiImgController.getAddedFile.isNotEmpty ||
|
multiImgController.getAddedFile.isNotEmpty ||
|
||||||
multiImgController.getDeletedUrl.isNotEmpty;
|
multiImgController.getDeletedUrl.isNotEmpty;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'model/processing_model.dart';
|
import 'model/processing_model.dart';
|
||||||
import 'package_editor.dart';
|
import 'package_editor.dart';
|
||||||
|
|
||||||
class ProcesingEditor extends StatefulWidget {
|
class ProcesingEditor extends StatefulWidget {
|
||||||
final Processing processing;
|
final Processing? processing;
|
||||||
const ProcesingEditor({this.processing});
|
const ProcesingEditor({this.processing});
|
||||||
@override
|
@override
|
||||||
_ProcesingEditorState createState() => _ProcesingEditorState();
|
_ProcesingEditorState createState() => _ProcesingEditorState();
|
||||||
@@ -27,9 +27,9 @@ class ProcesingEditor extends StatefulWidget {
|
|||||||
class _ProcesingEditorState extends State<ProcesingEditor> {
|
class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||||
Processing processing = Processing();
|
Processing processing = Processing();
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool _isNew;
|
late bool _isNew;
|
||||||
User consignee;
|
User? consignee;
|
||||||
User sender;
|
User? sender;
|
||||||
List<Package> packages = [];
|
List<Package> packages = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -37,7 +37,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
_isNew = widget.processing == null;
|
_isNew = widget.processing == null;
|
||||||
if (!_isNew) {
|
if (!_isNew) {
|
||||||
processing = widget.processing;
|
processing = widget.processing!;
|
||||||
consignee = User(
|
consignee = User(
|
||||||
fcsID: processing.userID,
|
fcsID: processing.userID,
|
||||||
name: processing.userName,
|
name: processing.userName,
|
||||||
@@ -56,7 +56,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: consignee != null ? consignee.fcsID : "",
|
text: consignee != null ? consignee!.fcsID : "",
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
)),
|
)),
|
||||||
@@ -71,14 +71,14 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final phoneNumberBox = DisplayText(
|
final phoneNumberBox = DisplayText(
|
||||||
text: consignee != null ? consignee.phoneNumber : "",
|
text: consignee != null ? consignee!.phoneNumber : "",
|
||||||
labelTextKey: "processing.phone",
|
labelTextKey: "processing.phone",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.phone,
|
iconData: Icons.phone,
|
||||||
);
|
);
|
||||||
|
|
||||||
final namebox = DisplayText(
|
final namebox = DisplayText(
|
||||||
text: consignee != null ? consignee.name : "",
|
text: consignee != null ? consignee!.name : "",
|
||||||
labelTextKey: "processing.consignee.name",
|
labelTextKey: "processing.consignee.name",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
@@ -98,7 +98,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: sender != null ? sender.fcsID : "",
|
text: sender != null ? sender!.fcsID : "",
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
)),
|
)),
|
||||||
@@ -113,14 +113,14 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final shipperPhoneNumberBox = DisplayText(
|
final shipperPhoneNumberBox = DisplayText(
|
||||||
text: sender != null ? sender.phoneNumber : "",
|
text: sender != null ? sender!.phoneNumber : "",
|
||||||
labelTextKey: "processing.phone",
|
labelTextKey: "processing.phone",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.phone,
|
iconData: Icons.phone,
|
||||||
);
|
);
|
||||||
|
|
||||||
final shipperNamebox = DisplayText(
|
final shipperNamebox = DisplayText(
|
||||||
text: sender != null ? sender.name : "",
|
text: sender != null ? sender!.name : "",
|
||||||
labelTextKey: "processing.shipper.name",
|
labelTextKey: "processing.shipper.name",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
@@ -152,7 +152,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
context, "Warning", "Please select 'Consignee'");
|
context, "Warning", "Please select 'Consignee'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Package _package = await Navigator.push<Package>(
|
Package? _package = await Navigator.push<Package>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => PackageEditor(
|
builder: (context) => PackageEditor(
|
||||||
@@ -160,7 +160,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
consignee: this.consignee,
|
consignee: this.consignee,
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
_addPackage(_package);
|
_addPackage(_package!);
|
||||||
// _savePackage(_package);
|
// _savePackage(_package);
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
@@ -230,10 +230,10 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
return packages.map((p) {
|
return packages.map((p) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Package _package = await Navigator.of(context).push<Package>(
|
Package? _package = await Navigator.of(context).push<Package>(
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => PackageInfo(package: p)));
|
builder: (context) => PackageInfo(package: p)));
|
||||||
_savePackage(_package);
|
_savePackage(_package!);
|
||||||
},
|
},
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
labelTextKey: "processing.tracking.id",
|
labelTextKey: "processing.tracking.id",
|
||||||
@@ -273,7 +273,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
if (_isNew) {
|
if (_isNew) {
|
||||||
await processingModel.createProcessing(processing);
|
await processingModel.createProcessing(processing);
|
||||||
} else {
|
} else {
|
||||||
processing.id = widget.processing.id;
|
processing.id = widget.processing!.id;
|
||||||
await processingModel.updateProcessing(processing);
|
await processingModel.updateProcessing(processing);
|
||||||
}
|
}
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import 'package:fcs/pages/widgets/progress.dart';
|
|||||||
import 'package:fcs/pages/widgets/status_tree.dart';
|
import 'package:fcs/pages/widgets/status_tree.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
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';
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ import 'processing_edit_editor.dart';
|
|||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
|
|
||||||
class ProcessingInfo extends StatefulWidget {
|
class ProcessingInfo extends StatefulWidget {
|
||||||
final Package package;
|
final Package? package;
|
||||||
ProcessingInfo({this.package});
|
ProcessingInfo({this.package});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -29,14 +29,14 @@ class ProcessingInfo extends StatefulWidget {
|
|||||||
|
|
||||||
class _ProcessingInfoState extends State<ProcessingInfo> {
|
class _ProcessingInfoState extends State<ProcessingInfo> {
|
||||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||||
Package _package;
|
Package? _package;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
MultiImgController multiImgController = MultiImgController();
|
MultiImgController multiImgController = MultiImgController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
initPackage(widget.package);
|
initPackage(widget.package!);
|
||||||
}
|
}
|
||||||
|
|
||||||
initPackage(Package package) {
|
initPackage(Package package) {
|
||||||
@@ -54,52 +54,52 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final trackingIdBox = DisplayText(
|
final trackingIdBox = DisplayText(
|
||||||
text: _package.trackingID,
|
text: _package != null ? _package!.trackingID : '',
|
||||||
labelTextKey: "processing.tracking.id",
|
labelTextKey: "processing.tracking.id",
|
||||||
iconData: MaterialCommunityIcons.barcode_scan,
|
iconData: MaterialCommunityIcons.barcode_scan,
|
||||||
);
|
);
|
||||||
var fcsIDBox = DisplayText(
|
var fcsIDBox = DisplayText(
|
||||||
text: _package.fcsID,
|
text: _package != null ? _package!.fcsID : "",
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
);
|
);
|
||||||
final phoneNumberBox = DisplayText(
|
final phoneNumberBox = DisplayText(
|
||||||
text: _package.phoneNumber,
|
text: _package != null ? _package!.phoneNumber : "",
|
||||||
labelTextKey: "processing.phone",
|
labelTextKey: "processing.phone",
|
||||||
iconData: Icons.phone,
|
iconData: Icons.phone,
|
||||||
);
|
);
|
||||||
final customerNameBox = DisplayText(
|
final customerNameBox = DisplayText(
|
||||||
text: _package.userName,
|
text:_package!=null? _package!.userName:"",
|
||||||
labelTextKey: "processing.consignee.name",
|
labelTextKey: "processing.consignee.name",
|
||||||
iconData: Icons.perm_identity,
|
iconData: Icons.perm_identity,
|
||||||
);
|
);
|
||||||
var senderFcsIDBox = DisplayText(
|
var senderFcsIDBox = DisplayText(
|
||||||
text: _package.senderFCSID,
|
text:_package!=null? _package!.senderFCSID:"",
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
);
|
);
|
||||||
final senderPhoneNumberBox = DisplayText(
|
final senderPhoneNumberBox = DisplayText(
|
||||||
text: _package.senderPhoneNumber,
|
text: _package!=null?_package!.senderPhoneNumber:"",
|
||||||
labelTextKey: "processing.phone",
|
labelTextKey: "processing.phone",
|
||||||
iconData: Icons.phone,
|
iconData: Icons.phone,
|
||||||
);
|
);
|
||||||
final senderNameBox = DisplayText(
|
final senderNameBox = DisplayText(
|
||||||
text: _package.senderName,
|
text:_package!=null? _package!.senderName:"",
|
||||||
labelTextKey: "processing.shipper.name",
|
labelTextKey: "processing.shipper.name",
|
||||||
iconData: Icons.perm_identity,
|
iconData: Icons.perm_identity,
|
||||||
);
|
);
|
||||||
final marketBox = DisplayText(
|
final marketBox = DisplayText(
|
||||||
text: _package.market ?? "-",
|
text:_package!=null? _package!.market : "-",
|
||||||
labelTextKey: "processing.market",
|
labelTextKey: "processing.market",
|
||||||
iconData: Icons.store,
|
iconData: Icons.store,
|
||||||
);
|
);
|
||||||
final descBox = DisplayText(
|
final descBox = DisplayText(
|
||||||
text: _package.desc ?? "-",
|
text:_package!=null? _package!.desc : "-",
|
||||||
labelTextKey: "processing.desc",
|
labelTextKey: "processing.desc",
|
||||||
iconData: MaterialCommunityIcons.message_text_outline,
|
iconData: MaterialCommunityIcons.message_text_outline,
|
||||||
);
|
);
|
||||||
final remarkBox = DisplayText(
|
final remarkBox = DisplayText(
|
||||||
text: _package.remark ?? "-",
|
text:_package!=null? _package!.remark : "-",
|
||||||
labelTextKey: "processing.remark",
|
labelTextKey: "processing.remark",
|
||||||
iconData: Entypo.new_message,
|
iconData: Entypo.new_message,
|
||||||
);
|
);
|
||||||
@@ -172,10 +172,10 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
marketBox,
|
marketBox,
|
||||||
descBox,
|
descBox,
|
||||||
remarkBox,
|
remarkBox,
|
||||||
_package.photoUrls.length == 0 ? Container() : img,
|
_package!.photoUrls.length == 0 ? Container() : img,
|
||||||
StatusTree(
|
StatusTree(
|
||||||
shipmentHistory: _package.shipmentHistory,
|
shipmentHistory: _package!.shipmentHistory,
|
||||||
currentStatus: _package.status),
|
currentStatus: _package!.status),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
)
|
)
|
||||||
@@ -199,7 +199,7 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
await packageModel.deleteProcessing(_package);
|
await packageModel.deleteProcessing(_package!);
|
||||||
Navigator.pop<bool>(context, true);
|
Navigator.pop<bool>(context, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
@@ -211,7 +211,7 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_gotoEditor() async {
|
_gotoEditor() async {
|
||||||
bool deleted = await Navigator.push<bool>(
|
bool? deleted = await Navigator.push<bool>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => ProcessingEditEditor(
|
builder: (context) => ProcessingEditEditor(
|
||||||
@@ -222,7 +222,7 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
} else {
|
} else {
|
||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
Package p = await packageModel.getPackage(_package.id);
|
Package p = await packageModel.getPackage(_package!.id);
|
||||||
initPackage(p);
|
initPackage(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'processing_info.dart';
|
import 'processing_info.dart';
|
||||||
@@ -11,12 +11,12 @@ import 'processing_info.dart';
|
|||||||
typedef CallbackPackageSelect(Package package);
|
typedef CallbackPackageSelect(Package package);
|
||||||
|
|
||||||
class ProcessingListRow extends StatelessWidget {
|
class ProcessingListRow extends StatelessWidget {
|
||||||
final Package package;
|
final Package? package;
|
||||||
final CallbackPackageSelect callbackPackageSelect;
|
final CallbackPackageSelect? callbackPackageSelect;
|
||||||
final double dotSize = 15.0;
|
final double dotSize = 15.0;
|
||||||
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||||
|
|
||||||
ProcessingListRow({Key key, this.package, this.callbackPackageSelect})
|
ProcessingListRow({Key? key, this.package, this.callbackPackageSelect})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -24,7 +24,7 @@ class ProcessingListRow extends StatelessWidget {
|
|||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (callbackPackageSelect != null) {
|
if (callbackPackageSelect != null) {
|
||||||
callbackPackageSelect(package);
|
callbackPackageSelect!(package!);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
@@ -57,7 +57,7 @@ class ProcessingListRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
package.id == null ? '' : package.trackingID,
|
package!.id == null ? '' : package!.trackingID,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -65,7 +65,7 @@ class ProcessingListRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
package.market == null ? '' : package.market,
|
package!.market == null ? '' : package!.market,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -81,12 +81,12 @@ class ProcessingListRow extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(3.0),
|
padding: const EdgeInsets.all(3.0),
|
||||||
child: getStatus(package.status),
|
child: getStatus(package!.status),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
dateFormat.format(package.currentStatusDate),
|
dateFormat.format(package!.currentStatusDate),
|
||||||
style: new TextStyle(fontSize: 15.0, color: Colors.grey),
|
style: new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -76,9 +76,9 @@ class _ProfileCurrencyEditState extends State<ProfileCurrencyEdit> {
|
|||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
value: Currency.USD,
|
value: Currency.USD,
|
||||||
groupValue: _currency,
|
groupValue: _currency,
|
||||||
onChanged: (Currency value) {
|
onChanged: (Currency? value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_currency = value;
|
_currency = value!;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -94,9 +94,9 @@ class _ProfileCurrencyEditState extends State<ProfileCurrencyEdit> {
|
|||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
value: Currency.MMK,
|
value: Currency.MMK,
|
||||||
groupValue: _currency,
|
groupValue: _currency,
|
||||||
onChanged: (Currency value) {
|
onChanged: (Currency? value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_currency = value;
|
_currency = value!;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ import 'package:fcs/pages/widgets/multi_img_file.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
typedef void FindCallBack();
|
typedef void FindCallBack();
|
||||||
|
|
||||||
class ReceivingEditor extends StatefulWidget {
|
class ReceivingEditor extends StatefulWidget {
|
||||||
final Package package;
|
final Package? package;
|
||||||
const ReceivingEditor({this.package});
|
const ReceivingEditor({this.package});
|
||||||
@override
|
@override
|
||||||
_ReceivingEditorState createState() => _ReceivingEditorState();
|
_ReceivingEditorState createState() => _ReceivingEditorState();
|
||||||
@@ -30,8 +30,8 @@ class ReceivingEditor extends StatefulWidget {
|
|||||||
class _ReceivingEditorState extends State<ReceivingEditor> {
|
class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||||
Package package = Package();
|
Package package = Package();
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool _isNew;
|
late bool _isNew;
|
||||||
User user;
|
User? user;
|
||||||
TextEditingController _trackingIDCtl = new TextEditingController();
|
TextEditingController _trackingIDCtl = new TextEditingController();
|
||||||
TextEditingController _remarkCtl = new TextEditingController();
|
TextEditingController _remarkCtl = new TextEditingController();
|
||||||
MultiImgController _multiImgController = MultiImgController();
|
MultiImgController _multiImgController = MultiImgController();
|
||||||
@@ -41,7 +41,7 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
_isNew = widget.package == null;
|
_isNew = widget.package == null;
|
||||||
if (!_isNew) {
|
if (!_isNew) {
|
||||||
package = widget.package;
|
package = widget.package!;
|
||||||
_trackingIDCtl.text = package.trackingID;
|
_trackingIDCtl.text = package.trackingID;
|
||||||
_remarkCtl.text = package.remark;
|
_remarkCtl.text = package.remark;
|
||||||
_multiImgController.setImageUrls = package.photoUrls;
|
_multiImgController.setImageUrls = package.photoUrls;
|
||||||
@@ -71,7 +71,7 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: user != null ? user.fcsID : "",
|
text: user != null ? user!.fcsID : "",
|
||||||
labelTextKey: "receiving.fcs.id",
|
labelTextKey: "receiving.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
)),
|
)),
|
||||||
@@ -124,7 +124,7 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
|||||||
title: "Receiving",
|
title: "Receiving",
|
||||||
);
|
);
|
||||||
final namebox = DisplayText(
|
final namebox = DisplayText(
|
||||||
text: user != null ? user.name : "",
|
text: user != null ? user!.name : "",
|
||||||
labelTextKey: "receiving.consignee.name",
|
labelTextKey: "receiving.consignee.name",
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
);
|
);
|
||||||
@@ -199,17 +199,17 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_scan() async {
|
_scan() async {
|
||||||
PermissionStatus permission =
|
// PermissionStatus permission =
|
||||||
await PermissionHandler().checkPermissionStatus(PermissionGroup.camera);
|
// await PermissionHandler().checkPermissionStatus(PermissionGroup.camera);
|
||||||
if (permission != PermissionStatus.granted) {
|
// if (permission != PermissionStatus.granted) {
|
||||||
Map<PermissionGroup, PermissionStatus> permissions =
|
// Map<PermissionGroup, PermissionStatus> permissions =
|
||||||
await PermissionHandler()
|
// await PermissionHandler()
|
||||||
.requestPermissions([PermissionGroup.camera]);
|
// .requestPermissions([PermissionGroup.camera]);
|
||||||
if (permissions[PermissionGroup.camera] != PermissionStatus.granted) {
|
// if (permissions[PermissionGroup.camera] != PermissionStatus.granted) {
|
||||||
showMsgDialog(context, "Error", "Camera permission is not granted");
|
// showMsgDialog(context, "Error", "Camera permission is not granted");
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String barcode = await scanBarcode();
|
String barcode = await scanBarcode();
|
||||||
@@ -239,12 +239,12 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
|||||||
try {
|
try {
|
||||||
if (_isNew) {
|
if (_isNew) {
|
||||||
await packageModel.createReceiving(
|
await packageModel.createReceiving(
|
||||||
user, _p, _multiImgController.getAddedFile);
|
user!, _p, _multiImgController.getAddedFile);
|
||||||
} else {
|
} else {
|
||||||
_p.id = widget.package.id;
|
_p.id = widget.package!.id;
|
||||||
_p.photoUrls = package.photoUrls;
|
_p.photoUrls = package.photoUrls;
|
||||||
await packageModel.updateReceiving(
|
await packageModel.updateReceiving(
|
||||||
user,
|
user!,
|
||||||
_p,
|
_p,
|
||||||
_multiImgController.getAddedFile,
|
_multiImgController.getAddedFile,
|
||||||
_multiImgController.getDeletedUrl);
|
_multiImgController.getDeletedUrl);
|
||||||
@@ -269,9 +269,9 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
|||||||
var _package = Package(
|
var _package = Package(
|
||||||
trackingID: _trackingIDCtl.text,
|
trackingID: _trackingIDCtl.text,
|
||||||
remark: _remarkCtl.text,
|
remark: _remarkCtl.text,
|
||||||
fcsID: user.fcsID,
|
fcsID: user!.fcsID,
|
||||||
photoUrls: widget.package.photoUrls);
|
photoUrls: widget.package!.photoUrls);
|
||||||
return widget.package.isChangedForEdit(_package) ||
|
return widget.package!.isChangedForEdit(_package) ||
|
||||||
_multiImgController.getAddedFile.isNotEmpty ||
|
_multiImgController.getAddedFile.isNotEmpty ||
|
||||||
_multiImgController.getDeletedUrl.isNotEmpty;
|
_multiImgController.getDeletedUrl.isNotEmpty;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import 'package:fcs/pages/widgets/progress.dart';
|
|||||||
import 'package:fcs/pages/widgets/status_tree.dart';
|
import 'package:fcs/pages/widgets/status_tree.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
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';
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ import 'receiving_editor.dart';
|
|||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
|
|
||||||
class ReceivingInfo extends StatefulWidget {
|
class ReceivingInfo extends StatefulWidget {
|
||||||
final Package package;
|
final Package? package;
|
||||||
ReceivingInfo({this.package});
|
ReceivingInfo({this.package});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -30,14 +30,14 @@ class ReceivingInfo extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ReceivingInfoState extends State<ReceivingInfo> {
|
class _ReceivingInfoState extends State<ReceivingInfo> {
|
||||||
Package _package;
|
Package? _package;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
MultiImgController multiImgController = MultiImgController();
|
MultiImgController multiImgController = MultiImgController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
initPackage(widget.package);
|
initPackage(widget.package!);
|
||||||
}
|
}
|
||||||
|
|
||||||
initPackage(Package package) {
|
initPackage(Package package) {
|
||||||
@@ -57,22 +57,22 @@ class _ReceivingInfoState extends State<ReceivingInfo> {
|
|||||||
bool isCustomer = Provider.of<MainModel>(context).isCustomer();
|
bool isCustomer = Provider.of<MainModel>(context).isCustomer();
|
||||||
|
|
||||||
final trackingIdBox = DisplayText(
|
final trackingIdBox = DisplayText(
|
||||||
text: _package.trackingID,
|
text: _package!.trackingID,
|
||||||
labelTextKey: "package.tracking.id",
|
labelTextKey: "package.tracking.id",
|
||||||
iconData: MaterialCommunityIcons.barcode_scan,
|
iconData: MaterialCommunityIcons.barcode_scan,
|
||||||
);
|
);
|
||||||
var fcsIDBox = DisplayText(
|
var fcsIDBox = DisplayText(
|
||||||
text: _package.fcsID,
|
text: _package!.fcsID,
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
);
|
);
|
||||||
final customerNameBox = DisplayText(
|
final customerNameBox = DisplayText(
|
||||||
text: _package.userName,
|
text: _package!.userName,
|
||||||
labelTextKey: "package.create.name",
|
labelTextKey: "package.create.name",
|
||||||
iconData: Icons.perm_identity,
|
iconData: Icons.perm_identity,
|
||||||
);
|
);
|
||||||
final remarkBox = DisplayText(
|
final remarkBox = DisplayText(
|
||||||
text: _package.remark ?? "-",
|
text: _package!.remark ?? "-",
|
||||||
labelTextKey: "package.edit.remark",
|
labelTextKey: "package.edit.remark",
|
||||||
iconData: Entypo.new_message,
|
iconData: Entypo.new_message,
|
||||||
);
|
);
|
||||||
@@ -123,10 +123,10 @@ class _ReceivingInfoState extends State<ReceivingInfo> {
|
|||||||
fcsIDBox,
|
fcsIDBox,
|
||||||
customerNameBox,
|
customerNameBox,
|
||||||
remarkBox,
|
remarkBox,
|
||||||
_package.photoUrls.length == 0 ? Container() : img,
|
_package!.photoUrls.length == 0 ? Container() : img,
|
||||||
StatusTree(
|
StatusTree(
|
||||||
shipmentHistory: _package.shipmentHistory,
|
shipmentHistory: _package!.shipmentHistory,
|
||||||
currentStatus: _package.status),
|
currentStatus: _package!.status),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
)
|
)
|
||||||
@@ -149,7 +149,7 @@ class _ReceivingInfoState extends State<ReceivingInfo> {
|
|||||||
);
|
);
|
||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
var pkg = await packageModel.getPackage(widget.package.id);
|
var pkg = await packageModel.getPackage(widget.package!.id);
|
||||||
initPackage(pkg);
|
initPackage(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ class _ReceivingInfoState extends State<ReceivingInfo> {
|
|||||||
try {
|
try {
|
||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
await packageModel.deleteReceiving(_package);
|
await packageModel.deleteReceiving(_package!);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'receiving_info.dart';
|
import 'receiving_info.dart';
|
||||||
@@ -11,12 +11,12 @@ import 'receiving_info.dart';
|
|||||||
typedef CallbackPackageSelect(Package package);
|
typedef CallbackPackageSelect(Package package);
|
||||||
|
|
||||||
class ReceivingListRow extends StatelessWidget {
|
class ReceivingListRow extends StatelessWidget {
|
||||||
final Package package;
|
final Package? package;
|
||||||
final CallbackPackageSelect callbackPackageSelect;
|
final CallbackPackageSelect? callbackPackageSelect;
|
||||||
final double dotSize = 15.0;
|
final double dotSize = 15.0;
|
||||||
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||||
|
|
||||||
ReceivingListRow({Key key, this.package, this.callbackPackageSelect})
|
ReceivingListRow({Key? key, this.package, this.callbackPackageSelect})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -24,7 +24,7 @@ class ReceivingListRow extends StatelessWidget {
|
|||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (callbackPackageSelect != null) {
|
if (callbackPackageSelect != null) {
|
||||||
callbackPackageSelect(package);
|
callbackPackageSelect!(package!);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
@@ -55,7 +55,7 @@ class ReceivingListRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
package.id == null ? '' : package.trackingID,
|
package!.id == null ? '' : package!.trackingID,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -63,7 +63,7 @@ class ReceivingListRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
package.market == null ? '' : package.market,
|
package!.market == null ? '' : package!.market,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -79,12 +79,12 @@ class ReceivingListRow extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(3.0),
|
padding: const EdgeInsets.all(3.0),
|
||||||
child: getStatus(package.status),
|
child: getStatus(package!.status),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
dateFormat.format(package.currentStatusDate),
|
dateFormat.format(package!.currentStatusDate),
|
||||||
style: new TextStyle(fontSize: 15.0, color: Colors.grey),
|
style: new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class DisplayText extends StatelessWidget {
|
class DisplayText extends StatelessWidget {
|
||||||
final String text;
|
final String? text;
|
||||||
final String labelTextKey;
|
final String? labelTextKey;
|
||||||
final IconData iconData;
|
final IconData? iconData;
|
||||||
final int maxLines;
|
final int? maxLines;
|
||||||
final bool withBorder;
|
final bool? withBorder;
|
||||||
final Color borderColor;
|
final Color? borderColor;
|
||||||
final Widget icon;
|
final Widget? icon;
|
||||||
|
|
||||||
const DisplayText({
|
const DisplayText({
|
||||||
Key key,
|
Key? key,
|
||||||
this.text,
|
this.text,
|
||||||
this.labelTextKey,
|
this.labelTextKey,
|
||||||
this.iconData,
|
this.iconData,
|
||||||
@@ -44,7 +44,9 @@ class DisplayText extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
iconData == null
|
iconData == null
|
||||||
? icon == null ? Container() : icon
|
? icon == null
|
||||||
|
? Container()
|
||||||
|
: icon!
|
||||||
: Padding(
|
: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: .0, right: 15.0, top: 8.0, bottom: 8.0),
|
left: .0, right: 15.0, top: 8.0, bottom: 8.0),
|
||||||
@@ -60,13 +62,13 @@ class DisplayText extends StatelessWidget {
|
|||||||
labelTextKey == null
|
labelTextKey == null
|
||||||
? Container()
|
? Container()
|
||||||
: Text(
|
: Text(
|
||||||
AppTranslations.of(context).text(labelTextKey),
|
AppTranslations.of(context).text(labelTextKey!),
|
||||||
style: labelStyle,
|
style: labelStyle,
|
||||||
),
|
),
|
||||||
text == null
|
text == null
|
||||||
? Container()
|
? Container()
|
||||||
: Text(
|
: Text(
|
||||||
text,
|
text!,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -49,10 +49,11 @@ dependencies:
|
|||||||
# barcode_scan: ^2.0.2
|
# barcode_scan: ^2.0.2
|
||||||
barcode_scan2: ^4.1.4
|
barcode_scan2: ^4.1.4
|
||||||
flutter_pdfview: ^1.2.1
|
flutter_pdfview: ^1.2.1
|
||||||
# flutter_local_notifications: ^8.1.1+1
|
flutter_local_notifications: ^8.2.0
|
||||||
share: ^2.0.4
|
share: ^2.0.4
|
||||||
cached_network_image: ^3.1.0
|
cached_network_image: ^3.1.0
|
||||||
flutter_cache_manager: ^3.1.2
|
flutter_cache_manager: ^3.1.2
|
||||||
|
flutter_vector_icons: ^1.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user