clean up
This commit is contained in:
79
lib/pages/rates/cargo_editor.dart
Normal file
79
lib/pages/rates/cargo_editor.dart
Normal file
@@ -0,0 +1,79 @@
|
||||
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/util.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CargoEditor extends StatefulWidget {
|
||||
final Rate rate;
|
||||
CargoEditor({this.rate});
|
||||
|
||||
@override
|
||||
_CargoEditorState createState() => _CargoEditorState();
|
||||
}
|
||||
|
||||
class _CargoEditorState extends State<CargoEditor> {
|
||||
TextEditingController _descController = new TextEditingController();
|
||||
TextEditingController _rateController = new TextEditingController();
|
||||
|
||||
bool _isLoading = false;
|
||||
Rate _rate = new Rate();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.rate != null) {
|
||||
_rate = widget.rate;
|
||||
_descController.text = _rate.description;
|
||||
_rateController.text = _rate.price.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(
|
||||
Icons.close,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(AppTranslations.of(context).text("cargo.form.title")),
|
||||
),
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(18),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
fcsInput("Cargo Type", Icons.text_format,
|
||||
controller: _descController),
|
||||
fcsInput("Rate", Icons.attach_money,
|
||||
controller: _rateController),
|
||||
SizedBox(height: 30),
|
||||
],
|
||||
),
|
||||
),
|
||||
widget.rate == null
|
||||
? fcsButton(context, "Create", callack: () {})
|
||||
: fcsButton(context, "Save", callack: () {}),
|
||||
SizedBox(height: 10)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
80
lib/pages/rates/custom_editor.dart
Normal file
80
lib/pages/rates/custom_editor.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:fcs/domain/entities/custom.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
class CustomEditor extends StatefulWidget {
|
||||
final Custom custom;
|
||||
CustomEditor({this.custom});
|
||||
|
||||
@override
|
||||
_CustomEditorState createState() => _CustomEditorState();
|
||||
}
|
||||
|
||||
class _CustomEditorState extends State<CustomEditor> {
|
||||
TextEditingController _productController = new TextEditingController();
|
||||
TextEditingController _feeController = new TextEditingController();
|
||||
|
||||
bool _isLoading = false;
|
||||
Custom _custom = new Custom();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.custom != null) {
|
||||
_custom = widget.custom;
|
||||
_productController.text = _custom.productType;
|
||||
_feeController.text = _custom.fee.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(
|
||||
Icons.close,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(AppTranslations.of(context).text("custom.form.title")),
|
||||
),
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(18),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
fcsInput("Procut Type", FontAwesomeIcons.weightHanging,
|
||||
controller: _productController),
|
||||
fcsInput("Fee", Icons.attach_money,
|
||||
controller: _feeController),
|
||||
SizedBox(height: 30),
|
||||
],
|
||||
),
|
||||
),
|
||||
widget.custom == null
|
||||
? fcsButton(context, "Create", callack: () {})
|
||||
: fcsButton(context, "Save", callack: () {}),
|
||||
SizedBox(height: 10)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
80
lib/pages/rates/discount_by_weight_editor.dart
Normal file
80
lib/pages/rates/discount_by_weight_editor.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
class DiscountByWeightEditor extends StatefulWidget {
|
||||
final Discount discount;
|
||||
DiscountByWeightEditor({this.discount});
|
||||
|
||||
@override
|
||||
_DiscountByWeightEditorState createState() => _DiscountByWeightEditorState();
|
||||
}
|
||||
|
||||
class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
||||
TextEditingController _weightController = new TextEditingController();
|
||||
TextEditingController _rateController = new TextEditingController();
|
||||
|
||||
bool _isLoading = false;
|
||||
Discount _discount = new Discount();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.discount != null) {
|
||||
_discount = widget.discount;
|
||||
_weightController.text = _discount.weight.toString();
|
||||
_rateController.text = _discount.discountRate.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(
|
||||
Icons.close,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(AppTranslations.of(context).text("discount.new")),
|
||||
),
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(18),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
fcsInput("Weight", FontAwesomeIcons.weightHanging,
|
||||
controller: _weightController),
|
||||
fcsInput("Discount Rate", Icons.attach_money,
|
||||
controller: _rateController),
|
||||
SizedBox(height: 30),
|
||||
],
|
||||
),
|
||||
),
|
||||
widget.discount == null
|
||||
? fcsButton(context, "Create", callack: () {})
|
||||
: fcsButton(context, "Save", callack: () {}),
|
||||
SizedBox(height: 10)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
47
lib/pages/rates/model/shipment_rate_model.dart
Normal file
47
lib/pages/rates/model/shipment_rate_model.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
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/pages/main/model/base_model.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
class ShipmentRateModel extends BaseModel {
|
||||
final log = Logger('ShipmentRateModel');
|
||||
|
||||
StreamSubscription<QuerySnapshot> listener;
|
||||
|
||||
List<Rate> rates = [
|
||||
Rate(
|
||||
id: '1', name: 'general_cargo', description: 'General Cargo', price: 6),
|
||||
Rate(id: '2', name: 'medicine', description: 'Medicine', price: 7),
|
||||
Rate(
|
||||
id: '3',
|
||||
name: 'dangerous_cargo',
|
||||
description: 'Dangerous Cargo',
|
||||
price: 8),
|
||||
];
|
||||
|
||||
List<Custom> customs = [
|
||||
Custom(productType: 'Phone', fee: 40),
|
||||
Custom(productType: 'Max Book', fee: 40)
|
||||
];
|
||||
|
||||
List<DiscountRate> discountsByWeight = [
|
||||
DiscountRate(weight: 50, discountRate: 0.25),
|
||||
DiscountRate(weight: 100, discountRate: 0.50)
|
||||
];
|
||||
|
||||
int freeDeliveryWeight = 10;
|
||||
|
||||
void initUser(user) {
|
||||
super.initUser(user);
|
||||
}
|
||||
|
||||
@override
|
||||
logout() async {
|
||||
if (listener != null) await listener.cancel();
|
||||
rates = [];
|
||||
}
|
||||
}
|
||||
196
lib/pages/rates/shipment_rates.dart
Normal file
196
lib/pages/rates/shipment_rates.dart
Normal file
@@ -0,0 +1,196 @@
|
||||
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';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../main/util.dart';
|
||||
import 'shipment_rates_calculate.dart';
|
||||
import 'shipment_rates_edit.dart';
|
||||
|
||||
class ShipmentRates extends StatefulWidget {
|
||||
ShipmentRates();
|
||||
|
||||
@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(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(
|
||||
Icons.close,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(AppTranslations.of(context).text("rate.title")),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 25, top: 10),
|
||||
child: Text(
|
||||
"Cargo Types",
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
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),
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
_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(BottomUpPageRoute(ShipmentRatesCal()));
|
||||
}),
|
||||
fcsButton(context, "Edit", callack: () {
|
||||
Navigator.of(context)
|
||||
.push(BottomUpPageRoute(ShipmentRatesEdit()));
|
||||
}),
|
||||
SizedBox(height: 10)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
List<Widget> getDiscountWidget(List<DiscountRate> discounts) {
|
||||
return discounts.map((d) {
|
||||
return Container(
|
||||
child: _row(
|
||||
"${d.weight.toString()} lb", "\$ " + d.discountRate.toString(), ''),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
_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>[
|
||||
Padding(
|
||||
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,
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
165
lib/pages/rates/shipment_rates_calculate.dart
Normal file
165
lib/pages/rates/shipment_rates_calculate.dart
Normal file
@@ -0,0 +1,165 @@
|
||||
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/progress.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ShipmentRatesCal extends StatefulWidget {
|
||||
ShipmentRatesCal();
|
||||
|
||||
@override
|
||||
_ShipmentRatesCalState createState() => _ShipmentRatesCalState();
|
||||
}
|
||||
|
||||
class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
||||
bool _isLoading = false;
|
||||
String cargoType;
|
||||
|
||||
@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(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(
|
||||
Icons.close,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(AppTranslations.of(context).text("rate.cal.title")),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 5, left: 25),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child:
|
||||
Text('Cargo Type', style: TextStyle(fontSize: 15))),
|
||||
Container(
|
||||
width: 150.0,
|
||||
child: DropdownButtonFormField(
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
hintText: shipmentRateModel.rates[0].description,
|
||||
hintStyle: TextStyle(color: Colors.black87)),
|
||||
items: shipmentRateModel.rates
|
||||
.map((e) => DropdownMenuItem(
|
||||
child: Text(e.description),
|
||||
value: e.description))
|
||||
.toList(),
|
||||
onChanged: (selected) => {
|
||||
setState(() {
|
||||
cargoType = selected;
|
||||
})
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
_row('Width (inches)', "", "", "10", input: true),
|
||||
_row('Height (inches)', "", "", "10", input: true),
|
||||
_row('Length (inches)', "", "", "10", input: true),
|
||||
_row('Actual Weight (pounds)', "", "", "0", input: true),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 25, top: 15, bottom: 5),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text('Shipment Weight', style: TextStyle(fontSize: 15)),
|
||||
Spacer(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 3.0),
|
||||
child: Text(
|
||||
'6',
|
||||
style:
|
||||
TextStyle(color: primaryColor, fontSize: 16),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'pounds',
|
||||
style: TextStyle(color: Colors.grey, fontSize: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)),
|
||||
SizedBox(height: 50),
|
||||
Center(
|
||||
child: Text(
|
||||
"Delivery fee:\$ 5",
|
||||
style: TextStyle(color: primaryColor, fontSize: 16),
|
||||
)),
|
||||
SizedBox(height: 20),
|
||||
Center(
|
||||
child: Text(
|
||||
"Total estimated amount:\$ 41",
|
||||
style: TextStyle(color: primaryColor, fontSize: 20),
|
||||
))
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_row(String desc, String price, String unit, String value, {bool input}) {
|
||||
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>[
|
||||
Padding(
|
||||
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),
|
||||
),
|
||||
// TextFormField(),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 50,
|
||||
),
|
||||
Container(
|
||||
width: 50,
|
||||
child: TextFormField(
|
||||
initialValue: value,
|
||||
textAlign: TextAlign.end,
|
||||
)),
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
393
lib/pages/rates/shipment_rates_edit.dart
Normal file
393
lib/pages/rates/shipment_rates_edit.dart
Normal file
@@ -0,0 +1,393 @@
|
||||
import 'package:fcs/domain/entities/custom.dart';
|
||||
import 'package:fcs/domain/entities/discount.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/my_data_table.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../main/util.dart';
|
||||
import 'cargo_editor.dart';
|
||||
import 'custom_editor.dart';
|
||||
import 'discount_by_weight_editor.dart';
|
||||
|
||||
class ShipmentRatesEdit extends StatefulWidget {
|
||||
ShipmentRatesEdit();
|
||||
|
||||
@override
|
||||
_ShipmentRatesEditState createState() => _ShipmentRatesEditState();
|
||||
}
|
||||
|
||||
class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
||||
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(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(
|
||||
Icons.close,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(AppTranslations.of(context).text("rate.edit.title")),
|
||||
),
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(18),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
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.customs),
|
||||
),
|
||||
),
|
||||
),
|
||||
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(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.discountsByWeight),
|
||||
),
|
||||
),
|
||||
),
|
||||
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,
|
||||
BottomUpPageRoute(DiscountByWeightEditor()),
|
||||
);
|
||||
},
|
||||
label: Text(
|
||||
'Add Discount',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
fcsButton(context, "Save", callack: () {
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
SizedBox(height: 10)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
List<MyDataRow> getCustomsRows(List<Custom> customs) {
|
||||
return customs.map((c) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (selected) {
|
||||
Navigator.push(
|
||||
context,
|
||||
BottomUpPageRoute(CustomEditor(custom: c)),
|
||||
);
|
||||
},
|
||||
cells: [
|
||||
MyDataCell(
|
||||
new Text(
|
||||
c.productType,
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
MyDataCell(
|
||||
new Text(
|
||||
c.fee.toString(),
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
MyDataCell(IconButton(icon: Icon(Icons.delete), onPressed: null)),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
List<MyDataRow> getDiscounts(List<DiscountRate> discounts) {
|
||||
return discounts.map((d) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (selected) {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// BottomUpPageRoute(CargoEditor(rate: r)),
|
||||
// );
|
||||
},
|
||||
cells: [
|
||||
MyDataCell(
|
||||
new Text(
|
||||
"${d.weight} lb",
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
MyDataCell(
|
||||
Center(
|
||||
child: new Text(
|
||||
d.discountRate.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),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text('$desc ', style: TextStyle(fontSize: 15)),
|
||||
Spacer(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
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,
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user