This commit is contained in:
PhyoThandar
2020-10-20 18:45:18 +06:30
parent 4884311d47
commit 3cf530d2cb
5 changed files with 140 additions and 66 deletions

View File

@@ -23,16 +23,19 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
TextEditingController _discountController = new TextEditingController();
bool _isLoading = false;
bool _isNew = false;
bool _isNew;
DiscountByWeight _discountByWeight = new DiscountByWeight();
@override
void initState() {
super.initState();
if (widget.discountByWeight != null) {
_discountByWeight = widget.discountByWeight;
_discountByWeight = widget.discountByWeight;
_weightController.text = _discountByWeight.weight.toString();
_discountController.text = _discountByWeight.discount.toString();
_isNew = false;
} else {
_isNew = true;
}
}
@@ -131,7 +134,8 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
try {
var shipmentRateModel =
Provider.of<ShipmentRateModel>(context, listen: false);
await shipmentRateModel.deleteDiscountByWeight(widget.discountByWeight.id);
await shipmentRateModel
.deleteDiscountByWeight(widget.discountByWeight.id);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());

View File

@@ -6,6 +6,7 @@ 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';
import 'package:fcs/pages/widgets/length_picker.dart';
import 'package:fcs/pages/widgets/local_dropdown.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
@@ -79,6 +80,7 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
@override
Widget build(BuildContext context) {
var shipmentRateModel = Provider.of<ShipmentRateModel>(context);
List<CargoType> cargos = shipmentRateModel.rate.cargoTypes;
final lengthBox = LengthPicker(
controller: _lengthController,
@@ -119,6 +121,18 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
textInputType: TextInputType.number,
);
var cargoTypeBox = LocalDropdown<CargoType>(
callback: (v) {
setState(() {
_cargoType = v;
});
},
labelKey: "cargo.type",
iconData: Icons.text_format,
selectedValue: _cargoType,
values: cargos,
);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
@@ -137,38 +151,8 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
padding: const EdgeInsets.all(8.0),
child: ListView(
children: <Widget>[
Container(
padding: EdgeInsets.only(top: 5, left: 25),
child: Row(
children: <Widget>[
Expanded(
child: LocalText(context, 'rate.cargo.type',
color: Colors.grey, fontSize: 15)),
Container(
width: 150.0,
child: DropdownButtonFormField(
value: _cargoType,
decoration: InputDecoration(
fillColor: Colors.white,
hintText: shipmentRateModel.rate.cargoTypes[0].name,
hintStyle: TextStyle(color: Colors.black87)),
items: shipmentRateModel.rate.cargoTypes
.map((e) =>
DropdownMenuItem(child: Text(e.name), value: e))
.toList(),
onChanged: (selected) => {
setState(() {
_cargoType = selected;
_calShipmentWeight();
})
},
),
),
],
),
),
cargoTypeBox,
actualWeightBox,
// LocalTitle(textKey: "box.dimension"),
dimBox,
shipmentWeightBox,
SizedBox(height: 50),