update rate
This commit is contained in:
@@ -34,6 +34,8 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
||||
TextEditingController _deliveryFee = new TextEditingController();
|
||||
TextEditingController _volumetricRatio = new TextEditingController();
|
||||
|
||||
bool _isNew = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -89,208 +91,207 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
||||
feeBox,
|
||||
ratioBox,
|
||||
SizedBox(height: 10),
|
||||
ExpansionTile(
|
||||
title: Text(
|
||||
'Cargo Types',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columnSpacing: 50,
|
||||
columns: [
|
||||
MyDataColumn(
|
||||
label: Text("Cargo Type",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[600]))),
|
||||
MyDataColumn(
|
||||
label: Text("Rate",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[600]))),
|
||||
MyDataColumn(
|
||||
label: Text("Delete",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[600]))),
|
||||
],
|
||||
rows: getCargoRows(
|
||||
shipmentRateModel.rate.cargoTypes),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding:
|
||||
EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Container(
|
||||
width: 120,
|
||||
height: 40,
|
||||
child: FloatingActionButton.extended(
|
||||
materialTapTargetSize:
|
||||
MaterialTapTargetSize.shrinkWrap,
|
||||
icon: Icon(Icons.add),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => CargoEditor()),
|
||||
);
|
||||
},
|
||||
label: Text(
|
||||
'Add Cargo',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text(
|
||||
'Custom Duties',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columnSpacing: 50,
|
||||
columns: [
|
||||
MyDataColumn(
|
||||
label: Text("Produt Type",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[600]))),
|
||||
MyDataColumn(
|
||||
label: Text("Fee",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[600]))),
|
||||
MyDataColumn(
|
||||
label: Text("Delete",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[600]))),
|
||||
],
|
||||
rows: getCustomsRows(
|
||||
shipmentRateModel.rate.customDuties),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding:
|
||||
EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Container(
|
||||
width: 120,
|
||||
height: 40,
|
||||
child: FloatingActionButton.extended(
|
||||
materialTapTargetSize:
|
||||
MaterialTapTargetSize.shrinkWrap,
|
||||
icon: Icon(Icons.add),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => CustomEditor()),
|
||||
);
|
||||
},
|
||||
label: Text(
|
||||
'Add Custom\nDuty',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text(
|
||||
'Discounts by weight',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columnSpacing: 30,
|
||||
columns: [
|
||||
MyDataColumn(
|
||||
label: Text("Weight",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[600]))),
|
||||
MyDataColumn(
|
||||
label: Text("Discount Rate",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[600]))),
|
||||
MyDataColumn(
|
||||
label: Text("Delete",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[600]))),
|
||||
],
|
||||
rows: getDiscounts(
|
||||
shipmentRateModel.rate.discountByWeights),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding:
|
||||
EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Container(
|
||||
width: 130,
|
||||
height: 40,
|
||||
child: FloatingActionButton.extended(
|
||||
materialTapTargetSize:
|
||||
MaterialTapTargetSize.shrinkWrap,
|
||||
icon: Icon(Icons.add),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
DiscountByWeightEditor()),
|
||||
);
|
||||
},
|
||||
label: Text(
|
||||
'Add Discount',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
// ExpansionTile(
|
||||
// title: Text(
|
||||
// 'Cargo Types',
|
||||
// style: TextStyle(
|
||||
// color: primaryColor, fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// children: <Widget>[
|
||||
// Container(
|
||||
// child: SingleChildScrollView(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// child: MyDataTable(
|
||||
// headingRowHeight: 40,
|
||||
// columnSpacing: 50,
|
||||
// columns: [
|
||||
// MyDataColumn(
|
||||
// label: Text("Cargo Type",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Rate",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Delete",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// ],
|
||||
// rows: getCargoRows(
|
||||
// shipmentRateModel.rate.cargoTypes),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// padding:
|
||||
// EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||
// child: Align(
|
||||
// alignment: Alignment.bottomRight,
|
||||
// child: Container(
|
||||
// width: 120,
|
||||
// height: 40,
|
||||
// child: FloatingActionButton.extended(
|
||||
// materialTapTargetSize:
|
||||
// MaterialTapTargetSize.shrinkWrap,
|
||||
// icon: Icon(Icons.add),
|
||||
// onPressed: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// CupertinoPageRoute(
|
||||
// builder: (context) => CargoEditor()),
|
||||
// );
|
||||
// },
|
||||
// label: Text(
|
||||
// 'Add Cargo',
|
||||
// style: TextStyle(fontSize: 12),
|
||||
// ),
|
||||
// backgroundColor: primaryColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ExpansionTile(
|
||||
// title: Text(
|
||||
// 'Custom Duties',
|
||||
// style: TextStyle(
|
||||
// color: primaryColor, fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// children: <Widget>[
|
||||
// Container(
|
||||
// child: SingleChildScrollView(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// child: MyDataTable(
|
||||
// headingRowHeight: 40,
|
||||
// columnSpacing: 50,
|
||||
// columns: [
|
||||
// MyDataColumn(
|
||||
// label: Text("Produt Type",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Fee",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Delete",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// ],
|
||||
// rows: getCustomsRows(
|
||||
// shipmentRateModel.rate.customDuties),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// padding:
|
||||
// EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||
// child: Align(
|
||||
// alignment: Alignment.bottomRight,
|
||||
// child: Container(
|
||||
// width: 120,
|
||||
// height: 40,
|
||||
// child: FloatingActionButton.extended(
|
||||
// materialTapTargetSize:
|
||||
// MaterialTapTargetSize.shrinkWrap,
|
||||
// icon: Icon(Icons.add),
|
||||
// onPressed: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// CupertinoPageRoute(
|
||||
// builder: (context) => CustomEditor()),
|
||||
// );
|
||||
// },
|
||||
// label: Text(
|
||||
// 'Add Custom\nDuty',
|
||||
// style: TextStyle(fontSize: 12),
|
||||
// ),
|
||||
// backgroundColor: primaryColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ExpansionTile(
|
||||
// title: Text(
|
||||
// 'Discounts by weight',
|
||||
// style: TextStyle(
|
||||
// color: primaryColor, fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// children: <Widget>[
|
||||
// Container(
|
||||
// child: SingleChildScrollView(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// child: MyDataTable(
|
||||
// headingRowHeight: 40,
|
||||
// columnSpacing: 30,
|
||||
// columns: [
|
||||
// MyDataColumn(
|
||||
// label: Text("Weight",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Discount Rate",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// MyDataColumn(
|
||||
// label: Text("Delete",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// color: Colors.grey[600]))),
|
||||
// ],
|
||||
// rows: getDiscounts(
|
||||
// shipmentRateModel.rate.discountByWeights),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// padding:
|
||||
// EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||
// child: Align(
|
||||
// alignment: Alignment.bottomRight,
|
||||
// child: Container(
|
||||
// width: 130,
|
||||
// height: 40,
|
||||
// child: FloatingActionButton.extended(
|
||||
// materialTapTargetSize:
|
||||
// MaterialTapTargetSize.shrinkWrap,
|
||||
// icon: Icon(Icons.add),
|
||||
// onPressed: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// CupertinoPageRoute(
|
||||
// builder: (context) =>
|
||||
// DiscountByWeightEditor()),
|
||||
// );
|
||||
// },
|
||||
// label: Text(
|
||||
// 'Add Discount',
|
||||
// style: TextStyle(fontSize: 12),
|
||||
// ),
|
||||
// backgroundColor: primaryColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
fcsButton(context, "Save", callack: () {
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
fcsButton(context, getLocalString(context, "btn.save"),
|
||||
callack: _save),
|
||||
SizedBox(height: 10)
|
||||
],
|
||||
),
|
||||
@@ -299,6 +300,29 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
||||
);
|
||||
}
|
||||
|
||||
_save() async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
var shipmentRateModel =
|
||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||
Rate _rate = Rate(
|
||||
deliveryFee: double.parse(_deliveryFee.text),
|
||||
freeDeliveryWeight: double.parse(_minWeight.text),
|
||||
volumetricRatio: double.parse(_volumetricRatio.text));
|
||||
|
||||
await shipmentRateModel.updateRate(_rate);
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
List<MyDataRow> getCargoRows(List<CargoType> cargos) {
|
||||
return cargos.map((r) {
|
||||
return MyDataRow(
|
||||
|
||||
Reference in New Issue
Block a user