2020-10-15 03:06:13 +06:30
|
|
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
|
|
|
|
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/domain/entities/rate.dart';
|
|
|
|
|
import 'package:fcs/helpers/theme.dart';
|
2020-10-15 03:06:13 +06:30
|
|
|
import 'package:fcs/pages/main/model/main_model.dart';
|
2020-10-15 15:49:02 +06:30
|
|
|
import 'package:fcs/pages/rates/cargo_type_list.dart';
|
|
|
|
|
import 'package:fcs/pages/rates/custom_list.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
2024-01-25 17:40:35 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
2020-10-07 14:42:07 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-10-14 13:54:42 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-05-29 15:54:26 +06:30
|
|
|
import 'package:flutter/material.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:provider/provider.dart';
|
2020-05-29 15:54:26 +06:30
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
import '../main/util.dart';
|
2020-10-15 15:49:02 +06:30
|
|
|
import 'discount_by weight_list.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'shipment_rates_calculate.dart';
|
|
|
|
|
import 'shipment_rates_edit.dart';
|
2020-05-29 15:54:26 +06:30
|
|
|
|
|
|
|
|
class ShipmentRates extends StatefulWidget {
|
2020-10-07 02:33:06 +06:30
|
|
|
ShipmentRates();
|
2020-05-29 15:54:26 +06:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ShipmentRatesState createState() => _ShipmentRatesState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ShipmentRatesState extends State<ShipmentRates> {
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
var shipmentRateModel = Provider.of<ShipmentRateModel>(context);
|
2020-10-15 03:06:13 +06:30
|
|
|
Rate rate = shipmentRateModel.rate;
|
|
|
|
|
bool isEditable = context.select((MainModel m) => m.rateEditable());
|
2020-05-29 15:54:26 +06:30
|
|
|
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
2024-01-25 17:40:35 +06:30
|
|
|
appBar: LocalAppBar(
|
|
|
|
|
labelKey: "rate.title",
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
labelColor: primaryColor,
|
|
|
|
|
arrowColor: primaryColor,
|
|
|
|
|
actions: isEditable
|
|
|
|
|
? [
|
|
|
|
|
IconButton(
|
|
|
|
|
onPressed: () => Navigator.of(context).push(
|
|
|
|
|
CupertinoPageRoute(
|
|
|
|
|
builder: (context) => ShipmentRatesEdit())),
|
|
|
|
|
icon: Icon(Icons.edit, color: primaryColor))
|
|
|
|
|
]
|
|
|
|
|
: []),
|
2020-05-31 15:00:11 +06:30
|
|
|
body: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: ListView(
|
2020-05-29 15:54:26 +06:30
|
|
|
children: <Widget>[
|
2020-10-17 01:40:24 +06:30
|
|
|
fcsButton(context, getLocalString(context, "rate.cal.title"),
|
|
|
|
|
callack: () {
|
2020-10-15 03:06:13 +06:30
|
|
|
Navigator.of(context).push(CupertinoPageRoute(
|
|
|
|
|
builder: (context) => ShipmentRatesCal()));
|
|
|
|
|
}),
|
|
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
2020-06-29 16:15:25 +06:30
|
|
|
Container(
|
2020-10-15 15:49:02 +06:30
|
|
|
padding: EdgeInsets.only(left: 25, top: 10, right: 25),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
2020-10-15 18:48:32 +06:30
|
|
|
LocalText(context, "rate.cargo.type",
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 15),
|
2020-10-15 15:49:02 +06:30
|
|
|
Spacer(),
|
2020-10-17 01:40:24 +06:30
|
|
|
isEditable
|
|
|
|
|
? IconButton(
|
|
|
|
|
icon: Icon(Icons.edit, color: primaryColor),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).push(CupertinoPageRoute(
|
|
|
|
|
builder: (context) => CargoTypeList()));
|
|
|
|
|
})
|
|
|
|
|
: Container()
|
2020-10-15 15:49:02 +06:30
|
|
|
],
|
2020-06-29 16:15:25 +06:30
|
|
|
),
|
|
|
|
|
),
|
2020-10-15 03:06:13 +06:30
|
|
|
Column(
|
|
|
|
|
children: getCargoWidget(shipmentRateModel.rate.cargoTypes),
|
2020-06-29 16:15:25 +06:30
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
2020-10-15 15:49:02 +06:30
|
|
|
padding: EdgeInsets.only(left: 25, top: 10, right: 25),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
2020-10-15 18:48:32 +06:30
|
|
|
LocalText(context, "rate.discount_by_weight",
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 15),
|
2020-10-15 15:49:02 +06:30
|
|
|
Spacer(),
|
2020-10-17 01:40:24 +06:30
|
|
|
isEditable
|
|
|
|
|
? IconButton(
|
|
|
|
|
icon: Icon(Icons.edit, color: primaryColor),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).push(CupertinoPageRoute(
|
|
|
|
|
builder: (context) =>
|
|
|
|
|
DiscountByWeightList()));
|
|
|
|
|
})
|
|
|
|
|
: Container()
|
2020-10-15 15:49:02 +06:30
|
|
|
],
|
2020-06-29 16:15:25 +06:30
|
|
|
),
|
|
|
|
|
),
|
2020-10-15 03:06:13 +06:30
|
|
|
Column(
|
|
|
|
|
children:
|
|
|
|
|
getDiscountWidget(shipmentRateModel.rate.discountByWeights),
|
2020-06-29 16:15:25 +06:30
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
2020-10-15 03:06:13 +06:30
|
|
|
_row("Free delivery within Yangon \nfor shipments over",
|
2020-12-04 17:28:21 +06:30
|
|
|
"${rate.freeDeliveryWeight.toStringAsFixed(2)}", "pounds"),
|
|
|
|
|
_row("Delivery fees", "\$ ${rate.deliveryFee.toStringAsFixed(2)}",
|
|
|
|
|
"below ${rate.freeDeliveryWeight.toStringAsFixed(2)} pounds"),
|
|
|
|
|
_row(
|
|
|
|
|
"Volumetric Ratio",
|
|
|
|
|
"${rate.volumetricRatio.toStringAsFixed(2)}",
|
2020-10-15 03:06:13 +06:30
|
|
|
"in3 per pound"),
|
2021-01-08 17:13:51 +06:30
|
|
|
_row("Weight difference discount",
|
|
|
|
|
"${rate.diffDiscountWeight.toStringAsFixed(2)}", "pounds"),
|
|
|
|
|
_row("Weight difference rate",
|
|
|
|
|
"\$ ${rate.diffWeightRate.toStringAsFixed(2)}", ""),
|
2020-10-15 03:06:13 +06:30
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
2020-06-29 16:15:25 +06:30
|
|
|
Container(
|
2020-10-15 15:49:02 +06:30
|
|
|
padding: EdgeInsets.only(left: 25, top: 10, right: 25),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
2020-10-15 18:48:32 +06:30
|
|
|
LocalText(context, "rate.custom_duty",
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 15),
|
2020-10-15 15:49:02 +06:30
|
|
|
Spacer(),
|
2020-10-17 01:40:24 +06:30
|
|
|
isEditable
|
|
|
|
|
? IconButton(
|
|
|
|
|
icon: Icon(Icons.edit, color: primaryColor),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).push(CupertinoPageRoute(
|
|
|
|
|
builder: (context) => CustomList()));
|
|
|
|
|
})
|
|
|
|
|
: Container()
|
2020-10-15 15:49:02 +06:30
|
|
|
],
|
2020-06-29 16:15:25 +06:30
|
|
|
),
|
|
|
|
|
),
|
2020-10-15 03:06:13 +06:30
|
|
|
Column(
|
|
|
|
|
children: getCustonWidget(shipmentRateModel.rate.customDuties),
|
2020-05-29 15:54:26 +06:30
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-05-31 15:00:11 +06:30
|
|
|
|
2020-10-15 03:06:13 +06:30
|
|
|
List<Widget> getCargoWidget(List<CargoType> cargos) {
|
|
|
|
|
return cargos.map((cargo) {
|
2020-06-29 16:15:25 +06:30
|
|
|
return Container(
|
2021-09-10 16:33:52 +06:30
|
|
|
child: _row(cargo.name ?? "", "\$ " + cargo.rate.toStringAsFixed(2),
|
|
|
|
|
'per pound'),
|
2020-06-29 16:15:25 +06:30
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-08 17:13:51 +06:30
|
|
|
List<Widget> getCustonWidget(List<CargoType> customs) {
|
2020-06-29 16:15:25 +06:30
|
|
|
return customs.map((c) {
|
|
|
|
|
return Container(
|
2021-09-10 16:33:52 +06:30
|
|
|
child:
|
|
|
|
|
_row(c.name ?? "", "\$ " + c.customDutyFee.toStringAsFixed(2), ''),
|
2020-06-29 16:15:25 +06:30
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-15 03:06:13 +06:30
|
|
|
List<Widget> getDiscountWidget(List<DiscountByWeight> discounts) {
|
2024-01-23 16:28:08 +06:30
|
|
|
if (discounts.isEmpty) return [];
|
2020-06-29 16:15:25 +06:30
|
|
|
return discounts.map((d) {
|
|
|
|
|
return Container(
|
2020-12-02 20:55:00 +06:30
|
|
|
child: _row("${d.weight.toStringAsFixed(2)} lb",
|
2020-12-04 17:28:21 +06:30
|
|
|
"\$ " + d.discount.toStringAsFixed(2), ''),
|
2020-06-29 16:15:25 +06:30
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 15:00:11 +06:30
|
|
|
_row(String desc, String price, String unit) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Text('$desc ', style: TextStyle(fontSize: 15)),
|
|
|
|
|
Spacer(),
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: <Widget>[
|
2020-06-02 15:30:11 +06:30
|
|
|
Padding(
|
2020-05-31 15:00:11 +06:30
|
|
|
padding: const EdgeInsets.only(bottom: 3.0),
|
|
|
|
|
child: Text(
|
|
|
|
|
'$price',
|
|
|
|
|
style: TextStyle(color: primaryColor, fontSize: 14),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'$unit',
|
|
|
|
|
style: TextStyle(color: Colors.grey, fontSize: 14),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 50,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
));
|
|
|
|
|
}
|
2020-05-29 15:54:26 +06:30
|
|
|
}
|