update shipment rate

This commit is contained in:
Thinzar Win
2020-06-25 16:19:23 +06:30
parent fd63f30cb4
commit 869142ec66
18 changed files with 797 additions and 300 deletions

View File

@@ -1,6 +1,11 @@
import 'package:fcs/model/pickup_model.dart';
import 'package:fcs/model/shipment_rate_model.dart';
import 'package:fcs/pages_fcs/cargo_editor.dart';
import 'package:fcs/vo/pickup.dart';
import 'package:fcs/vo/rate.dart';
import 'package:fcs/widget/bottom_up_page_route.dart';
import 'package:fcs/widget/local_text.dart';
import 'package:fcs/widget/my_data_table.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:fcs/widget/localization/app_translations.dart';
@@ -69,26 +74,88 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
),
body: Container(
padding: EdgeInsets.all(18),
child: ListView(
child: Column(
children: <Widget>[
Container(
height: 190,
child: ListView.builder(
itemCount: shipmentRateModel.rates.length,
itemBuilder: (context, index) {
return fcsInput(
shipmentRateModel.rates[index].description,
Icons.attach_money,
value:
shipmentRateModel.rates[index].price.toString());
}),
Expanded(
child: ListView(
children: <Widget>[
fcsInput("Min Weight for Free delivery within Yangon",
FontAwesomeIcons.weightHanging,
value: "10"),
fcsInput("Delivery fees", Icons.attach_money, value: "5"),
SizedBox(height: 10),
fcsInput("Volumetric Ratio", Icons.attach_money,
value: "166.36"),
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.rates),
),
),
),
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,
BottomUpPageRoute(CargoEditor()),
);
},
label: Text(
'Add Cargo',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
)
],
),
],
),
),
fcsInput("Min Weight for Free delivery within Yangon",
FontAwesomeIcons.weightHanging,
value: "10"),
fcsInput("Delivery fees", Icons.attach_money, value: "5"),
SizedBox(height: 10),
fcsButton(context, "Save", callack: () {}),
fcsButton(context, "Save", callack: () {
Navigator.pop(context);
}),
SizedBox(height: 10)
],
),
@@ -97,6 +164,34 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
);
}
List<MyDataRow> getCargoRows(List<Rate> rates) {
return rates.map((r) {
return MyDataRow(
onSelectChanged: (selected) {
Navigator.push(
context,
BottomUpPageRoute(CargoEditor(rate: r)),
);
},
cells: [
MyDataCell(
new Text(
r.description,
style: textStyle,
),
),
MyDataCell(
new Text(
r.price.toString(),
style: textStyle,
),
),
MyDataCell(IconButton(icon: Icon(Icons.delete), onPressed: null)),
],
);
}).toList();
}
_row(String desc, String price, String unit) {
return Container(
padding: EdgeInsets.only(left: 25, top: 5, bottom: 5),