update carton info

This commit is contained in:
tzw
2024-02-09 13:49:18 +06:30
parent e485e5792e
commit 2d912a20aa
16 changed files with 300 additions and 914 deletions

View File

@@ -0,0 +1,116 @@
import 'package:fcs/domain/entities/cargo_type.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/input_text.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';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
class CargoTypeEditor extends StatefulWidget {
final CargoType? cargo;
CargoTypeEditor({this.cargo});
@override
_CargoTypeEditorState createState() => _CargoTypeEditorState();
}
class _CargoTypeEditorState extends State<CargoTypeEditor> {
TextEditingController _weightController = new TextEditingController();
bool _isLoading = false;
CargoType? _cargo;
@override
void initState() {
super.initState();
if (widget.cargo != null) {
_cargo = widget.cargo;
_weightController.text = _cargo!.weight.toStringAsFixed(2);
} else {
_loadDefalut();
}
}
_loadDefalut() {
ShipmentRateModel shipmentRateModel =
Provider.of<ShipmentRateModel>(context, listen: false);
_cargo = shipmentRateModel.rate.defaultCargoType.clone();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
ShipmentRateModel shipmentRateModel =
Provider.of<ShipmentRateModel>(context);
List<CargoType> cargos = shipmentRateModel.rate.cargoTypes;
final rateBox = InputText(
labelTextKey: 'cargo.weight',
iconData: FontAwesomeIcons.weightHanging,
textInputType: TextInputType.number,
controller: _weightController);
var cargoTypeBox = LocalDropdown<CargoType>(
callback: (v) {
setState(() {
_cargo = v;
});
},
labelKey: "cargo.type",
iconData: Icons.text_format,
selectedValue: _cargo!,
values: cargos,
);
final saveBtn = fcsButton(
context,
getLocalString(context, 'box.cargo.save.btn'),
callack: () {
_cargo!.weight = double.tryParse(_weightController.text) ?? 0;
Navigator.pop(context, _cargo);
},
);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon:
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: LocalText(
context,
"cargo.form.title",
fontSize: 20,
color: primaryColor,
)),
body: Container(
padding: EdgeInsets.all(18),
child: ListView(
shrinkWrap: true,
children: <Widget>[
cargoTypeBox,
rateBox,
SizedBox(height: 40),
saveBtn,
SizedBox(height: 20),
],
),
),
),
);
}
}

View File

@@ -2,7 +2,7 @@ import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/carton/cargo_type_editor.dart';
import 'package:fcs/pages/shipment/cargo_type_editor.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';