cleanup code
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/shipment.dart';
|
||||
import 'package:fcs/domain/entities/user.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
@@ -8,7 +7,6 @@ import 'package:fcs/pages/staff/model/staff_model.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
||||
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_title.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
@@ -42,7 +40,6 @@ class _ShipmentAssignState extends State<ShipmentAssign> {
|
||||
bool _isLoading = false;
|
||||
var now = new DateTime.now();
|
||||
|
||||
String? _selectedShipmentType;
|
||||
User? _user;
|
||||
List<User>? _users;
|
||||
|
||||
@@ -53,13 +50,10 @@ class _ShipmentAssignState extends State<ShipmentAssign> {
|
||||
_shipment = widget.shipment;
|
||||
_loadUsers();
|
||||
|
||||
_selectedShipmentType = _shipment!.shipmentType;
|
||||
_fromTimeEditingController.text = _shipment!.pickupTimeStart!;
|
||||
_toTimeEditingController.text = _shipment!.pickupTimeEnd!;
|
||||
_pickupDate.text = dateFormatter.format(_shipment!.pickupDate ?? now);
|
||||
_handlingFee.text = _shipment!.handlingFee != null
|
||||
? _shipment!.handlingFee.toString()
|
||||
: "0";
|
||||
_handlingFee.text = _shipment!.handlingFee.toString();
|
||||
}
|
||||
|
||||
_loadUsers() async {
|
||||
@@ -74,12 +68,7 @@ class _ShipmentAssignState extends State<ShipmentAssign> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
|
||||
final shipmentNumberBox = getShipmentNumberStatus(context, _shipment!);
|
||||
bool isLocalPickup = _selectedShipmentType == shipment_local_pickup;
|
||||
bool isCourierPickup = _selectedShipmentType == shipment_courier_pickup;
|
||||
bool isLocalDropoff = _selectedShipmentType == shipment_local_dropoff;
|
||||
bool isCourierDropoff = _selectedShipmentType == shipment_courier_dropoff;
|
||||
|
||||
var usersBox = LocalDropdown<User>(
|
||||
callback: (v) {
|
||||
|
||||
@@ -50,9 +50,9 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
||||
if (widget.box != null) {
|
||||
_box = widget.box;
|
||||
_isNew = false;
|
||||
_lengthCtl.text = _box!.length != null ? _box!.length.toString() : '';
|
||||
_widthCtl.text = _box!.width != null ? _box!.width.toString() : '';
|
||||
_heightCtl.text = _box!.height != null ? _box!.height.toString() : '';
|
||||
_lengthCtl.text = _box!.length.toString();
|
||||
_widthCtl.text = _box!.width.toString();
|
||||
_heightCtl.text = _box!.height.toString();
|
||||
} else {
|
||||
var shipmentModel =
|
||||
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||
@@ -86,7 +86,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
||||
|
||||
final shipmentWeightBox = DisplayText(
|
||||
labelTextKey: "shipment.box.shipment.weight",
|
||||
text: shipmentWeight == null ? "" : shipmentWeight.toStringAsFixed(0),
|
||||
text: shipmentWeight.toStringAsFixed(0),
|
||||
iconData: MaterialCommunityIcons.weight,
|
||||
);
|
||||
|
||||
@@ -212,7 +212,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
||||
}
|
||||
|
||||
List<DataRow> getCargoRows(BuildContext context) {
|
||||
if (_box!.cargoTypes == null) {
|
||||
if (_box!.cargoTypes.isEmpty) {
|
||||
return [];
|
||||
}
|
||||
double total = 0;
|
||||
@@ -238,8 +238,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2),
|
||||
style: textStyle),
|
||||
Text(c.weight.toStringAsFixed(2), style: textStyle),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.remove_circle,
|
||||
@@ -281,7 +280,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
||||
return rows;
|
||||
}
|
||||
|
||||
_addCargo(CargoType cargo) {
|
||||
_addCargo(CargoType? cargo) {
|
||||
if (cargo == null) return;
|
||||
setState(() {
|
||||
_box!.cargoTypes.remove(cargo);
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons_null_safety/flutter_icons_null_safety.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -279,19 +279,19 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
_addBox(Carton box) {
|
||||
_addBox(Carton? box) {
|
||||
if (box == null) return;
|
||||
box.cartonType = carton_from_shipments;
|
||||
_shipment!.boxes.add(box);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_saveBox(Carton box) {
|
||||
_saveBox(Carton? box) {
|
||||
if (box == null) return;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_removeBox(Carton box) {
|
||||
_removeBox(Carton? box) {
|
||||
if (box == null) return;
|
||||
_shipment!.boxes.remove(box);
|
||||
setState(() {});
|
||||
|
||||
@@ -53,14 +53,7 @@ class _ShipmentInfoState extends State<ShipmentInfo> {
|
||||
TextEditingController _noOfPackageEditingController =
|
||||
new TextEditingController();
|
||||
TextEditingController _weightEditingController = new TextEditingController();
|
||||
TextEditingController _recipientNameEditingController =
|
||||
new TextEditingController();
|
||||
TextEditingController _recipientPhoneEditingController =
|
||||
new TextEditingController();
|
||||
TextEditingController _recipientAddressEditingController =
|
||||
new TextEditingController();
|
||||
TextEditingController _pickupDate = new TextEditingController();
|
||||
TextEditingController _handlingFeeController = new TextEditingController();
|
||||
|
||||
Shipment? _shipment;
|
||||
bool _isLoading = false;
|
||||
@@ -77,11 +70,8 @@ class _ShipmentInfoState extends State<ShipmentInfo> {
|
||||
_addressEditingController.text = _shipment!.address ?? "";
|
||||
_fromTimeEditingController.text = _shipment!.pickupTimeStart ?? "";
|
||||
_toTimeEditingController.text = _shipment!.pickupTimeEnd ?? "";
|
||||
_noOfPackageEditingController.text = _shipment!.numberOfPackage != null
|
||||
? _shipment!.numberOfPackage.toString()
|
||||
: "";
|
||||
_weightEditingController.text =
|
||||
_shipment!.weight != null ? _shipment!.weight.toString() : "";
|
||||
_noOfPackageEditingController.text = _shipment!.numberOfPackage.toString();
|
||||
_weightEditingController.text = _shipment!.weight.toString();
|
||||
_pickupDate.text = dateFormatter.format(_shipment!.pickupDate ?? now);
|
||||
}
|
||||
|
||||
@@ -362,7 +352,7 @@ class _ShipmentInfoState extends State<ShipmentInfo> {
|
||||
}
|
||||
|
||||
List<Widget> getBoxList(BuildContext context, List<Carton> boxes) {
|
||||
if (boxes == null) return [];
|
||||
if (boxes.isEmpty) return [];
|
||||
return boxes.asMap().entries.map((_box) {
|
||||
return Row(
|
||||
children: [
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/local_popup_menu_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_popupmenu.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
|
||||
Reference in New Issue
Block a user