add rate service

This commit is contained in:
Sai Naw Wun
2020-10-15 03:06:13 +06:30
parent 7b88658893
commit 47c07a6c88
45 changed files with 870 additions and 496 deletions

View File

@@ -2,8 +2,8 @@ import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/pickup.dart';
import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/shipment.dart';
import 'package:fcs/domain/vo/radio.dart';
import 'package:fcs/pages/main/model/base_model.dart';
import 'package:logging/logging.dart';
@@ -78,9 +78,9 @@ class ShipmentModel extends BaseModel {
isCourier: true,
radioIndex: 2,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200125 - 12 May 2020",
@@ -95,9 +95,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200441 - 13 Apr 2020",
@@ -113,9 +113,9 @@ class ShipmentModel extends BaseModel {
handlingFee: 50,
radioIndex: 3,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200412 - 12 Apr 2020",
@@ -130,9 +130,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200125 - 12 May 2020",
@@ -147,9 +147,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200441 - 13 Apr 2020",
@@ -164,9 +164,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200441 - 10 Apr 2020",
@@ -181,9 +181,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200441 - 6 Apr 2020",
@@ -198,9 +198,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
];
return pickups;
@@ -222,9 +222,9 @@ class ShipmentModel extends BaseModel {
isCourier: true,
radioIndex: 2,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200125 - 12 May 2020",
@@ -239,9 +239,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200441 - 13 Apr 2020",
@@ -257,9 +257,9 @@ class ShipmentModel extends BaseModel {
handlingFee: 50,
radioIndex: 3,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200412 - 12 Apr 2020",
@@ -274,9 +274,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200125 - 12 May 2020",
@@ -291,9 +291,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200441 - 13 Apr 2020",
@@ -308,9 +308,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200441 - 10 Apr 2020",
@@ -325,9 +325,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
Shipment(
id: "S200441 - 6 Apr 2020",
@@ -342,9 +342,9 @@ class ShipmentModel extends BaseModel {
address: '154-19 64th Ave.\nFlushing, NY 11367',
handlingFee: 50,
cargoTypes: [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
]),
];

View File

@@ -1,10 +1,11 @@
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/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/box/cargo_type_editor.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.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/defalut_delivery_address.dart';
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
@@ -39,14 +40,15 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
DeliveryAddress _deliveryAddress;
double volumetricRatio = 0;
double shipmentWeight = 0;
List<Cargo> cargos = [];
List<CargoType> cargos = [];
@override
void initState() {
super.initState();
volumetricRatio =
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
.rate
.volumetricRatio;
if (widget.box != null) {
_box = widget.box;
@@ -145,7 +147,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
color: primaryColor,
),
onPressed: () async {
Cargo cargo = await Navigator.push<Cargo>(
CargoType cargo = await Navigator.push<CargoType>(
context,
CupertinoPageRoute(
builder: (context) => CargoTypeEditor()));
@@ -212,7 +214,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
total += c.weight;
return MyDataRow(
onSelectChanged: (bool selected) async {
Cargo cargo = await Navigator.push<Cargo>(
CargoType cargo = await Navigator.push<CargoType>(
context,
CupertinoPageRoute(
builder: (context) => CargoTypeEditor(
@@ -222,7 +224,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
},
cells: [
MyDataCell(new Text(
c.type == null ? "" : c.type,
c.name == null ? "" : c.name,
style: textStyle,
)),
MyDataCell(
@@ -270,7 +272,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
return rows;
}
_addCargo(Cargo cargo) {
_addCargo(CargoType cargo) {
if (cargo == null) return;
setState(() {
cargos.remove(cargo);
@@ -278,7 +280,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
});
}
_removeCargo(Cargo cargo) {
_removeCargo(CargoType cargo) {
setState(() {
cargos.remove(cargo);
});

View File

@@ -1,7 +1,7 @@
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/pickup.dart';
import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/shipment.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/box/model/box_model.dart';
@@ -93,10 +93,10 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
_pickupDate.text = dateFormatter.format(now);
_fromTimeEditingController.text = "${(now.hour)}:${(now.minute)}";
_toTimeEditingController.text = "${(now.hour)}:${(now.minute)}";
List<Cargo> _cargoTypes = [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
List<CargoType> _cargoTypes = [
CargoType(name: 'General Cargo', weight: 25),
CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30)
];
_pickUp = Shipment(cargoTypes: _cargoTypes);
}

View File

@@ -1,4 +1,4 @@
import 'package:fcs/domain/entities/pickup.dart';
import 'package:fcs/domain/entities/shipment.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:flutter/cupertino.dart';
@@ -41,8 +41,8 @@ class _ShipmentListRowState extends State<ShipmentListRow> {
padding: EdgeInsets.only(left: 15, right: 15),
child: InkWell(
onTap: () {
Navigator.of(context)
.push(CupertinoPageRoute(builder: (context) => ShipmentEditor(shipment: _pickUp)));
Navigator.of(context).push(CupertinoPageRoute(
builder: (context) => ShipmentEditor(shipment: _pickUp)));
},
child: Row(
children: <Widget>[