2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/domain/entities/custom.dart';
|
|
|
|
|
import 'package:fcs/domain/entities/discount_rate.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/rates/model/shipment_rate_model.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/progress.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';
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
2020-05-31 15:00:11 +06:30
|
|
|
centerTitle: true,
|
|
|
|
|
leading: new IconButton(
|
|
|
|
|
icon: new Icon(
|
|
|
|
|
Icons.close,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
2020-05-29 15:54:26 +06:30
|
|
|
backgroundColor: primaryColor,
|
2020-05-31 15:00:11 +06:30
|
|
|
title: Text(AppTranslations.of(context).text("rate.title")),
|
2020-05-29 15:54:26 +06:30
|
|
|
),
|
2020-05-31 15:00:11 +06:30
|
|
|
body: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: ListView(
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
2020-05-29 15:54:26 +06:30
|
|
|
children: <Widget>[
|
2020-06-29 16:15:25 +06:30
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 25, top: 10),
|
|
|
|
|
child: Text(
|
|
|
|
|
"Cargo Types",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 15),
|
|
|
|
|
),
|
|
|
|
|
),
|
2020-05-31 15:00:11 +06:30
|
|
|
Container(
|
|
|
|
|
height: 135,
|
2020-06-29 16:15:25 +06:30
|
|
|
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),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 25, top: 10),
|
|
|
|
|
child: Text(
|
|
|
|
|
"Discounts by weight",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 15),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
height: 100,
|
|
|
|
|
child: Column(
|
|
|
|
|
children:
|
|
|
|
|
getDiscountWidget(shipmentRateModel.discountsByWeight),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey,
|
2020-05-29 15:54:26 +06:30
|
|
|
),
|
2020-06-02 15:30:11 +06:30
|
|
|
_row("Free delivery within Yangon \nfor shipments over", "10",
|
|
|
|
|
"pounds"),
|
|
|
|
|
_row("Delivery fees", "\$ 5", "below 10 pounds"),
|
2020-06-29 16:15:25 +06:30
|
|
|
_row("Volumetric Ratio", "166.36", "in3 per pound"),
|
|
|
|
|
// fcsButton(context, "Terms & Conditions", callack: () {
|
|
|
|
|
// Navigator.of(context)
|
|
|
|
|
// .push(MaterialPageRoute(builder: (_) => Term()));
|
|
|
|
|
// }),
|
2020-06-04 01:36:49 +06:30
|
|
|
fcsButton(context, "Estimate shipping cost", callack: () {
|
2020-06-02 15:30:11 +06:30
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(BottomUpPageRoute(ShipmentRatesCal()));
|
2020-05-31 15:00:11 +06:30
|
|
|
}),
|
|
|
|
|
fcsButton(context, "Edit", callack: () {
|
2020-06-02 15:30:11 +06:30
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(BottomUpPageRoute(ShipmentRatesEdit()));
|
2020-05-31 15:00:11 +06:30
|
|
|
}),
|
2020-06-02 15:30:11 +06:30
|
|
|
SizedBox(height: 10)
|
2020-05-29 15:54:26 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-05-31 15:00:11 +06:30
|
|
|
|
2020-06-29 16:15:25 +06:30
|
|
|
List<Widget> getCargoWidget(List<Rate> rates) {
|
|
|
|
|
return rates.map((cargo) {
|
|
|
|
|
return Container(
|
|
|
|
|
child: _row(
|
|
|
|
|
cargo.description, "\$ " + cargo.price.toString(), 'per pound'),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> getCustonWidget(List<Custom> customs) {
|
|
|
|
|
return customs.map((c) {
|
|
|
|
|
return Container(
|
|
|
|
|
child: _row(c.productType, "\$ " + c.fee.toString(), ''),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
List<Widget> getDiscountWidget(List<DiscountRate> discounts) {
|
2020-06-29 16:15:25 +06:30
|
|
|
return discounts.map((d) {
|
|
|
|
|
return Container(
|
|
|
|
|
child: _row(
|
|
|
|
|
"${d.weight.toString()} lb", "\$ " + d.discountRate.toString(), ''),
|
|
|
|
|
);
|
|
|
|
|
}).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
|
|
|
}
|