cleanup code
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CargoTable extends StatefulWidget {
|
||||
@@ -68,7 +66,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
c.name ?? "",
|
||||
style: textStyle,
|
||||
)),
|
||||
DataCell(c.qty == null || c.qty == 0
|
||||
DataCell(c.qty == 0
|
||||
? Center(
|
||||
child: Text(
|
||||
"-",
|
||||
@@ -82,8 +80,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
),
|
||||
)),
|
||||
DataCell(
|
||||
Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2),
|
||||
style: textStyle),
|
||||
Text(c.weight.toStringAsFixed(2), style: textStyle),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/dialog_input.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef OnRemove(CargoType cargoType);
|
||||
@@ -94,7 +93,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
c.isCutomDuty!
|
||||
? GestureDetector(
|
||||
onTap: () async {
|
||||
String _t = await showDialog(
|
||||
String? _t = await showDialog(
|
||||
context: context,
|
||||
builder: (_) => DialogInput(
|
||||
label: "cargo.qty", value: c.qty.toString()));
|
||||
@@ -114,7 +113,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
||||
),
|
||||
child: new Text(
|
||||
c.qty == null ? "" : c.qty.toString(),
|
||||
c.qty.toString(),
|
||||
style: textStyle,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
@@ -140,7 +139,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
return;
|
||||
}
|
||||
|
||||
String _t = await showDialog(
|
||||
String? _t = await showDialog(
|
||||
context: context,
|
||||
builder: (_) => DialogInput(
|
||||
label: "cargo.weight",
|
||||
@@ -161,9 +160,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
border: Border.all(color: primaryColor),
|
||||
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
||||
),
|
||||
child: Text(
|
||||
c.weight == null ? "0.00" : c.weight.toStringAsFixed(2),
|
||||
style: textStyle),
|
||||
child: Text(c.weight.toStringAsFixed(2), style: textStyle),
|
||||
),
|
||||
),
|
||||
widget.onRemove == null
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -78,7 +77,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
style: textStyle,
|
||||
),
|
||||
new Text(
|
||||
c.qty == null || c.qty == 0 ? "" : " x ${c.qty.toString()}",
|
||||
c.qty == 0 ? "" : " x ${c.qty.toString()}",
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
],
|
||||
@@ -135,9 +134,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
totalWeight = _t;
|
||||
this.remainingWeight = this.totalWeight - _total;
|
||||
widget.cargoTypes!.forEach((c) {
|
||||
if (c.qty == null) {
|
||||
this._cargos.add(c);
|
||||
}
|
||||
this._cargos.add(c);
|
||||
});
|
||||
this._cargos.forEach((c) {
|
||||
_list.add(c.name!);
|
||||
|
||||
@@ -110,6 +110,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
name: _carton!.senderName);
|
||||
_selectedMixBoxType = _carton!.mixBoxType;
|
||||
this._mixCartons =
|
||||
// ignore: unnecessary_null_comparison
|
||||
_carton!.mixCartons == null ? [] : List.from(_carton!.mixCartons);
|
||||
bool isMixBox = _carton!.cartonType == carton_mix_box;
|
||||
bool isFromPackages = _carton!.cartonType == carton_from_packages;
|
||||
@@ -665,11 +666,11 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
||||
|
||||
if (isFromPackages) {
|
||||
_loadPackages();
|
||||
c.value.packages = _carton!.packages;
|
||||
Carton _c = await Navigator.push(
|
||||
Carton? _c = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => PackageCartonEditor(
|
||||
@@ -791,10 +792,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_updateCargo(CargoType cargo) {
|
||||
setState(() {
|
||||
var _c = _cargoTypes.firstWhere((e) => e.id == cargo.id);
|
||||
if (_c != null) {
|
||||
_c.weight = cargo.weight;
|
||||
_c.qty = cargo.qty;
|
||||
}
|
||||
_c.weight = cargo.weight;
|
||||
_c.qty = cargo.qty;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -880,7 +879,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
}
|
||||
|
||||
_addMixCarton(Carton carton) {
|
||||
if (carton == null) return;
|
||||
if (this._mixCartons.any((c) => c.id == carton.id)) return;
|
||||
setState(() {
|
||||
this._mixCartons.add(carton);
|
||||
|
||||
@@ -272,11 +272,11 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
final cargoTableBox = CargoTable(
|
||||
cargoTypes: _box!.cargoTypes,
|
||||
);
|
||||
final mixCartonNumberBox = DisplayText(
|
||||
text: _box!.mixCartonNumber,
|
||||
labelTextKey: "box.mix.carton",
|
||||
iconData: MaterialCommunityIcons.package,
|
||||
);
|
||||
// final mixCartonNumberBox = DisplayText(
|
||||
// text: _box!.mixCartonNumber,
|
||||
// labelTextKey: "box.mix.carton",
|
||||
// iconData: MaterialCommunityIcons.package,
|
||||
// );
|
||||
|
||||
final mixTypeBox = Container(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
|
||||
@@ -293,11 +293,9 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
_updateCargo(CargoType cargo) {
|
||||
setState(() {
|
||||
var _c = _cargoTypes.firstWhere((e) => e.id == cargo.id);
|
||||
if (_c != null) {
|
||||
_c.weight = cargo.weight;
|
||||
_c.qty = cargo.qty;
|
||||
}
|
||||
});
|
||||
_c.weight = cargo.weight;
|
||||
_c.qty = cargo.qty;
|
||||
});
|
||||
}
|
||||
|
||||
_creatCarton() async {
|
||||
|
||||
Reference in New Issue
Block a user