add rate service
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/box.dart';
|
||||
import 'package:fcs/domain/entities/cargo.dart';
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/entities/user.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
@@ -12,6 +12,7 @@ import 'package:fcs/pages/main/model/language_model.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
||||
@@ -54,7 +55,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
||||
List<Package> _packages = [];
|
||||
List<Box> _shipmentBoxes = [];
|
||||
List<Box> _mixBoxes = [];
|
||||
List<Cargo> _cargoTypes = [];
|
||||
List<CargoType> _cargoTypes = [];
|
||||
double volumetricRatio = 0;
|
||||
double shipmentWeight = 0;
|
||||
Box _selectedShipmentBox;
|
||||
@@ -83,8 +84,9 @@ class _BoxEditorState extends State<BoxEditor> {
|
||||
});
|
||||
|
||||
//for shipment weight
|
||||
volumetricRatio =
|
||||
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
|
||||
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||
.rate
|
||||
.volumetricRatio;
|
||||
_lengthController.addListener(_calShipmentWeight);
|
||||
_widthController.addListener(_calShipmentWeight);
|
||||
_heightController.addListener(_calShipmentWeight);
|
||||
@@ -101,9 +103,9 @@ class _BoxEditorState extends State<BoxEditor> {
|
||||
isNew = false;
|
||||
} else {
|
||||
_cargoTypes = [
|
||||
Cargo(type: 'General', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous', weight: 30)
|
||||
CargoType(id: "1", name: 'General', weight: 25),
|
||||
CargoType(id: "2", name: 'Medicine', weight: 20),
|
||||
CargoType(id: "3", name: 'Dangerous', weight: 30)
|
||||
];
|
||||
|
||||
var shipmentModel =
|
||||
@@ -401,7 +403,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
||||
total += c.value.weight;
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
Cargo cargo = await Navigator.push<Cargo>(
|
||||
CargoType cargo = await Navigator.push<CargoType>(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => CargoTypeEditor(cargo: c.value)),
|
||||
@@ -422,7 +424,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new Text(
|
||||
c.value.type,
|
||||
c.value.name,
|
||||
style: textStyle,
|
||||
)),
|
||||
Row(
|
||||
@@ -630,7 +632,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
Cargo cargo = await Navigator.push<Cargo>(
|
||||
CargoType cargo = await Navigator.push<CargoType>(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => CargoTypeEditor()),
|
||||
@@ -700,7 +702,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
_addCargo(Cargo cargo) {
|
||||
_addCargo(CargoType cargo) {
|
||||
if (cargo == null) return;
|
||||
setState(() {
|
||||
_cargoTypes.remove(cargo);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/box.dart';
|
||||
import 'package:fcs/domain/entities/cargo.dart';
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/package/model/package_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/defalut_delivery_address.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
@@ -48,7 +49,7 @@ class _BoxInfoState extends State<BoxInfo> {
|
||||
List<Package> _packages = [];
|
||||
List<Box> _mixBoxes = [];
|
||||
Box _selectedShipmentBox;
|
||||
List<Cargo> _cargoTypes = [];
|
||||
List<CargoType> _cargoTypes = [];
|
||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||
TextEditingController _widthController = new TextEditingController();
|
||||
TextEditingController _heightController = new TextEditingController();
|
||||
@@ -83,8 +84,9 @@ class _BoxInfoState extends State<BoxInfo> {
|
||||
});
|
||||
|
||||
//for shipment weight
|
||||
volumetricRatio =
|
||||
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
|
||||
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||
.rate
|
||||
.volumetricRatio;
|
||||
_lengthController.addListener(_calShipmentWeight);
|
||||
_widthController.addListener(_calShipmentWeight);
|
||||
_heightController.addListener(_calShipmentWeight);
|
||||
@@ -342,7 +344,7 @@ class _BoxInfoState extends State<BoxInfo> {
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new Text(
|
||||
c.value.type,
|
||||
c.value.name,
|
||||
style: textStyle,
|
||||
)),
|
||||
Container(
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import 'package:fcs/domain/entities/cargo.dart';
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
@@ -12,7 +13,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class CargoTypeEditor extends StatefulWidget {
|
||||
final Cargo cargo;
|
||||
final CargoType cargo;
|
||||
CargoTypeEditor({this.cargo});
|
||||
|
||||
@override
|
||||
@@ -23,7 +24,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
||||
TextEditingController _weightController = new TextEditingController();
|
||||
|
||||
bool _isLoading = false;
|
||||
Cargo _cargo;
|
||||
CargoType _cargo;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -37,8 +38,9 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
||||
}
|
||||
|
||||
_loadDefalut() {
|
||||
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
||||
_cargo = mainModel.setting.defaultCargoType;
|
||||
ShipmentRateModel shipmentRateModel =
|
||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||
_cargo = shipmentRateModel.rate.defaultCargoType;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -48,8 +50,9 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
MainModel mainModel = Provider.of<MainModel>(context);
|
||||
List<Cargo> cargos = mainModel.setting.cargoTypesList;
|
||||
ShipmentRateModel shipmentRateModel =
|
||||
Provider.of<ShipmentRateModel>(context);
|
||||
List<CargoType> cargos = shipmentRateModel.rate.cargoTypes;
|
||||
|
||||
final rateBox = InputText(
|
||||
labelTextKey: 'cargo.weight',
|
||||
@@ -57,7 +60,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
||||
textInputType: TextInputType.number,
|
||||
controller: _weightController);
|
||||
|
||||
var cargoTypeBox = LocalDropdown<Cargo>(
|
||||
var cargoTypeBox = LocalDropdown<CargoType>(
|
||||
callback: (v) {
|
||||
setState(() {
|
||||
_cargo = v;
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'dart:async';
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/box.dart';
|
||||
import 'package:fcs/domain/entities/cargo.dart';
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/vo/shipment_status.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
@@ -55,9 +55,9 @@ class BoxModel extends BaseModel {
|
||||
state: 'NY',
|
||||
phoneNumber: '+1 (292)215-2247'),
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous', weight: 30)
|
||||
CargoType(name: 'General', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous', weight: 30)
|
||||
]),
|
||||
Box(
|
||||
shipmentNumber: "A203",
|
||||
@@ -87,9 +87,9 @@ class BoxModel extends BaseModel {
|
||||
state: 'Myanmar',
|
||||
phoneNumber: '+09 95724 8750'),
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous', weight: 30)
|
||||
CargoType(name: 'General', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous', weight: 30)
|
||||
]),
|
||||
Box(
|
||||
shipmentNumber: "A204",
|
||||
@@ -119,9 +119,9 @@ class BoxModel extends BaseModel {
|
||||
state: 'Myanmar',
|
||||
phoneNumber: '+09 95724 8750'),
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous', weight: 30)
|
||||
CargoType(name: 'General', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous', weight: 30)
|
||||
]),
|
||||
Box(
|
||||
shipmentNumber: "A202",
|
||||
@@ -150,9 +150,9 @@ class BoxModel extends BaseModel {
|
||||
state: 'NY',
|
||||
phoneNumber: '+1 (292)215-2247'),
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous', weight: 30)
|
||||
CargoType(name: 'General', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous', weight: 30)
|
||||
]),
|
||||
Box(
|
||||
shipmentNumber: "A202",
|
||||
@@ -180,9 +180,9 @@ class BoxModel extends BaseModel {
|
||||
state: 'NY',
|
||||
phoneNumber: '+1 (292)215-2247'),
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous', weight: 30)
|
||||
CargoType(name: 'General', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous', weight: 30)
|
||||
]),
|
||||
Box(
|
||||
shipmentNumber: "A202",
|
||||
@@ -210,9 +210,9 @@ class BoxModel extends BaseModel {
|
||||
state: 'NY',
|
||||
phoneNumber: '+1 (292)215-2247'),
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous', weight: 30)
|
||||
CargoType(name: 'General', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous', weight: 30)
|
||||
]),
|
||||
Box(
|
||||
shipmentNumber: "A201",
|
||||
@@ -240,9 +240,9 @@ class BoxModel extends BaseModel {
|
||||
state: 'NY',
|
||||
phoneNumber: '+1 (292)215-2247'),
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous', weight: 30)
|
||||
CargoType(name: 'General', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous', weight: 30)
|
||||
]),
|
||||
Box(
|
||||
shipmentNumber: "A201",
|
||||
@@ -270,9 +270,9 @@ class BoxModel extends BaseModel {
|
||||
state: 'NY',
|
||||
phoneNumber: '+1 (292)215-2247'),
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous', weight: 30)
|
||||
CargoType(name: 'General', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous', weight: 30)
|
||||
]),
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user