add rate service
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import 'package:fcs/domain/entities/custom.dart';
|
||||
import 'package:fcs/domain/entities/discount_rate.dart';
|
||||
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/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
@@ -38,6 +40,8 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var shipmentRateModel = Provider.of<ShipmentRateModel>(context);
|
||||
Rate rate = shipmentRateModel.rate;
|
||||
bool isEditable = context.select((MainModel m) => m.rateEditable());
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
@@ -45,22 +49,38 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(
|
||||
context,
|
||||
"rate.title",
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
shadowColor: Colors.transparent,
|
||||
title: LocalText(context, 'rate.title',
|
||||
color: primaryColor, fontSize: 20),
|
||||
actions: isEditable
|
||||
? [
|
||||
IconButton(
|
||||
onPressed: () => Navigator.of(context).push(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => ShipmentRatesEdit())),
|
||||
icon: Icon(
|
||||
CupertinoIcons.pen,
|
||||
color: primaryColor,
|
||||
))
|
||||
]
|
||||
: [],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
fcsButton(context, "Calculate shipping cost", callack: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => ShipmentRatesCal()));
|
||||
}),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 25, top: 10),
|
||||
child: Text(
|
||||
@@ -71,30 +91,8 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
fontSize: 15),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 135,
|
||||
child: Column(
|
||||
children: getCargoWidget(shipmentRateModel.rates),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 25, top: 10),
|
||||
child: Text(
|
||||
"Custom Duties",
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 100,
|
||||
child: Column(
|
||||
children: getCustonWidget(shipmentRateModel.customs),
|
||||
),
|
||||
Column(
|
||||
children: getCargoWidget(shipmentRateModel.rate.cargoTypes),
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
@@ -109,33 +107,35 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
fontSize: 15),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 100,
|
||||
child: Column(
|
||||
children:
|
||||
getDiscountWidget(shipmentRateModel.discountsByWeight),
|
||||
),
|
||||
Column(
|
||||
children:
|
||||
getDiscountWidget(shipmentRateModel.rate.discountByWeights),
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
),
|
||||
_row("Free delivery within Yangon \nfor shipments over", "10",
|
||||
"pounds"),
|
||||
_row("Delivery fees", "\$ 5", "below 10 pounds"),
|
||||
_row("Volumetric Ratio", "166.36", "in3 per pound"),
|
||||
// fcsButton(context, "Terms & Conditions", callack: () {
|
||||
// Navigator.of(context)
|
||||
// .push(MaterialPageRoute(builder: (_) => Term()));
|
||||
// }),
|
||||
fcsButton(context, "Estimate shipping cost", callack: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => ShipmentRatesCal()));
|
||||
}),
|
||||
fcsButton(context, "Edit", callack: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => ShipmentRatesEdit()));
|
||||
}),
|
||||
SizedBox(height: 10)
|
||||
_row("Free delivery within Yangon \nfor shipments over",
|
||||
"${rate.freeDeliveryWeight}", "pounds"),
|
||||
_row("Delivery fees", "\$ ${rate.deliveryFee}",
|
||||
"below ${rate.freeDeliveryWeight} pounds"),
|
||||
_row("Volumetric Ratio", "${rate.volumetricRatio}",
|
||||
"in3 per pound"),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 25, top: 10),
|
||||
child: Text(
|
||||
"Custom Duties",
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: getCustonWidget(shipmentRateModel.rate.customDuties),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -143,16 +143,15 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getCargoWidget(List<Rate> rates) {
|
||||
return rates.map((cargo) {
|
||||
List<Widget> getCargoWidget(List<CargoType> cargos) {
|
||||
return cargos.map((cargo) {
|
||||
return Container(
|
||||
child: _row(
|
||||
cargo.description, "\$ " + cargo.price.toString(), 'per pound'),
|
||||
child: _row(cargo.name, "\$ " + cargo.rate.toString(), 'per pound'),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
List<Widget> getCustonWidget(List<Custom> customs) {
|
||||
List<Widget> getCustonWidget(List<CustomDuty> customs) {
|
||||
return customs.map((c) {
|
||||
return Container(
|
||||
child: _row(c.productType, "\$ " + c.fee.toString(), ''),
|
||||
@@ -160,11 +159,12 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
List<Widget> getDiscountWidget(List<DiscountRate> discounts) {
|
||||
List<Widget> getDiscountWidget(List<DiscountByWeight> discounts) {
|
||||
if (discounts == null) return [];
|
||||
return discounts.map((d) {
|
||||
return Container(
|
||||
child: _row(
|
||||
"${d.weight.toString()} lb", "\$ " + d.discountRate.toString(), ''),
|
||||
"${d.weight.toString()} lb", "\$ " + d.discount.toString(), ''),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user