update
This commit is contained in:
@@ -11,7 +11,7 @@ import 'package:provider/provider.dart';
|
||||
import 'model/shipment_rate_model.dart';
|
||||
|
||||
class CargoEditor extends StatefulWidget {
|
||||
final CargoType cargo;
|
||||
final CargoType? cargo;
|
||||
CargoEditor({this.cargo});
|
||||
|
||||
@override
|
||||
@@ -23,14 +23,14 @@ class _CargoEditorState extends State<CargoEditor> {
|
||||
TextEditingController _rateController = new TextEditingController();
|
||||
|
||||
bool _isLoading = false;
|
||||
CargoType _cargo;
|
||||
late CargoType _cargo;
|
||||
bool _isNew = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.cargo != null) {
|
||||
_cargo = widget.cargo;
|
||||
_cargo = widget.cargo!;
|
||||
_descController.text = _cargo.name;
|
||||
_rateController.text = _cargo.rate.toStringAsFixed(2);
|
||||
} else {
|
||||
@@ -71,7 +71,7 @@ class _CargoEditorState extends State<CargoEditor> {
|
||||
},
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(AppTranslations.of(context).text("cargo.form.title")),
|
||||
title: Text(AppTranslations.of(context)!.text("cargo.form.title")),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
@@ -114,7 +114,7 @@ class _CargoEditorState extends State<CargoEditor> {
|
||||
if (_isNew) {
|
||||
await shipmentRateModel.addCargoType(_cargo);
|
||||
} else {
|
||||
_cargo.id = widget.cargo.id;
|
||||
_cargo.id = this._cargo.id;
|
||||
await shipmentRateModel.updateCargoType(_cargo);
|
||||
}
|
||||
Navigator.pop(context);
|
||||
@@ -138,7 +138,7 @@ class _CargoEditorState extends State<CargoEditor> {
|
||||
try {
|
||||
var shipmentRateModel =
|
||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||
await shipmentRateModel.deleteCargoType(widget.cargo.id);
|
||||
await shipmentRateModel.deleteCargoType(this._cargo.id);
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
@@ -155,7 +155,7 @@ class _CargoEditorState extends State<CargoEditor> {
|
||||
} else {
|
||||
CargoType _cargo = CargoType(
|
||||
name: _descController.text, rate: double.parse(_rateController.text));
|
||||
return widget.cargo.isChangedForEdit(_cargo);
|
||||
return this._cargo.isChangedForEdit(_cargo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'cargo_editor.dart';
|
||||
import 'model/shipment_rate_model.dart';
|
||||
|
||||
class CargoTypeList extends StatefulWidget {
|
||||
const CargoTypeList({Key key}) : super(key: key);
|
||||
const CargoTypeList({Key? key}) : super(key: key);
|
||||
@override
|
||||
_CargoTypeListState createState() => _CargoTypeListState();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'package:provider/provider.dart';
|
||||
import 'model/shipment_rate_model.dart';
|
||||
|
||||
class CustomEditor extends StatefulWidget {
|
||||
final CargoType custom;
|
||||
final CargoType? custom;
|
||||
CustomEditor({this.custom});
|
||||
|
||||
@override
|
||||
@@ -32,7 +32,7 @@ class _CustomEditorState extends State<CustomEditor> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.custom != null) {
|
||||
_custom = widget.custom;
|
||||
_custom = widget.custom!;
|
||||
_productController.text = _custom.name;
|
||||
_feeController.text = _custom.customDutyFee.toStringAsFixed(2);
|
||||
_shipmentRateController.text =
|
||||
@@ -83,7 +83,7 @@ class _CustomEditorState extends State<CustomEditor> {
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title:
|
||||
Text(AppTranslations.of(context).text("rate.custom.form.title")),
|
||||
Text(AppTranslations.of(context)!.text("rate.custom.form.title")),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
@@ -129,7 +129,7 @@ class _CustomEditorState extends State<CustomEditor> {
|
||||
if (_isNew) {
|
||||
await shipmentRateModel.addCustomDuty(_customduty);
|
||||
} else {
|
||||
_customduty.id = widget.custom.id;
|
||||
_customduty.id = this._custom.id;
|
||||
await shipmentRateModel.updateCustomDuty(_customduty);
|
||||
}
|
||||
Navigator.pop(context);
|
||||
@@ -154,7 +154,7 @@ class _CustomEditorState extends State<CustomEditor> {
|
||||
try {
|
||||
var shipmentRateModel =
|
||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||
await shipmentRateModel.deleteCustomDuty(widget.custom.id);
|
||||
await shipmentRateModel.deleteCustomDuty(this._custom.id);
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
@@ -175,7 +175,7 @@ class _CustomEditorState extends State<CustomEditor> {
|
||||
name: _productController.text,
|
||||
customDutyFee: double.parse(_feeController.text),
|
||||
rate: double.parse(_shipmentRateController.text));
|
||||
return widget.custom.isChangedForEditCustomDuty(_customduty);
|
||||
return this._custom.isChangedForEditCustomDuty(_customduty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/rates/custom_editor.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@@ -14,8 +9,8 @@ import 'package:provider/provider.dart';
|
||||
import 'model/shipment_rate_model.dart';
|
||||
|
||||
class CustomList extends StatefulWidget {
|
||||
final bool selected;
|
||||
const CustomList({Key key, this.selected}) : super(key: key);
|
||||
final bool? selected;
|
||||
const CustomList({Key? key, this.selected}) : super(key: key);
|
||||
@override
|
||||
_CustomListState createState() => _CustomListState();
|
||||
}
|
||||
@@ -28,7 +23,7 @@ class _CustomListState extends State<CustomList> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.selected != null) {
|
||||
_selected = widget.selected;
|
||||
_selected = widget.selected!;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,13 @@ import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
|
||||
typedef SelectionCallback(CustomDuty custom);
|
||||
|
||||
class CustomRow extends StatelessWidget {
|
||||
final CustomDuty custom;
|
||||
final SelectionCallback selectionCallback;
|
||||
const CustomRow({Key key, this.custom, this.selectionCallback})
|
||||
final SelectionCallback? selectionCallback;
|
||||
const CustomRow({Key? key, required this.custom, this.selectionCallback})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -19,7 +18,7 @@ class CustomRow extends StatelessWidget {
|
||||
return InkWell(
|
||||
onTap: selectionCallback == null
|
||||
? null
|
||||
: () => this.selectionCallback(custom),
|
||||
: () => this.selectionCallback!(custom),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
@@ -40,8 +39,8 @@ class CustomRow extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget line(BuildContext context, String text,
|
||||
{IconData iconData, Color color, double fontSize}) {
|
||||
Widget line(BuildContext context, String? text,
|
||||
{IconData? iconData, Color? color, double? fontSize}) {
|
||||
return Row(
|
||||
children: [
|
||||
iconData == null
|
||||
@@ -55,7 +54,7 @@ class CustomRow extends StatelessWidget {
|
||||
context,
|
||||
text ?? "",
|
||||
fontSize: fontSize ?? 14,
|
||||
color: color,
|
||||
color: color ?? Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,24 +1,16 @@
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/rates/custom_editor.dart';
|
||||
import 'package:fcs/pages/rates/discount_by_weight_editor.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
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:provider/provider.dart';
|
||||
|
||||
import 'custom_row.dart';
|
||||
import 'model/shipment_rate_model.dart';
|
||||
|
||||
class DiscountByWeightList extends StatefulWidget {
|
||||
const DiscountByWeightList({Key key}) : super(key: key);
|
||||
const DiscountByWeightList({Key? key}) : super(key: key);
|
||||
@override
|
||||
_DiscountByWeightListState createState() => _DiscountByWeightListState();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DiscountByWeightEditor extends StatefulWidget {
|
||||
final DiscountByWeight discountByWeight;
|
||||
final DiscountByWeight? discountByWeight;
|
||||
DiscountByWeightEditor({this.discountByWeight});
|
||||
|
||||
@override
|
||||
@@ -23,14 +23,14 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
||||
TextEditingController _discountController = new TextEditingController();
|
||||
|
||||
bool _isLoading = false;
|
||||
bool _isNew;
|
||||
bool _isNew = false;
|
||||
DiscountByWeight _discountByWeight = new DiscountByWeight();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.discountByWeight != null) {
|
||||
_discountByWeight = widget.discountByWeight;
|
||||
_discountByWeight = widget.discountByWeight!;
|
||||
_weightController.text = _discountByWeight.weight.toStringAsFixed(2);
|
||||
_discountController.text = _discountByWeight.discount.toString();
|
||||
_isNew = false;
|
||||
@@ -73,7 +73,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
||||
},
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(AppTranslations.of(context).text("discount.new")),
|
||||
title: Text(AppTranslations.of(context)!.text("discount.new")),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
@@ -117,7 +117,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
||||
if (_isNew) {
|
||||
await shipmentRateModel.addDiscountByWeight(_discount);
|
||||
} else {
|
||||
_discount.id = widget.discountByWeight.id;
|
||||
_discount.id = this._discountByWeight.id;
|
||||
await shipmentRateModel.updateDiscountByWeight(_discount);
|
||||
}
|
||||
Navigator.pop(context);
|
||||
@@ -143,7 +143,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
||||
var shipmentRateModel =
|
||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||
await shipmentRateModel
|
||||
.deleteDiscountByWeight(widget.discountByWeight.id);
|
||||
.deleteDiscountByWeight(this._discountByWeight.id);
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
@@ -161,7 +161,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
||||
DiscountByWeight _discount = DiscountByWeight(
|
||||
weight: double.parse(_weightController.text),
|
||||
discount: double.parse(_discountController.text));
|
||||
return widget.discountByWeight.isChangedForEdit(_discount);
|
||||
return this._discountByWeight.isChangedForEdit(_discount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/rate.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
@@ -12,7 +11,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/flutter_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ShipmentRatesCal extends StatefulWidget {
|
||||
@@ -24,7 +22,7 @@ class ShipmentRatesCal extends StatefulWidget {
|
||||
|
||||
class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
||||
bool _isLoading = false;
|
||||
CargoType _cargoType;
|
||||
late CargoType _cargoType;
|
||||
TextEditingController _widthController = new TextEditingController();
|
||||
TextEditingController _heightController = new TextEditingController();
|
||||
TextEditingController _lengthController = new TextEditingController();
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||
import 'package:fcs/domain/entities/rate.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -14,8 +10,6 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../main/util.dart';
|
||||
import 'cargo_editor.dart';
|
||||
import 'custom_editor.dart';
|
||||
|
||||
class ShipmentRatesEdit extends StatefulWidget {
|
||||
ShipmentRatesEdit();
|
||||
@@ -32,7 +26,7 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
||||
TextEditingController _diffDiscountWeight = new TextEditingController();
|
||||
TextEditingController _diffWeightRate = new TextEditingController();
|
||||
|
||||
Rate rate;
|
||||
late Rate rate;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -99,7 +93,7 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
||||
},
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(AppTranslations.of(context).text("rate.edit.title")),
|
||||
title: Text(AppTranslations.of(context)!.text("rate.edit.title")),
|
||||
),
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(18),
|
||||
|
||||
Reference in New Issue
Block a user