add rate service
This commit is contained in:
@@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
"FAQ Start ================================================================":"",
|
"FAQ Start ================================================================":"",
|
||||||
"faq.btn":"FAQs",
|
"faq.btn":"FAQs",
|
||||||
"faq.title":"Frequently Asked Questions",
|
"faq.title":"FAQs",
|
||||||
"faq.add.title":"New FAQ",
|
"faq.add.title":"New FAQ",
|
||||||
"faq.edit.title":"Edit FAQ",
|
"faq.edit.title":"Edit FAQ",
|
||||||
"faq.edit.eng":"English",
|
"faq.edit.eng":"English",
|
||||||
|
|||||||
@@ -132,6 +132,8 @@ class AuthFb {
|
|||||||
String privileges = idToken.claims["pr"];
|
String privileges = idToken.claims["pr"];
|
||||||
if (privileges != null && privileges != "") {
|
if (privileges != null && privileges != "") {
|
||||||
user.privileges = privileges.split(":").toList();
|
user.privileges = privileges.split(":").toList();
|
||||||
|
} else {
|
||||||
|
user.privileges = [];
|
||||||
}
|
}
|
||||||
controller.add(user);
|
controller.add(user);
|
||||||
}
|
}
|
||||||
@@ -198,18 +200,6 @@ class AuthFb {
|
|||||||
return token.token;
|
return token.token;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Setting> getSetting() async {
|
|
||||||
var snap = await Firestore.instance
|
|
||||||
.collection(config_collection)
|
|
||||||
.document(setting_doc_id)
|
|
||||||
.get();
|
|
||||||
if (!snap.exists) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// _listSetting();
|
|
||||||
return Setting.fromMap(snap.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
Stream<Setting> settings() async* {
|
Stream<Setting> settings() async* {
|
||||||
Stream<DocumentSnapshot> snapshot = Firestore.instance
|
Stream<DocumentSnapshot> snapshot = Firestore.instance
|
||||||
.collection(config_collection)
|
.collection(config_collection)
|
||||||
|
|||||||
181
lib/data/provider/rate_data_provider.dart
Normal file
181
lib/data/provider/rate_data_provider.dart
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:fcs/domain/constants.dart';
|
||||||
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
|
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||||
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
|
import 'package:fcs/helpers/api_helper.dart';
|
||||||
|
import 'package:fcs/helpers/firebase_helper.dart';
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
|
class RateDataProvider {
|
||||||
|
final log = Logger('RateDataProvider');
|
||||||
|
|
||||||
|
static final RateDataProvider instance = RateDataProvider._();
|
||||||
|
RateDataProvider._();
|
||||||
|
|
||||||
|
StreamController<Rate> controller;
|
||||||
|
static Rate _rate = Rate();
|
||||||
|
|
||||||
|
Stream<Rate> _rateStream() async* {
|
||||||
|
Stream<DocumentSnapshot> snapshot = Firestore.instance
|
||||||
|
.collection(config_collection)
|
||||||
|
.document(rate_doc_id)
|
||||||
|
.snapshots();
|
||||||
|
await for (var snap in snapshot) {
|
||||||
|
Rate rate = Rate.fromMap(snap.data);
|
||||||
|
yield rate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream<List<CargoType>> _cargoTypeStream() async* {
|
||||||
|
List<CargoType> cargoTypes = [];
|
||||||
|
Stream<QuerySnapshot> snapshots = Firestore.instance
|
||||||
|
.collection(config_collection)
|
||||||
|
.document(rate_doc_id)
|
||||||
|
.collection(cargo_types_collection)
|
||||||
|
.snapshots();
|
||||||
|
|
||||||
|
await for (var snaps in snapshots) {
|
||||||
|
cargoTypes = [];
|
||||||
|
cargoTypes = snaps.documents.map((snap) {
|
||||||
|
return CargoType.fromMap(snap.data, snap.documentID);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
yield cargoTypes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream<List<CustomDuty>> _customDutiesStream() async* {
|
||||||
|
List<CustomDuty> customDuries = [];
|
||||||
|
Stream<QuerySnapshot> snapshots = Firestore.instance
|
||||||
|
.collection(config_collection)
|
||||||
|
.document(rate_doc_id)
|
||||||
|
.collection(custom_duties_collection)
|
||||||
|
.snapshots();
|
||||||
|
|
||||||
|
await for (var snaps in snapshots) {
|
||||||
|
customDuries = [];
|
||||||
|
customDuries = snaps.documents.map((snap) {
|
||||||
|
return CustomDuty.fromMap(snap.data, snap.documentID);
|
||||||
|
}).toList();
|
||||||
|
yield customDuries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream<List<DiscountByWeight>> _discountByWeightStream() async* {
|
||||||
|
List<DiscountByWeight> discountByWeight = [];
|
||||||
|
Stream<QuerySnapshot> snapshots = Firestore.instance
|
||||||
|
.collection(config_collection)
|
||||||
|
.document(rate_doc_id)
|
||||||
|
.collection(discounts_by_weights_collection)
|
||||||
|
.snapshots();
|
||||||
|
|
||||||
|
await for (var snaps in snapshots) {
|
||||||
|
discountByWeight = [];
|
||||||
|
discountByWeight = snaps.documents.map((snap) {
|
||||||
|
return DiscountByWeight.fromMap(snap.data, snap.documentID);
|
||||||
|
}).toList();
|
||||||
|
yield discountByWeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamSubscription<Rate> rateListener;
|
||||||
|
StreamSubscription<List<CargoType>> cargoListener;
|
||||||
|
StreamSubscription<List<CustomDuty>> customListener;
|
||||||
|
StreamSubscription<List<DiscountByWeight>> discountListener;
|
||||||
|
Stream<Rate> rate() {
|
||||||
|
Future<void> _start() async {
|
||||||
|
rateListener = _rateStream().listen((rate) {
|
||||||
|
_rate.deliveryFee = rate.deliveryFee;
|
||||||
|
_rate.freeDeliveryWeight = rate.freeDeliveryWeight;
|
||||||
|
_rate.volumetricRatio = rate.volumetricRatio;
|
||||||
|
controller.add(_rate);
|
||||||
|
});
|
||||||
|
cargoListener = _cargoTypeStream().listen((cargoTypes) {
|
||||||
|
_rate.cargoTypes = cargoTypes;
|
||||||
|
controller.add(_rate);
|
||||||
|
});
|
||||||
|
customListener = _customDutiesStream().listen((customDuties) {
|
||||||
|
_rate.customDuties = customDuties;
|
||||||
|
controller.add(_rate);
|
||||||
|
});
|
||||||
|
discountListener = _discountByWeightStream().listen((discountByWeights) {
|
||||||
|
_rate.discountByWeights = discountByWeights;
|
||||||
|
controller.add(_rate);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _stop() {
|
||||||
|
if (rateListener != null) {
|
||||||
|
rateListener.cancel();
|
||||||
|
}
|
||||||
|
if (cargoListener != null) {
|
||||||
|
cargoListener.cancel();
|
||||||
|
}
|
||||||
|
if (customListener != null) {
|
||||||
|
customListener.cancel();
|
||||||
|
}
|
||||||
|
if (discountListener != null) {
|
||||||
|
discountListener.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
controller = StreamController<Rate>(
|
||||||
|
onListen: _start, onPause: _stop, onResume: _start, onCancel: _stop);
|
||||||
|
|
||||||
|
return controller.stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateRates(Rate rate) async {
|
||||||
|
return await requestAPI("/rates", "PUT",
|
||||||
|
payload: rate.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> createCargoType(CargoType cargoType) async {
|
||||||
|
return await requestAPI("/cargo_types", "POST",
|
||||||
|
payload: cargoType.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateCargoType(CargoType cargoType) async {
|
||||||
|
return await requestAPI("/cargo_types", "PUT",
|
||||||
|
payload: cargoType.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteCargoType(String id) async {
|
||||||
|
return await requestAPI("/cargo_types", "DELETE",
|
||||||
|
payload: {"id": id}, token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> createCustomDuty(CustomDuty customDuty) async {
|
||||||
|
return await requestAPI("/custom_duties", "POST",
|
||||||
|
payload: customDuty.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateCustomDuty(CustomDuty customDuty) async {
|
||||||
|
return await requestAPI("/custom_duties", "PUT",
|
||||||
|
payload: customDuty.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteCustomDuty(String id) async {
|
||||||
|
return await requestAPI("/custom_duties", "PUT",
|
||||||
|
payload: {"id": id}, token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> createDiscountByWeight(DiscountByWeight discountByWeight) async {
|
||||||
|
return await requestAPI("/discounts_by_weight", "POST",
|
||||||
|
payload: discountByWeight.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateDiscountByWeight(DiscountByWeight discountByWeight) async {
|
||||||
|
return await requestAPI("/discounts_by_weight", "PUT",
|
||||||
|
payload: discountByWeight.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteDiscountByWeight(String id) async {
|
||||||
|
return await requestAPI("/discounts_by_weight", "PUT",
|
||||||
|
payload: {"id": id}, token: await getToken());
|
||||||
|
}
|
||||||
|
}
|
||||||
75
lib/data/services/rate_imp.dart
Normal file
75
lib/data/services/rate_imp.dart
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import 'package:fcs/data/provider/rate_data_provider.dart';
|
||||||
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/domain/entities/connectivity.dart';
|
||||||
|
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||||
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'rate_service.dart';
|
||||||
|
|
||||||
|
class RateServiceImp implements RateService {
|
||||||
|
RateServiceImp({
|
||||||
|
@required this.rateDataProvider,
|
||||||
|
@required this.connectivity,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Connectivity connectivity;
|
||||||
|
final RateDataProvider rateDataProvider;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Stream<Rate> getRateStream() {
|
||||||
|
return rateDataProvider.rate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> createCargoType(CargoType cargoType) {
|
||||||
|
return rateDataProvider.createCargoType(cargoType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> createCustomDuty(CustomDuty customDuty) {
|
||||||
|
return rateDataProvider.createCustomDuty(customDuty);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> createDiscountByWeight(DiscountByWeight discountByWeight) {
|
||||||
|
return rateDataProvider.createDiscountByWeight(discountByWeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteCargoType(String id) {
|
||||||
|
return rateDataProvider.deleteCargoType(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteCustomDuty(String id) {
|
||||||
|
return rateDataProvider.deleteCustomDuty(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteDiscountByWeight(String id) {
|
||||||
|
return rateDataProvider.deleteDiscountByWeight(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateCargoType(CargoType cargoType) {
|
||||||
|
return rateDataProvider.updateCargoType(cargoType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateCustomDuty(CustomDuty customDuty) {
|
||||||
|
return rateDataProvider.updateCustomDuty(customDuty);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateDiscountByWeight(DiscountByWeight discountByWeight) {
|
||||||
|
return rateDataProvider.updateDiscountByWeight(discountByWeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateRate(Rate rate) {
|
||||||
|
// TODO: implement updateRate
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
}
|
||||||
22
lib/data/services/rate_service.dart
Normal file
22
lib/data/services/rate_service.dart
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
|
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||||
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
|
|
||||||
|
abstract class RateService {
|
||||||
|
Stream<Rate> getRateStream();
|
||||||
|
|
||||||
|
Future<void> updateRate(Rate rate);
|
||||||
|
|
||||||
|
Future<void> createCargoType(CargoType cargoType);
|
||||||
|
Future<void> updateCargoType(CargoType cargoType);
|
||||||
|
Future<void> deleteCargoType(String id);
|
||||||
|
|
||||||
|
Future<void> createCustomDuty(CustomDuty customDuty);
|
||||||
|
Future<void> updateCustomDuty(CustomDuty customDuty);
|
||||||
|
Future<void> deleteCustomDuty(String id);
|
||||||
|
|
||||||
|
Future<void> createDiscountByWeight(DiscountByWeight discountByWeight);
|
||||||
|
Future<void> updateDiscountByWeight(DiscountByWeight discountByWeight);
|
||||||
|
Future<void> deleteDiscountByWeight(String id);
|
||||||
|
}
|
||||||
@@ -3,12 +3,14 @@ import 'package:fcs/data/provider/common_data_provider.dart';
|
|||||||
import 'package:fcs/data/provider/delivery_address_data_provider.dart';
|
import 'package:fcs/data/provider/delivery_address_data_provider.dart';
|
||||||
import 'package:fcs/data/provider/fcs_shipment_data_provider.dart';
|
import 'package:fcs/data/provider/fcs_shipment_data_provider.dart';
|
||||||
import 'package:fcs/data/provider/package_data_provider.dart';
|
import 'package:fcs/data/provider/package_data_provider.dart';
|
||||||
|
import 'package:fcs/data/provider/rate_data_provider.dart';
|
||||||
import 'package:fcs/data/provider/user_data_provider.dart';
|
import 'package:fcs/data/provider/user_data_provider.dart';
|
||||||
import 'package:fcs/data/services/delivery_address_imp.dart';
|
import 'package:fcs/data/services/delivery_address_imp.dart';
|
||||||
import 'package:fcs/data/services/delivery_address_service.dart';
|
import 'package:fcs/data/services/delivery_address_service.dart';
|
||||||
import 'package:fcs/data/services/fcs_shipment_imp.dart';
|
import 'package:fcs/data/services/fcs_shipment_imp.dart';
|
||||||
import 'package:fcs/data/services/fcs_shipment_service.dart';
|
import 'package:fcs/data/services/fcs_shipment_service.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/data/services/rate_imp.dart';
|
||||||
|
import 'package:fcs/data/services/rate_service.dart';
|
||||||
|
|
||||||
import 'auth_imp.dart';
|
import 'auth_imp.dart';
|
||||||
import 'auth_service.dart';
|
import 'auth_service.dart';
|
||||||
@@ -31,6 +33,7 @@ class Services {
|
|||||||
CommonService _commonService;
|
CommonService _commonService;
|
||||||
FcsShipmentService _fcsShipmentService;
|
FcsShipmentService _fcsShipmentService;
|
||||||
DeliveryAddressService _deliveryAddressService;
|
DeliveryAddressService _deliveryAddressService;
|
||||||
|
RateService _rateService;
|
||||||
Services._() {
|
Services._() {
|
||||||
_authService = AuthServiceImp(
|
_authService = AuthServiceImp(
|
||||||
authFb: AuthFb.instance,
|
authFb: AuthFb.instance,
|
||||||
@@ -47,6 +50,8 @@ class Services {
|
|||||||
_deliveryAddressService = DeliveryAddressImp(
|
_deliveryAddressService = DeliveryAddressImp(
|
||||||
connectivity: null,
|
connectivity: null,
|
||||||
deliveryAddressDataProvider: DeliveryAddressDataProvider());
|
deliveryAddressDataProvider: DeliveryAddressDataProvider());
|
||||||
|
_rateService = RateServiceImp(
|
||||||
|
rateDataProvider: RateDataProvider.instance, connectivity: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthService get authService => _authService;
|
AuthService get authService => _authService;
|
||||||
@@ -56,4 +61,5 @@ class Services {
|
|||||||
CommonService get commonService => _commonService;
|
CommonService get commonService => _commonService;
|
||||||
FcsShipmentService get fcsShipmentService => _fcsShipmentService;
|
FcsShipmentService get fcsShipmentService => _fcsShipmentService;
|
||||||
DeliveryAddressService get deliveryAddressService => _deliveryAddressService;
|
DeliveryAddressService get deliveryAddressService => _deliveryAddressService;
|
||||||
|
RateService get rateService => _rateService;
|
||||||
}
|
}
|
||||||
|
|||||||
23
lib/data/services/shipment_service.dart
Normal file
23
lib/data/services/shipment_service.dart
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
|
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||||
|
import 'package:fcs/domain/entities/shipment.dart';
|
||||||
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
|
|
||||||
|
abstract class RateService {
|
||||||
|
Stream<Rate> getRateStream();
|
||||||
|
|
||||||
|
Future<void> createShipment(Shipment shipment);
|
||||||
|
|
||||||
|
Future<void> createCargoType(CargoType cargoType);
|
||||||
|
Future<void> updateCargoType(CargoType cargoType);
|
||||||
|
Future<void> deleteCargoType(String id);
|
||||||
|
|
||||||
|
Future<void> createCustomDuty(CustomDuty customDuty);
|
||||||
|
Future<void> updateCustomDuty(CustomDuty customDuty);
|
||||||
|
Future<void> deleteCustomDuty(String id);
|
||||||
|
|
||||||
|
Future<void> createDiscountByWeight(DiscountByWeight discountByWeight);
|
||||||
|
Future<void> updateDiscountByWeight(DiscountByWeight discountByWeight);
|
||||||
|
Future<void> deleteDiscountByWeight(String id);
|
||||||
|
}
|
||||||
@@ -1,13 +1,19 @@
|
|||||||
const config_collection = "configs";
|
const config_collection = "configs";
|
||||||
const user_collection = "users";
|
const user_collection = "users";
|
||||||
const invitations_collection = "invitations";
|
const invitations_collection = "invitations";
|
||||||
const setting_doc_id = "setting";
|
|
||||||
const privilege_collection = "privileges";
|
const privilege_collection = "privileges";
|
||||||
const markets_collection = "markets";
|
const markets_collection = "markets";
|
||||||
const packages_collection = "packages";
|
const packages_collection = "packages";
|
||||||
const messages_collection = "messages";
|
const messages_collection = "messages";
|
||||||
const fcs_shipment_collection = "fcs_shipments";
|
const fcs_shipment_collection = "fcs_shipments";
|
||||||
const delivery_address_collection = "delivery_addresses";
|
const delivery_address_collection = "delivery_addresses";
|
||||||
|
const cargo_types_collection = "cargo_types";
|
||||||
|
const custom_duties_collection = "custom_duties";
|
||||||
|
const discounts_by_weights_collection = "discounts_by_weight";
|
||||||
|
|
||||||
|
// docs
|
||||||
|
const setting_doc_id = "setting";
|
||||||
|
const rate_doc_id = "rate";
|
||||||
|
|
||||||
const user_requested_status = "requested";
|
const user_requested_status = "requested";
|
||||||
const user_invited_status = "invited";
|
const user_invited_status = "invited";
|
||||||
@@ -17,6 +23,7 @@ const pkg_files_path = "/packages";
|
|||||||
// Link page
|
// Link page
|
||||||
const page_payment_methods = "payment_methods";
|
const page_payment_methods = "payment_methods";
|
||||||
const page_buying_instructions = "buying_instructions";
|
const page_buying_instructions = "buying_instructions";
|
||||||
|
const page_rates = "rates";
|
||||||
|
|
||||||
// Message type
|
// Message type
|
||||||
const message_type_package = "t_p";
|
const message_type_package = "t_p";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:fcs/domain/vo/shipment_status.dart';
|
import 'package:fcs/domain/vo/shipment_status.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
|
|
||||||
import 'cargo.dart';
|
import 'cargo_type.dart';
|
||||||
import 'package.dart';
|
import 'package.dart';
|
||||||
|
|
||||||
class Box {
|
class Box {
|
||||||
@@ -36,7 +36,7 @@ class Box {
|
|||||||
|
|
||||||
List<Package> packages;
|
List<Package> packages;
|
||||||
|
|
||||||
List<Cargo> cargoTypes;
|
List<CargoType> cargoTypes;
|
||||||
|
|
||||||
DeliveryAddress shippingAddress;
|
DeliveryAddress shippingAddress;
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
class Cargo {
|
|
||||||
String type;
|
|
||||||
int price;
|
|
||||||
int weight;
|
|
||||||
Cargo({this.type, this.price, this.weight});
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) => other is Cargo && other.type == type;
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => type.hashCode;
|
|
||||||
}
|
|
||||||
29
lib/domain/entities/cargo_type.dart
Normal file
29
lib/domain/entities/cargo_type.dart
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
class CargoType {
|
||||||
|
String id;
|
||||||
|
String name;
|
||||||
|
double rate;
|
||||||
|
|
||||||
|
factory CargoType.fromMap(Map<String, dynamic> map, String id) {
|
||||||
|
return CargoType(
|
||||||
|
id: id,
|
||||||
|
name: map['name'],
|
||||||
|
rate: (map['rate'] ?? 0).toDouble(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
int weight;
|
||||||
|
CargoType({this.id, this.name, this.rate, this.weight});
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
"id": id,
|
||||||
|
'name': name,
|
||||||
|
'rate': rate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) => other is CargoType && other.id == id;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => id.hashCode;
|
||||||
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
class Custom{
|
|
||||||
String id;
|
|
||||||
String productType;
|
|
||||||
int fee;
|
|
||||||
Custom({this.productType,this.fee});
|
|
||||||
}
|
|
||||||
25
lib/domain/entities/custom_duty.dart
Normal file
25
lib/domain/entities/custom_duty.dart
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
class CustomDuty {
|
||||||
|
String id;
|
||||||
|
String productType;
|
||||||
|
String desc;
|
||||||
|
double fee;
|
||||||
|
CustomDuty({this.id, this.productType, this.desc, this.fee});
|
||||||
|
|
||||||
|
factory CustomDuty.fromMap(Map<String, dynamic> map, String id) {
|
||||||
|
return CustomDuty(
|
||||||
|
id: id,
|
||||||
|
productType: map['product_type'],
|
||||||
|
desc: map['desc'],
|
||||||
|
fee: (map['fee'] ?? 0).toDouble(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
"id": id,
|
||||||
|
'product_type': productType,
|
||||||
|
'desc': desc,
|
||||||
|
'fee': fee,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
23
lib/domain/entities/discount_by_weight.dart
Normal file
23
lib/domain/entities/discount_by_weight.dart
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
class DiscountByWeight {
|
||||||
|
String id;
|
||||||
|
double weight;
|
||||||
|
double discount;
|
||||||
|
|
||||||
|
DiscountByWeight({this.id, this.weight, this.discount});
|
||||||
|
|
||||||
|
factory DiscountByWeight.fromMap(Map<String, dynamic> map, String id) {
|
||||||
|
return DiscountByWeight(
|
||||||
|
id: id,
|
||||||
|
weight: (map['weight'] ?? 0).toDouble(),
|
||||||
|
discount: (map['discount'] ?? 0).toDouble(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
"id": id,
|
||||||
|
'weight': weight,
|
||||||
|
'discount': discount,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
class DiscountRate {
|
|
||||||
int weight;
|
|
||||||
double discountRate;
|
|
||||||
|
|
||||||
DiscountRate({this.weight, this.discountRate});
|
|
||||||
}
|
|
||||||
@@ -1,31 +1,45 @@
|
|||||||
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
|
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||||
|
|
||||||
|
import 'cargo_type.dart';
|
||||||
|
|
||||||
class Rate {
|
class Rate {
|
||||||
String id;
|
double deliveryFee;
|
||||||
String name;
|
double freeDeliveryWeight;
|
||||||
String description;
|
double volumetricRatio;
|
||||||
String fromTime;
|
|
||||||
String toTime;
|
|
||||||
int price;
|
|
||||||
|
|
||||||
Rate(
|
List<CargoType> cargoTypes;
|
||||||
{this.id,
|
List<CustomDuty> customDuties;
|
||||||
this.name,
|
List<DiscountByWeight> discountByWeights;
|
||||||
this.description,
|
|
||||||
this.fromTime,
|
|
||||||
this.toTime,
|
|
||||||
this.price,});
|
|
||||||
|
|
||||||
factory Rate.fromMap(Map<String, dynamic> map, String id) {
|
CargoType get defaultCargoType => cargoTypes == null
|
||||||
|
? null
|
||||||
|
: cargoTypes.firstWhere((e) => e.name == "General");
|
||||||
|
|
||||||
|
Rate({
|
||||||
|
this.deliveryFee,
|
||||||
|
this.freeDeliveryWeight,
|
||||||
|
this.volumetricRatio,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Rate.fromMap(Map<String, dynamic> map) {
|
||||||
return Rate(
|
return Rate(
|
||||||
id: id,
|
deliveryFee: (map['delivery_fee'] ?? 0).toDouble(),
|
||||||
name: map['name'],
|
freeDeliveryWeight: (map['free_delivery_weight'] ?? 0).toDouble(),
|
||||||
description: map['description'],
|
volumetricRatio: (map['volumetric_ratio'] ?? 0).toDouble(),
|
||||||
fromTime: map['from_time'],
|
);
|
||||||
toTime: map['to_time'],
|
}
|
||||||
price: map['price'],);
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
"delivery_fee": deliveryFee,
|
||||||
|
'free_delivery_weight': freeDeliveryWeight,
|
||||||
|
'volumetric_ratio': volumetricRatio,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Rate{id:$id, name:$name,description:$description,fromTime:$fromTime,toTime:$toTime}';
|
return 'Rate{deliveryFee:$deliveryFee,freeDeliveryWeight:$freeDeliveryWeight,volumetricRatio:$volumetricRatio}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
import 'package:fcs/domain/entities/cargo.dart';
|
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
|
||||||
|
|
||||||
List<Day> dayLists = [
|
List<Day> dayLists = [
|
||||||
Day(id: 1, name: 'Sun'),
|
Day(id: 1, name: 'Sun'),
|
||||||
Day(id: 2, name: 'Mon'),
|
Day(id: 2, name: 'Mon'),
|
||||||
@@ -26,32 +23,24 @@ class Setting {
|
|||||||
final String termsEng;
|
final String termsEng;
|
||||||
final String termsMm;
|
final String termsMm;
|
||||||
String about;
|
String about;
|
||||||
double volumetricRatio;
|
|
||||||
|
|
||||||
List<String> shipmentTypes;
|
List<String> shipmentTypes;
|
||||||
Map<String, int> cargoTypes;
|
|
||||||
List<Cargo> get cargoTypesList => cargoTypes.entries
|
|
||||||
.map((e) => Cargo(type: e.key, price: e.value))
|
|
||||||
.toList();
|
|
||||||
Cargo get defaultCargoType =>
|
|
||||||
cargoTypesList.firstWhere((e) => e.type == "General");
|
|
||||||
|
|
||||||
Setting(
|
Setting({
|
||||||
{this.supportBuildNum,
|
this.supportBuildNum,
|
||||||
this.usaAddress,
|
this.usaAddress,
|
||||||
this.mmAddress,
|
this.mmAddress,
|
||||||
this.usaContactNumber,
|
this.usaContactNumber,
|
||||||
this.mmContactNumber,
|
this.mmContactNumber,
|
||||||
this.emailAddress,
|
this.emailAddress,
|
||||||
this.facebookLink,
|
this.facebookLink,
|
||||||
this.inviteRequired,
|
this.inviteRequired,
|
||||||
this.appUrl,
|
this.appUrl,
|
||||||
this.termsEng,
|
this.termsEng,
|
||||||
this.termsMm,
|
this.termsMm,
|
||||||
this.about,
|
this.about,
|
||||||
this.shipmentTypes,
|
this.shipmentTypes,
|
||||||
this.volumetricRatio,
|
});
|
||||||
this.cargoTypes});
|
|
||||||
|
|
||||||
factory Setting.fromMap(Map<String, dynamic> map) {
|
factory Setting.fromMap(Map<String, dynamic> map) {
|
||||||
return Setting(
|
return Setting(
|
||||||
@@ -67,11 +56,7 @@ class Setting {
|
|||||||
about: map['about'],
|
about: map['about'],
|
||||||
termsEng: map['terms_eng'],
|
termsEng: map['terms_eng'],
|
||||||
termsMm: map['terms_mm'],
|
termsMm: map['terms_mm'],
|
||||||
volumetricRatio: map['volumetric_ratio'],
|
|
||||||
shipmentTypes: List.from(map['shipment_types']),
|
shipmentTypes: List.from(map['shipment_types']),
|
||||||
cargoTypes: map['cargo_types'] == null
|
|
||||||
? []
|
|
||||||
: Map<String, int>.from(map['cargo_types']),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'cargo.dart';
|
import 'cargo_type.dart';
|
||||||
|
|
||||||
class Shipment {
|
class Shipment {
|
||||||
String id;
|
String id;
|
||||||
@@ -12,7 +12,7 @@ class Shipment {
|
|||||||
String address;
|
String address;
|
||||||
String status;
|
String status;
|
||||||
DateTime date;
|
DateTime date;
|
||||||
List<Cargo> cargoTypes;
|
List<CargoType> cargoTypes;
|
||||||
bool isCourier;
|
bool isCourier;
|
||||||
int radioIndex;
|
int radioIndex;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:fcs/domain/constants.dart';
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/box.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/package.dart';
|
||||||
import 'package:fcs/domain/entities/user.dart';
|
import 'package:fcs/domain/entities/user.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.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/model/main_model.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/package/model/package_model.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/user_search/user_serach.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.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/defalut_delivery_address.dart';
|
||||||
@@ -54,7 +55,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
List<Package> _packages = [];
|
List<Package> _packages = [];
|
||||||
List<Box> _shipmentBoxes = [];
|
List<Box> _shipmentBoxes = [];
|
||||||
List<Box> _mixBoxes = [];
|
List<Box> _mixBoxes = [];
|
||||||
List<Cargo> _cargoTypes = [];
|
List<CargoType> _cargoTypes = [];
|
||||||
double volumetricRatio = 0;
|
double volumetricRatio = 0;
|
||||||
double shipmentWeight = 0;
|
double shipmentWeight = 0;
|
||||||
Box _selectedShipmentBox;
|
Box _selectedShipmentBox;
|
||||||
@@ -83,8 +84,9 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//for shipment weight
|
//for shipment weight
|
||||||
volumetricRatio =
|
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||||
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
|
.rate
|
||||||
|
.volumetricRatio;
|
||||||
_lengthController.addListener(_calShipmentWeight);
|
_lengthController.addListener(_calShipmentWeight);
|
||||||
_widthController.addListener(_calShipmentWeight);
|
_widthController.addListener(_calShipmentWeight);
|
||||||
_heightController.addListener(_calShipmentWeight);
|
_heightController.addListener(_calShipmentWeight);
|
||||||
@@ -101,9 +103,9 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
isNew = false;
|
isNew = false;
|
||||||
} else {
|
} else {
|
||||||
_cargoTypes = [
|
_cargoTypes = [
|
||||||
Cargo(type: 'General', weight: 25),
|
CargoType(id: "1", name: 'General', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(id: "2", name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous', weight: 30)
|
CargoType(id: "3", name: 'Dangerous', weight: 30)
|
||||||
];
|
];
|
||||||
|
|
||||||
var shipmentModel =
|
var shipmentModel =
|
||||||
@@ -401,7 +403,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
total += c.value.weight;
|
total += c.value.weight;
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Cargo cargo = await Navigator.push<Cargo>(
|
CargoType cargo = await Navigator.push<CargoType>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => CargoTypeEditor(cargo: c.value)),
|
builder: (context) => CargoTypeEditor(cargo: c.value)),
|
||||||
@@ -422,7 +424,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: new Text(
|
child: new Text(
|
||||||
c.value.type,
|
c.value.name,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
)),
|
||||||
Row(
|
Row(
|
||||||
@@ -630,7 +632,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Cargo cargo = await Navigator.push<Cargo>(
|
CargoType cargo = await Navigator.push<CargoType>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => CargoTypeEditor()),
|
builder: (context) => CargoTypeEditor()),
|
||||||
@@ -700,7 +702,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
_addCargo(Cargo cargo) {
|
_addCargo(CargoType cargo) {
|
||||||
if (cargo == null) return;
|
if (cargo == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
_cargoTypes.remove(cargo);
|
_cargoTypes.remove(cargo);
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import 'package:fcs/domain/constants.dart';
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/box.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/package.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/package/model/package_model.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/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
@@ -48,7 +49,7 @@ class _BoxInfoState extends State<BoxInfo> {
|
|||||||
List<Package> _packages = [];
|
List<Package> _packages = [];
|
||||||
List<Box> _mixBoxes = [];
|
List<Box> _mixBoxes = [];
|
||||||
Box _selectedShipmentBox;
|
Box _selectedShipmentBox;
|
||||||
List<Cargo> _cargoTypes = [];
|
List<CargoType> _cargoTypes = [];
|
||||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||||
TextEditingController _widthController = new TextEditingController();
|
TextEditingController _widthController = new TextEditingController();
|
||||||
TextEditingController _heightController = new TextEditingController();
|
TextEditingController _heightController = new TextEditingController();
|
||||||
@@ -83,8 +84,9 @@ class _BoxInfoState extends State<BoxInfo> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//for shipment weight
|
//for shipment weight
|
||||||
volumetricRatio =
|
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||||
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
|
.rate
|
||||||
|
.volumetricRatio;
|
||||||
_lengthController.addListener(_calShipmentWeight);
|
_lengthController.addListener(_calShipmentWeight);
|
||||||
_widthController.addListener(_calShipmentWeight);
|
_widthController.addListener(_calShipmentWeight);
|
||||||
_heightController.addListener(_calShipmentWeight);
|
_heightController.addListener(_calShipmentWeight);
|
||||||
@@ -342,7 +344,7 @@ class _BoxInfoState extends State<BoxInfo> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: new Text(
|
child: new Text(
|
||||||
c.value.type,
|
c.value.name,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
)),
|
||||||
Container(
|
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/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
import 'package:fcs/pages/main/util.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/input_text.dart';
|
||||||
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.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';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class CargoTypeEditor extends StatefulWidget {
|
class CargoTypeEditor extends StatefulWidget {
|
||||||
final Cargo cargo;
|
final CargoType cargo;
|
||||||
CargoTypeEditor({this.cargo});
|
CargoTypeEditor({this.cargo});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -23,7 +24,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
|||||||
TextEditingController _weightController = new TextEditingController();
|
TextEditingController _weightController = new TextEditingController();
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
Cargo _cargo;
|
CargoType _cargo;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -37,8 +38,9 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_loadDefalut() {
|
_loadDefalut() {
|
||||||
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
ShipmentRateModel shipmentRateModel =
|
||||||
_cargo = mainModel.setting.defaultCargoType;
|
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||||
|
_cargo = shipmentRateModel.rate.defaultCargoType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -48,8 +50,9 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
MainModel mainModel = Provider.of<MainModel>(context);
|
ShipmentRateModel shipmentRateModel =
|
||||||
List<Cargo> cargos = mainModel.setting.cargoTypesList;
|
Provider.of<ShipmentRateModel>(context);
|
||||||
|
List<CargoType> cargos = shipmentRateModel.rate.cargoTypes;
|
||||||
|
|
||||||
final rateBox = InputText(
|
final rateBox = InputText(
|
||||||
labelTextKey: 'cargo.weight',
|
labelTextKey: 'cargo.weight',
|
||||||
@@ -57,7 +60,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
|||||||
textInputType: TextInputType.number,
|
textInputType: TextInputType.number,
|
||||||
controller: _weightController);
|
controller: _weightController);
|
||||||
|
|
||||||
var cargoTypeBox = LocalDropdown<Cargo>(
|
var cargoTypeBox = LocalDropdown<CargoType>(
|
||||||
callback: (v) {
|
callback: (v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_cargo = v;
|
_cargo = v;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'dart:async';
|
|||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:fcs/domain/constants.dart';
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/box.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/package.dart';
|
||||||
import 'package:fcs/domain/vo/shipment_status.dart';
|
import 'package:fcs/domain/vo/shipment_status.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
@@ -55,9 +55,9 @@ class BoxModel extends BaseModel {
|
|||||||
state: 'NY',
|
state: 'NY',
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
phoneNumber: '+1 (292)215-2247'),
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General', weight: 25),
|
CargoType(name: 'General', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous', weight: 30)
|
CargoType(name: 'Dangerous', weight: 30)
|
||||||
]),
|
]),
|
||||||
Box(
|
Box(
|
||||||
shipmentNumber: "A203",
|
shipmentNumber: "A203",
|
||||||
@@ -87,9 +87,9 @@ class BoxModel extends BaseModel {
|
|||||||
state: 'Myanmar',
|
state: 'Myanmar',
|
||||||
phoneNumber: '+09 95724 8750'),
|
phoneNumber: '+09 95724 8750'),
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General', weight: 25),
|
CargoType(name: 'General', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous', weight: 30)
|
CargoType(name: 'Dangerous', weight: 30)
|
||||||
]),
|
]),
|
||||||
Box(
|
Box(
|
||||||
shipmentNumber: "A204",
|
shipmentNumber: "A204",
|
||||||
@@ -119,9 +119,9 @@ class BoxModel extends BaseModel {
|
|||||||
state: 'Myanmar',
|
state: 'Myanmar',
|
||||||
phoneNumber: '+09 95724 8750'),
|
phoneNumber: '+09 95724 8750'),
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General', weight: 25),
|
CargoType(name: 'General', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous', weight: 30)
|
CargoType(name: 'Dangerous', weight: 30)
|
||||||
]),
|
]),
|
||||||
Box(
|
Box(
|
||||||
shipmentNumber: "A202",
|
shipmentNumber: "A202",
|
||||||
@@ -150,9 +150,9 @@ class BoxModel extends BaseModel {
|
|||||||
state: 'NY',
|
state: 'NY',
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
phoneNumber: '+1 (292)215-2247'),
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General', weight: 25),
|
CargoType(name: 'General', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous', weight: 30)
|
CargoType(name: 'Dangerous', weight: 30)
|
||||||
]),
|
]),
|
||||||
Box(
|
Box(
|
||||||
shipmentNumber: "A202",
|
shipmentNumber: "A202",
|
||||||
@@ -180,9 +180,9 @@ class BoxModel extends BaseModel {
|
|||||||
state: 'NY',
|
state: 'NY',
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
phoneNumber: '+1 (292)215-2247'),
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General', weight: 25),
|
CargoType(name: 'General', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous', weight: 30)
|
CargoType(name: 'Dangerous', weight: 30)
|
||||||
]),
|
]),
|
||||||
Box(
|
Box(
|
||||||
shipmentNumber: "A202",
|
shipmentNumber: "A202",
|
||||||
@@ -210,9 +210,9 @@ class BoxModel extends BaseModel {
|
|||||||
state: 'NY',
|
state: 'NY',
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
phoneNumber: '+1 (292)215-2247'),
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General', weight: 25),
|
CargoType(name: 'General', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous', weight: 30)
|
CargoType(name: 'Dangerous', weight: 30)
|
||||||
]),
|
]),
|
||||||
Box(
|
Box(
|
||||||
shipmentNumber: "A201",
|
shipmentNumber: "A201",
|
||||||
@@ -240,9 +240,9 @@ class BoxModel extends BaseModel {
|
|||||||
state: 'NY',
|
state: 'NY',
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
phoneNumber: '+1 (292)215-2247'),
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General', weight: 25),
|
CargoType(name: 'General', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous', weight: 30)
|
CargoType(name: 'Dangerous', weight: 30)
|
||||||
]),
|
]),
|
||||||
Box(
|
Box(
|
||||||
shipmentNumber: "A201",
|
shipmentNumber: "A201",
|
||||||
@@ -270,9 +270,9 @@ class BoxModel extends BaseModel {
|
|||||||
state: 'NY',
|
state: 'NY',
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
phoneNumber: '+1 (292)215-2247'),
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General', weight: 25),
|
CargoType(name: 'General', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous', weight: 30)
|
CargoType(name: 'Dangerous', weight: 30)
|
||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -105,16 +105,13 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: Colors.white,
|
||||||
title: LocalText(
|
shadowColor: Colors.transparent,
|
||||||
context,
|
title: LocalText(context, 'delivery_address',
|
||||||
'delivery_address',
|
color: primaryColor, fontSize: 18),
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 20,
|
|
||||||
),
|
|
||||||
actions: [IconButton(icon: Icon(Icons.delete), onPressed: _delete)],
|
actions: [IconButton(icon: Icon(Icons.delete), onPressed: _delete)],
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ import 'package:fcs/domain/vo/delivery_address.dart';
|
|||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
|
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'model/delivery_address_model.dart';
|
|
||||||
import 'delivery_address_row.dart';
|
import 'delivery_address_row.dart';
|
||||||
|
import 'model/delivery_address_model.dart';
|
||||||
|
|
||||||
class DeliveryAddressList extends StatefulWidget {
|
class DeliveryAddressList extends StatefulWidget {
|
||||||
const DeliveryAddressList({Key key}) : super(key: key);
|
const DeliveryAddressList({Key key}) : super(key: key);
|
||||||
@@ -41,16 +40,13 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
),
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
title: LocalText(
|
|
||||||
context,
|
|
||||||
"delivery_addresses",
|
|
||||||
fontSize: 20,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
),
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
title: LocalText(context, 'delivery_addresses',
|
||||||
|
color: primaryColor, fontSize: 20),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton.extended(
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
@@ -94,8 +94,12 @@ class _FAQEditorState extends State<FAQEditor> {
|
|||||||
_pageLink = newValue;
|
_pageLink = newValue;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
items: <String>[info, page_buying_instructions, page_payment_methods]
|
items: <String>[
|
||||||
.map<DropdownMenuItem<String>>((String value) {
|
info,
|
||||||
|
page_buying_instructions,
|
||||||
|
page_payment_methods,
|
||||||
|
page_rates
|
||||||
|
].map<DropdownMenuItem<String>>((String value) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -116,6 +120,64 @@ class _FAQEditorState extends State<FAQEditor> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
|
inAsyncCall: _isLoading,
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
leading: new IconButton(
|
||||||
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
title: LocalText(
|
||||||
|
context, _isNew ? 'faq.add.title' : 'faq.edit.title',
|
||||||
|
color: primaryColor, fontSize: 20),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.delete),
|
||||||
|
onPressed: _delete,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(left: 24.0, right: 24.0),
|
||||||
|
child: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
snBox,
|
||||||
|
Center(child: itemTitle(context, "faq.edit.eng")),
|
||||||
|
subItemTitle(context, "faq.edit.question",
|
||||||
|
iconData: SimpleLineIcons.question),
|
||||||
|
questionEngBox,
|
||||||
|
subItemTitle(context, "faq.edit.answer",
|
||||||
|
iconData: MaterialCommunityIcons.message_reply_text),
|
||||||
|
answerEngBox,
|
||||||
|
Divider(),
|
||||||
|
Center(child: itemTitle(context, "faq.edit.mm")),
|
||||||
|
subItemTitle(context, "faq.edit.question",
|
||||||
|
iconData: SimpleLineIcons.question),
|
||||||
|
questionMmBox,
|
||||||
|
subItemTitle(context, "faq.edit.answer",
|
||||||
|
iconData: MaterialCommunityIcons.message_reply_text),
|
||||||
|
answerMmBox,
|
||||||
|
Divider(),
|
||||||
|
Center(child: itemTitle(context, "faq.edit.page")),
|
||||||
|
pageLinkBox,
|
||||||
|
pageLabelEngBox,
|
||||||
|
pageLabelMmBox,
|
||||||
|
fcsButton(context, getLocalString(context, "btn.save"),
|
||||||
|
callack: _save),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)));
|
||||||
|
|
||||||
|
LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: CustomScrollView(slivers: [
|
body: CustomScrollView(slivers: [
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:fcs/pages/faq/faq_edit_page.dart';
|
|||||||
import 'package:fcs/pages/main/model/language_model.dart';
|
import 'package:fcs/pages/main/model/language_model.dart';
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
import 'package:fcs/pages/payment_methods/payment_method_page.dart';
|
import 'package:fcs/pages/payment_methods/payment_method_page.dart';
|
||||||
|
import 'package:fcs/pages/rates/shipment_rates.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/fcs_expansion_tile.dart';
|
import 'package:fcs/pages/widgets/fcs_expansion_tile.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
@@ -43,6 +44,32 @@ class _FAQListPageState extends State<FAQListPage>
|
|||||||
bool isEditable = context.select((MainModel m) => m.faqEditable());
|
bool isEditable = context.select((MainModel m) => m.faqEditable());
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
title: LocalText(
|
||||||
|
context,
|
||||||
|
"faq.title",
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 20,
|
||||||
|
),
|
||||||
|
leading: new IconButton(
|
||||||
|
icon: new Icon(CupertinoIcons.back),
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
backgroundColor: primaryColor,
|
||||||
|
actions: isEditable
|
||||||
|
? [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () => setState(() {
|
||||||
|
isEditMode = !isEditMode;
|
||||||
|
}),
|
||||||
|
icon: Icon(
|
||||||
|
Icons.edit,
|
||||||
|
color: Colors.white,
|
||||||
|
))
|
||||||
|
]
|
||||||
|
: [],
|
||||||
|
),
|
||||||
floatingActionButton: isEditable
|
floatingActionButton: isEditable
|
||||||
? FloatingActionButton.extended(
|
? FloatingActionButton.extended(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -54,54 +81,11 @@ class _FAQListPageState extends State<FAQListPage>
|
|||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
)
|
)
|
||||||
: Container(),
|
: Container(),
|
||||||
body: CustomScrollView(
|
body: ListView.builder(
|
||||||
slivers: [
|
itemCount: faqModel.faqs.length,
|
||||||
SliverAppBar(
|
itemBuilder: (BuildContext context, int index) {
|
||||||
leading: IconButton(
|
return _faqItem(context, faqModel.faqs[index]);
|
||||||
icon: Icon(
|
}));
|
||||||
CupertinoIcons.back,
|
|
||||||
size: 30,
|
|
||||||
),
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
),
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
expandedHeight: 150.0,
|
|
||||||
floating: false,
|
|
||||||
pinned: true,
|
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
|
||||||
centerTitle: true,
|
|
||||||
titlePadding:
|
|
||||||
EdgeInsets.symmetric(vertical: 10, horizontal: 45),
|
|
||||||
title: LocalText(
|
|
||||||
context,
|
|
||||||
"faq.title",
|
|
||||||
fontSize: 20,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: isEditable
|
|
||||||
? [
|
|
||||||
IconButton(
|
|
||||||
onPressed: () => setState(() {
|
|
||||||
isEditMode = !isEditMode;
|
|
||||||
}),
|
|
||||||
icon: Icon(
|
|
||||||
Icons.edit,
|
|
||||||
color: Colors.white,
|
|
||||||
))
|
|
||||||
]
|
|
||||||
: [],
|
|
||||||
),
|
|
||||||
SliverList(
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
(context, index) {
|
|
||||||
return _faqItem(context, faqModel.faqs[index]);
|
|
||||||
},
|
|
||||||
childCount: faqModel.faqs.length,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isEditMode = false;
|
bool isEditMode = false;
|
||||||
@@ -177,6 +161,9 @@ class _FAQListPageState extends State<FAQListPage>
|
|||||||
} else if (linkPage == page_buying_instructions) {
|
} else if (linkPage == page_buying_instructions) {
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.push(CupertinoPageRoute(builder: (context) => BuyingOnlinePage()));
|
.push(CupertinoPageRoute(builder: (context) => BuyingOnlinePage()));
|
||||||
|
} else if (linkPage == page_rates) {
|
||||||
|
Navigator.of(context)
|
||||||
|
.push(CupertinoPageRoute(builder: (context) => ShipmentRates()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:fcs/domain/entities/box.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/custom.dart';
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
import 'package:fcs/domain/entities/discount.dart';
|
import 'package:fcs/domain/entities/discount.dart';
|
||||||
import 'package:fcs/domain/entities/invoice.dart';
|
import 'package:fcs/domain/entities/invoice.dart';
|
||||||
import 'package:fcs/domain/entities/payment_method.dart';
|
import 'package:fcs/domain/entities/payment_method.dart';
|
||||||
@@ -14,6 +14,7 @@ import 'package:fcs/pages/main/model/main_model.dart';
|
|||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/payment_methods/model/payment_method_model.dart';
|
import 'package:fcs/pages/payment_methods/model/payment_method_model.dart';
|
||||||
import 'package:fcs/pages/rates/custom_list.dart';
|
import 'package:fcs/pages/rates/custom_list.dart';
|
||||||
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||||
import 'package:fcs/pages/user_search/user_serach.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/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/discount_dropdown.dart';
|
import 'package:fcs/pages/widgets/discount_dropdown.dart';
|
||||||
@@ -67,7 +68,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
List<Box> _boxes = [];
|
List<Box> _boxes = [];
|
||||||
bool isSwitched = false;
|
bool isSwitched = false;
|
||||||
int deliveryfee = 0;
|
int deliveryfee = 0;
|
||||||
int customFee = 10;
|
double customFee = 10;
|
||||||
int handlingFee = 0;
|
int handlingFee = 0;
|
||||||
double total = 0;
|
double total = 0;
|
||||||
Discount _discount;
|
Discount _discount;
|
||||||
@@ -78,12 +79,12 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
double volumetricRatio = 0;
|
double volumetricRatio = 0;
|
||||||
|
|
||||||
List<Box> selectedBoxes = [];
|
List<Box> selectedBoxes = [];
|
||||||
List<Custom> customs = [];
|
List<CustomDuty> customs = [];
|
||||||
|
|
||||||
List<Cargo> _cargoTypes = [
|
List<CargoType> _cargoTypes = [
|
||||||
Cargo(type: 'General Cargo', weight: 33, price: 6),
|
CargoType(name: 'General Cargo', weight: 33, rate: 6),
|
||||||
Cargo(type: 'Medicine', weight: 33, price: 7),
|
CargoType(name: 'Medicine', weight: 33, rate: 7),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 33, price: 8)
|
CargoType(name: 'Dangerous Cargo', weight: 33, rate: 8)
|
||||||
];
|
];
|
||||||
|
|
||||||
List<String> _receipts = [
|
List<String> _receipts = [
|
||||||
@@ -94,8 +95,9 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
volumetricRatio =
|
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||||
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
|
.rate
|
||||||
|
.volumetricRatio;
|
||||||
|
|
||||||
if (widget.invoice != null) {
|
if (widget.invoice != null) {
|
||||||
_invoice = widget.invoice;
|
_invoice = widget.invoice;
|
||||||
@@ -148,9 +150,9 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
// packages: packages,
|
// packages: packages,
|
||||||
// statusHistory: statusHistory,
|
// statusHistory: statusHistory,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Box(
|
Box(
|
||||||
shipmentNumber: "A202",
|
shipmentNumber: "A202",
|
||||||
@@ -170,9 +172,9 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
// packages: packages,
|
// packages: packages,
|
||||||
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
|
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -257,7 +259,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon: Icon(Icons.add_circle, color: primaryColor),
|
icon: Icon(Icons.add_circle, color: primaryColor),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Custom custom = await Navigator.of(context).push(
|
CustomDuty custom = await Navigator.of(context).push(
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => CustomList()));
|
builder: (context) => CustomList()));
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -492,7 +494,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
var discountModel = Provider.of<DiscountModel>(context);
|
var discountModel = Provider.of<DiscountModel>(context);
|
||||||
total = 0;
|
total = 0;
|
||||||
List<Widget> dataRow = _cargoTypes.map((cargo) {
|
List<Widget> dataRow = _cargoTypes.map((cargo) {
|
||||||
var amount = cargo.weight * cargo.price;
|
var amount = cargo.weight * cargo.rate;
|
||||||
total += amount;
|
total += amount;
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -501,10 +503,10 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
|
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(flex: 2, child: Text('${cargo.type}')),
|
Expanded(flex: 2, child: Text('${cargo.name}')),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Text('${cargo.weight} x ${cargo.price}',
|
child: Text('${cargo.weight} x ${cargo.rate}',
|
||||||
textAlign: TextAlign.center)),
|
textAlign: TextAlign.center)),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text('\$ $amount',
|
child: Text('\$ $amount',
|
||||||
@@ -820,7 +822,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
return _boxes.map((p) {
|
return _boxes.map((p) {
|
||||||
p.cargoTypes.map((cargo) {
|
p.cargoTypes.map((cargo) {
|
||||||
_cargoTypes.asMap().map((index, _cargo) {
|
_cargoTypes.asMap().map((index, _cargo) {
|
||||||
if (_cargo.type == cargo.type) {
|
if (_cargo.id == cargo.id) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_cargoTypes[index].weight += cargo.weight;
|
_cargoTypes[index].weight += cargo.weight;
|
||||||
});
|
});
|
||||||
@@ -860,16 +862,16 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
List<MyDataRow> getCargoDataRow(BuildContext context) {
|
List<MyDataRow> getCargoDataRow(BuildContext context) {
|
||||||
return _cargoTypes.asMap().entries.map((c) {
|
return _cargoTypes.asMap().entries.map((c) {
|
||||||
var cargo = c.value;
|
var cargo = c.value;
|
||||||
var amt = cargo.weight * cargo.price;
|
var amt = cargo.weight * cargo.rate;
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (bool selected) {},
|
onSelectChanged: (bool selected) {},
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(new Text(
|
MyDataCell(new Text(
|
||||||
cargo.type,
|
cargo.name,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
)),
|
||||||
MyDataCell(new Text(
|
MyDataCell(new Text(
|
||||||
cargo.weight.toString() + ' x ' + cargo.price.toString(),
|
cargo.weight.toString() + ' x ' + cargo.rate.toString(),
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
)),
|
||||||
MyDataCell(new Text(
|
MyDataCell(new Text(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:fcs/domain/entities/box.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/custom.dart';
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
import 'package:fcs/domain/entities/discount.dart';
|
import 'package:fcs/domain/entities/discount.dart';
|
||||||
import 'package:fcs/domain/entities/invoice.dart';
|
import 'package:fcs/domain/entities/invoice.dart';
|
||||||
import 'package:fcs/domain/entities/payment_method.dart';
|
import 'package:fcs/domain/entities/payment_method.dart';
|
||||||
@@ -15,6 +15,7 @@ import 'package:fcs/pages/main/model/main_model.dart';
|
|||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/payment_methods/model/payment_method_model.dart';
|
import 'package:fcs/pages/payment_methods/model/payment_method_model.dart';
|
||||||
import 'package:fcs/pages/rates/custom_list.dart';
|
import 'package:fcs/pages/rates/custom_list.dart';
|
||||||
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||||
import 'package:fcs/pages/user_search/user_serach.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/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/discount_dropdown.dart';
|
import 'package:fcs/pages/widgets/discount_dropdown.dart';
|
||||||
@@ -67,7 +68,7 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
|||||||
List<Box> _boxes = [];
|
List<Box> _boxes = [];
|
||||||
bool isSwitched = false;
|
bool isSwitched = false;
|
||||||
int deliveryfee = 0;
|
int deliveryfee = 0;
|
||||||
int customFee = 0;
|
double customFee = 0;
|
||||||
double total = 0;
|
double total = 0;
|
||||||
Discount _discount;
|
Discount _discount;
|
||||||
bool isNew = false;
|
bool isNew = false;
|
||||||
@@ -77,12 +78,12 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
|||||||
double volumetricRatio = 0;
|
double volumetricRatio = 0;
|
||||||
|
|
||||||
List<Box> selectedBoxes = [];
|
List<Box> selectedBoxes = [];
|
||||||
List<Custom> customs = [];
|
List<CustomDuty> customs = [];
|
||||||
|
|
||||||
List<Cargo> _cargoTypes = [
|
List<CargoType> _cargoTypes = [
|
||||||
Cargo(type: 'General Cargo', weight: 33, price: 6),
|
CargoType(id: "1", name: 'General Cargo', weight: 33, rate: 6),
|
||||||
Cargo(type: 'Medicine', weight: 33, price: 7),
|
CargoType(id: "2", name: 'Medicine', weight: 33, rate: 7),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 33, price: 8)
|
CargoType(id: "3", name: 'Dangerous Cargo', weight: 33, rate: 8)
|
||||||
];
|
];
|
||||||
|
|
||||||
List<String> _receipts = [
|
List<String> _receipts = [
|
||||||
@@ -92,8 +93,9 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
volumetricRatio =
|
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||||
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
|
.rate
|
||||||
|
.volumetricRatio;
|
||||||
|
|
||||||
if (widget.invoice != null) {
|
if (widget.invoice != null) {
|
||||||
_invoice = widget.invoice;
|
_invoice = widget.invoice;
|
||||||
@@ -142,9 +144,9 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
|||||||
// packages: packages,
|
// packages: packages,
|
||||||
// statusHistory: statusHistory,
|
// statusHistory: statusHistory,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Box(
|
Box(
|
||||||
shipmentNumber: "A202",
|
shipmentNumber: "A202",
|
||||||
@@ -164,9 +166,9 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
|||||||
// packages: packages,
|
// packages: packages,
|
||||||
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
|
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -444,7 +446,7 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
|||||||
getCargoTableByBox(BuildContext context) {
|
getCargoTableByBox(BuildContext context) {
|
||||||
total = 0;
|
total = 0;
|
||||||
List<Widget> dataRow = _cargoTypes.map((cargo) {
|
List<Widget> dataRow = _cargoTypes.map((cargo) {
|
||||||
var amount = cargo.weight * cargo.price;
|
var amount = cargo.weight * cargo.rate;
|
||||||
total += amount;
|
total += amount;
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -453,10 +455,10 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
|||||||
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
|
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(flex: 2, child: Text('${cargo.type}')),
|
Expanded(flex: 2, child: Text('${cargo.rate}')),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Text('${cargo.weight} x ${cargo.price}',
|
child: Text('${cargo.weight} x ${cargo.rate}',
|
||||||
textAlign: TextAlign.center)),
|
textAlign: TextAlign.center)),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text('\$ $amount',
|
child: Text('\$ $amount',
|
||||||
@@ -736,7 +738,7 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
|||||||
return _boxes.map((p) {
|
return _boxes.map((p) {
|
||||||
p.cargoTypes.map((cargo) {
|
p.cargoTypes.map((cargo) {
|
||||||
_cargoTypes.asMap().map((index, _cargo) {
|
_cargoTypes.asMap().map((index, _cargo) {
|
||||||
if (_cargo.type == cargo.type) {
|
if (_cargo.id == cargo.id) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_cargoTypes[index].weight += cargo.weight;
|
_cargoTypes[index].weight += cargo.weight;
|
||||||
});
|
});
|
||||||
@@ -776,16 +778,16 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
|||||||
List<MyDataRow> getCargoDataRow(BuildContext context) {
|
List<MyDataRow> getCargoDataRow(BuildContext context) {
|
||||||
return _cargoTypes.asMap().entries.map((c) {
|
return _cargoTypes.asMap().entries.map((c) {
|
||||||
var cargo = c.value;
|
var cargo = c.value;
|
||||||
var amt = cargo.weight * cargo.price;
|
var amt = cargo.weight * cargo.rate;
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (bool selected) {},
|
onSelectChanged: (bool selected) {},
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(new Text(
|
MyDataCell(new Text(
|
||||||
cargo.type,
|
cargo.name,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
)),
|
||||||
MyDataCell(new Text(
|
MyDataCell(new Text(
|
||||||
cargo.weight.toString() + ' x ' + cargo.price.toString(),
|
cargo.weight.toString() + ' x ' + cargo.rate.toString(),
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
)),
|
||||||
MyDataCell(new Text(
|
MyDataCell(new Text(
|
||||||
|
|||||||
@@ -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/helpers/theme.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|||||||
@@ -24,12 +24,10 @@ import 'package:fcs/pages/package/model/package_model.dart';
|
|||||||
import 'package:fcs/pages/package/package_info.dart';
|
import 'package:fcs/pages/package/package_info.dart';
|
||||||
import 'package:fcs/pages/package/package_list.dart';
|
import 'package:fcs/pages/package/package_list.dart';
|
||||||
import 'package:fcs/pages/processing/processing_list.dart';
|
import 'package:fcs/pages/processing/processing_list.dart';
|
||||||
import 'package:fcs/pages/rates/shipment_rates.dart';
|
|
||||||
import 'package:fcs/pages/receiving/receiving_list.dart';
|
import 'package:fcs/pages/receiving/receiving_list.dart';
|
||||||
import 'package:fcs/pages/shipment/shipment_list.dart';
|
import 'package:fcs/pages/shipment/shipment_list.dart';
|
||||||
import 'package:fcs/pages/staff/staff_list.dart';
|
import 'package:fcs/pages/staff/staff_list.dart';
|
||||||
import 'package:fcs/pages/widgets/badge.dart';
|
import 'package:fcs/pages/widgets/badge.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
||||||
import 'package:fcs/pages/widgets/bottom_widgets.dart';
|
import 'package:fcs/pages/widgets/bottom_widgets.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
@@ -254,12 +252,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
btnCallback: () => Navigator.of(context)
|
btnCallback: () => Navigator.of(context)
|
||||||
.push(CupertinoPageRoute(builder: (context) => ShipmentList())));
|
.push(CupertinoPageRoute(builder: (context) => ShipmentList())));
|
||||||
|
|
||||||
final shipmentCostBtn = TaskButton("rate",
|
|
||||||
icon: FontAwesomeIcons.calculator,
|
|
||||||
btnCallback: () => Navigator.of(context).push(CupertinoPageRoute(
|
|
||||||
builder: (context) => ShipmentRates(),
|
|
||||||
)));
|
|
||||||
|
|
||||||
final fcsShipmentBtn = TaskButton("FCSshipment.title",
|
final fcsShipmentBtn = TaskButton("FCSshipment.title",
|
||||||
icon: Ionicons.ios_airplane,
|
icon: Ionicons.ios_airplane,
|
||||||
btnCallback: () => Navigator.of(context).push(CupertinoPageRoute(
|
btnCallback: () => Navigator.of(context).push(CupertinoPageRoute(
|
||||||
@@ -324,7 +316,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
widgets.add(shipmentBtn);
|
widgets.add(shipmentBtn);
|
||||||
widgets.add(invoicesBtn);
|
widgets.add(invoicesBtn);
|
||||||
widgets.add(faqBtn);
|
widgets.add(faqBtn);
|
||||||
widgets.add(shipmentCostBtn);
|
|
||||||
|
|
||||||
List<Widget> widgetsFcs = [];
|
List<Widget> widgetsFcs = [];
|
||||||
if (user.hasPackages()) widgetsFcs.add(packagesBtnFcs);
|
if (user.hasPackages()) widgetsFcs.add(packagesBtnFcs);
|
||||||
@@ -374,7 +365,8 @@ class _HomePageState extends State<HomePage> {
|
|||||||
);
|
);
|
||||||
final signinBtn = FlatButton(
|
final signinBtn = FlatButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).push(CupertinoPageRoute(builder: (context) => SigninPage()));
|
Navigator.of(context)
|
||||||
|
.push(CupertinoPageRoute(builder: (context) => SigninPage()));
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
"Sign In",
|
"Sign In",
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ class MainModel extends ChangeNotifier {
|
|||||||
return this.user != null && this.user.hasSupport();
|
return this.user != null && this.user.hasSupport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool rateEditable() {
|
||||||
|
return this.user != null && this.user.hasSupport();
|
||||||
|
}
|
||||||
|
|
||||||
bool paymentMethodsEditable() {
|
bool paymentMethodsEditable() {
|
||||||
return this.user != null && this.user.hasSupport();
|
return this.user != null && this.user.hasSupport();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
|||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/package/model/package_model.dart';
|
import 'package:fcs/pages/package/model/package_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/defalut_delivery_address.dart';
|
||||||
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
@@ -20,7 +19,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:timeline_list/timeline_model.dart';
|
|
||||||
|
|
||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
|
|
||||||
@@ -84,11 +82,6 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
labelTextKey: "package.create.name",
|
labelTextKey: "package.create.name",
|
||||||
iconData: Icons.perm_identity,
|
iconData: Icons.perm_identity,
|
||||||
);
|
);
|
||||||
final statusBox = DisplayText(
|
|
||||||
text: _package.currentStatus,
|
|
||||||
labelTextKey: "package.edit.status",
|
|
||||||
iconData: AntDesign.exclamationcircleo,
|
|
||||||
);
|
|
||||||
final marketBox = DisplayText(
|
final marketBox = DisplayText(
|
||||||
text: _package.market ?? "-",
|
text: _package.market ?? "-",
|
||||||
labelTextKey: "package.create.market",
|
labelTextKey: "package.create.market",
|
||||||
@@ -156,7 +149,6 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
widget.isSearchResult ? Container() : fcsIDBox,
|
widget.isSearchResult ? Container() : fcsIDBox,
|
||||||
widget.isSearchResult ? Container() : customerNameBox,
|
widget.isSearchResult ? Container() : customerNameBox,
|
||||||
widget.isSearchResult ? Container() : marketBox,
|
widget.isSearchResult ? Container() : marketBox,
|
||||||
statusBox,
|
|
||||||
_package.photoUrls.length == 0 ? Container() : img,
|
_package.photoUrls.length == 0 ? Container() : img,
|
||||||
widget.isSearchResult ? Container() : descBox,
|
widget.isSearchResult ? Container() : descBox,
|
||||||
remarkBox,
|
remarkBox,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:fcs/domain/entities/rate.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
@@ -8,8 +8,8 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class CargoEditor extends StatefulWidget {
|
class CargoEditor extends StatefulWidget {
|
||||||
final Rate rate;
|
final CargoType cargo;
|
||||||
CargoEditor({this.rate});
|
CargoEditor({this.cargo});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_CargoEditorState createState() => _CargoEditorState();
|
_CargoEditorState createState() => _CargoEditorState();
|
||||||
@@ -20,15 +20,14 @@ class _CargoEditorState extends State<CargoEditor> {
|
|||||||
TextEditingController _rateController = new TextEditingController();
|
TextEditingController _rateController = new TextEditingController();
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
Rate _rate = new Rate();
|
CargoType _cargo;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (widget.rate != null) {
|
if (widget.cargo != null) {
|
||||||
_rate = widget.rate;
|
_cargo = widget.cargo;
|
||||||
_descController.text = _rate.description;
|
_descController.text = _cargo.name;
|
||||||
_rateController.text = _rate.price.toString();
|
_rateController.text = _cargo.rate.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +71,7 @@ class _CargoEditorState extends State<CargoEditor> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
widget.rate == null
|
widget.cargo == null
|
||||||
? fcsButton(context, "Create", callack: () {})
|
? fcsButton(context, "Create", callack: () {})
|
||||||
: fcsButton(context, "Save", callack: () {}),
|
: fcsButton(context, "Save", callack: () {}),
|
||||||
SizedBox(height: 10)
|
SizedBox(height: 10)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:fcs/domain/entities/custom.dart';
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
@@ -9,7 +9,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
class CustomEditor extends StatefulWidget {
|
class CustomEditor extends StatefulWidget {
|
||||||
final Custom custom;
|
final CustomDuty custom;
|
||||||
CustomEditor({this.custom});
|
CustomEditor({this.custom});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -21,7 +21,7 @@ class _CustomEditorState extends State<CustomEditor> {
|
|||||||
TextEditingController _feeController = new TextEditingController();
|
TextEditingController _feeController = new TextEditingController();
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
Custom _custom = new Custom();
|
CustomDuty _custom = new CustomDuty();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:fcs/domain/entities/custom.dart';
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
|
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
|
||||||
@@ -60,17 +60,18 @@ class _CustomListState extends State<CustomList> {
|
|||||||
separatorBuilder: (c, i) => Divider(
|
separatorBuilder: (c, i) => Divider(
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
itemCount: shipmentRateModel.customs.length,
|
itemCount: shipmentRateModel.rate.customDuties.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return _row(context, shipmentRateModel.customs[index]);
|
return _row(
|
||||||
|
context, shipmentRateModel.rate.customDuties[index]);
|
||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_row(BuildContext context, Custom custom) {
|
_row(BuildContext context, CustomDuty custom) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => Navigator.pop<Custom>(context, custom),
|
onTap: () => Navigator.pop<CustomDuty>(context, custom),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:fcs/domain/entities/custom.dart';
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
@@ -6,13 +6,12 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
|
|
||||||
typedef SelectionCallback(Custom custom);
|
typedef SelectionCallback(CustomDuty custom);
|
||||||
|
|
||||||
class CustomRow extends StatelessWidget {
|
class CustomRow extends StatelessWidget {
|
||||||
final Custom custom;
|
final CustomDuty custom;
|
||||||
final SelectionCallback selectionCallback;
|
final SelectionCallback selectionCallback;
|
||||||
const CustomRow(
|
const CustomRow({Key key, this.custom, this.selectionCallback})
|
||||||
{Key key, this.custom, this.selectionCallback})
|
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -33,7 +32,6 @@ class CustomRow extends StatelessWidget {
|
|||||||
fontSize: 16),
|
fontSize: 16),
|
||||||
line(context, custom.fee.toString(),
|
line(context, custom.fee.toString(),
|
||||||
iconData: Icons.phone, color: primaryColor, fontSize: 16),
|
iconData: Icons.phone, color: primaryColor, fontSize: 16),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:fcs/data/services/services.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/domain/entities/rate.dart';
|
||||||
import 'package:fcs/pages/main/model/base_model.dart';
|
import 'package:fcs/pages/main/model/base_model.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
@@ -10,38 +8,20 @@ import 'package:logging/logging.dart';
|
|||||||
class ShipmentRateModel extends BaseModel {
|
class ShipmentRateModel extends BaseModel {
|
||||||
final log = Logger('ShipmentRateModel');
|
final log = Logger('ShipmentRateModel');
|
||||||
|
|
||||||
StreamSubscription<QuerySnapshot> listener;
|
StreamSubscription<Rate> listener;
|
||||||
|
Rate rate;
|
||||||
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) {
|
void initUser(user) {
|
||||||
super.initUser(user);
|
super.initUser(user);
|
||||||
|
if (listener != null) listener.cancel();
|
||||||
|
listener = Services.instance.rateService.getRateStream().listen((rate) {
|
||||||
|
this.rate = rate;
|
||||||
|
notifyListeners();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
logout() async {
|
logout() async {
|
||||||
if (listener != null) await listener.cancel();
|
if (listener != null) await listener.cancel();
|
||||||
rates = [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import 'package:fcs/domain/entities/custom.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
import 'package:fcs/domain/entities/discount_rate.dart';
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
|
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||||
import 'package:fcs/domain/entities/rate.dart';
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_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/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
@@ -38,6 +40,8 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var shipmentRateModel = Provider.of<ShipmentRateModel>(context);
|
var shipmentRateModel = Provider.of<ShipmentRateModel>(context);
|
||||||
|
Rate rate = shipmentRateModel.rate;
|
||||||
|
bool isEditable = context.select((MainModel m) => m.rateEditable());
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
@@ -45,22 +49,38 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: Colors.white,
|
||||||
title: LocalText(
|
shadowColor: Colors.transparent,
|
||||||
context,
|
title: LocalText(context, 'rate.title',
|
||||||
"rate.title",
|
color: primaryColor, fontSize: 20),
|
||||||
color: Colors.white,
|
actions: isEditable
|
||||||
fontSize: 18,
|
? [
|
||||||
),
|
IconButton(
|
||||||
|
onPressed: () => Navigator.of(context).push(
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => ShipmentRatesEdit())),
|
||||||
|
icon: Icon(
|
||||||
|
CupertinoIcons.pen,
|
||||||
|
color: primaryColor,
|
||||||
|
))
|
||||||
|
]
|
||||||
|
: [],
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
fcsButton(context, "Calculate shipping cost", callack: () {
|
||||||
|
Navigator.of(context).push(CupertinoPageRoute(
|
||||||
|
builder: (context) => ShipmentRatesCal()));
|
||||||
|
}),
|
||||||
|
Divider(
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(left: 25, top: 10),
|
padding: EdgeInsets.only(left: 25, top: 10),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -71,30 +91,8 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
fontSize: 15),
|
fontSize: 15),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Column(
|
||||||
height: 135,
|
children: getCargoWidget(shipmentRateModel.rate.cargoTypes),
|
||||||
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(
|
Divider(
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
@@ -109,33 +107,35 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
fontSize: 15),
|
fontSize: 15),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Column(
|
||||||
height: 100,
|
children:
|
||||||
child: Column(
|
getDiscountWidget(shipmentRateModel.rate.discountByWeights),
|
||||||
children:
|
|
||||||
getDiscountWidget(shipmentRateModel.discountsByWeight),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Divider(
|
Divider(
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
_row("Free delivery within Yangon \nfor shipments over", "10",
|
_row("Free delivery within Yangon \nfor shipments over",
|
||||||
"pounds"),
|
"${rate.freeDeliveryWeight}", "pounds"),
|
||||||
_row("Delivery fees", "\$ 5", "below 10 pounds"),
|
_row("Delivery fees", "\$ ${rate.deliveryFee}",
|
||||||
_row("Volumetric Ratio", "166.36", "in3 per pound"),
|
"below ${rate.freeDeliveryWeight} pounds"),
|
||||||
// fcsButton(context, "Terms & Conditions", callack: () {
|
_row("Volumetric Ratio", "${rate.volumetricRatio}",
|
||||||
// Navigator.of(context)
|
"in3 per pound"),
|
||||||
// .push(MaterialPageRoute(builder: (_) => Term()));
|
Divider(
|
||||||
// }),
|
color: Colors.grey,
|
||||||
fcsButton(context, "Estimate shipping cost", callack: () {
|
),
|
||||||
Navigator.of(context).push(CupertinoPageRoute(
|
Container(
|
||||||
builder: (context) => ShipmentRatesCal()));
|
padding: EdgeInsets.only(left: 25, top: 10),
|
||||||
}),
|
child: Text(
|
||||||
fcsButton(context, "Edit", callack: () {
|
"Custom Duties",
|
||||||
Navigator.of(context).push(CupertinoPageRoute(
|
style: TextStyle(
|
||||||
builder: (context) => ShipmentRatesEdit()));
|
color: primaryColor,
|
||||||
}),
|
fontWeight: FontWeight.bold,
|
||||||
SizedBox(height: 10)
|
fontSize: 15),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: getCustonWidget(shipmentRateModel.rate.customDuties),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -143,16 +143,15 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getCargoWidget(List<Rate> rates) {
|
List<Widget> getCargoWidget(List<CargoType> cargos) {
|
||||||
return rates.map((cargo) {
|
return cargos.map((cargo) {
|
||||||
return Container(
|
return Container(
|
||||||
child: _row(
|
child: _row(cargo.name, "\$ " + cargo.rate.toString(), 'per pound'),
|
||||||
cargo.description, "\$ " + cargo.price.toString(), 'per pound'),
|
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getCustonWidget(List<Custom> customs) {
|
List<Widget> getCustonWidget(List<CustomDuty> customs) {
|
||||||
return customs.map((c) {
|
return customs.map((c) {
|
||||||
return Container(
|
return Container(
|
||||||
child: _row(c.productType, "\$ " + c.fee.toString(), ''),
|
child: _row(c.productType, "\$ " + c.fee.toString(), ''),
|
||||||
@@ -160,11 +159,12 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getDiscountWidget(List<DiscountRate> discounts) {
|
List<Widget> getDiscountWidget(List<DiscountByWeight> discounts) {
|
||||||
|
if (discounts == null) return [];
|
||||||
return discounts.map((d) {
|
return discounts.map((d) {
|
||||||
return Container(
|
return Container(
|
||||||
child: _row(
|
child: _row(
|
||||||
"${d.weight.toString()} lb", "\$ " + d.discountRate.toString(), ''),
|
"${d.weight.toString()} lb", "\$ " + d.discount.toString(), ''),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@@ -38,11 +39,13 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: Colors.white,
|
||||||
title: Text(AppTranslations.of(context).text("rate.cal.title")),
|
shadowColor: Colors.transparent,
|
||||||
|
title: LocalText(context, 'rate.cal.title',
|
||||||
|
color: primaryColor, fontSize: 20),
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
@@ -60,12 +63,11 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
|||||||
child: DropdownButtonFormField(
|
child: DropdownButtonFormField(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
hintText: shipmentRateModel.rates[0].description,
|
hintText: shipmentRateModel.rate.cargoTypes[0].name,
|
||||||
hintStyle: TextStyle(color: Colors.black87)),
|
hintStyle: TextStyle(color: Colors.black87)),
|
||||||
items: shipmentRateModel.rates
|
items: shipmentRateModel.rate.cargoTypes
|
||||||
.map((e) => DropdownMenuItem(
|
.map((e) => DropdownMenuItem(
|
||||||
child: Text(e.description),
|
child: Text(e.name), value: e.name))
|
||||||
value: e.description))
|
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (selected) => {
|
onChanged: (selected) => {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:fcs/domain/entities/custom.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
import 'package:fcs/domain/entities/discount.dart';
|
import 'package:fcs/domain/entities/discount.dart';
|
||||||
import 'package:fcs/domain/entities/discount_rate.dart';
|
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||||
import 'package:fcs/domain/entities/rate.dart';
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
@@ -118,7 +119,8 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
color: Colors.grey[600]))),
|
color: Colors.grey[600]))),
|
||||||
],
|
],
|
||||||
rows: getCargoRows(shipmentRateModel.rates),
|
rows: getCargoRows(
|
||||||
|
shipmentRateModel.rate.cargoTypes),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -182,7 +184,8 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
color: Colors.grey[600]))),
|
color: Colors.grey[600]))),
|
||||||
],
|
],
|
||||||
rows: getCustomsRows(shipmentRateModel.customs),
|
rows: getCustomsRows(
|
||||||
|
shipmentRateModel.rate.customDuties),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -247,7 +250,7 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
color: Colors.grey[600]))),
|
color: Colors.grey[600]))),
|
||||||
],
|
],
|
||||||
rows: getDiscounts(
|
rows: getDiscounts(
|
||||||
shipmentRateModel.discountsByWeight),
|
shipmentRateModel.rate.discountByWeights),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -296,25 +299,25 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MyDataRow> getCargoRows(List<Rate> rates) {
|
List<MyDataRow> getCargoRows(List<CargoType> cargos) {
|
||||||
return rates.map((r) {
|
return cargos.map((r) {
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (selected) {
|
onSelectChanged: (selected) {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (context) => CargoEditor(rate: r)),
|
CupertinoPageRoute(builder: (context) => CargoEditor(cargo: r)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(
|
MyDataCell(
|
||||||
new Text(
|
new Text(
|
||||||
r.description,
|
r.name,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
MyDataCell(
|
MyDataCell(
|
||||||
new Text(
|
new Text(
|
||||||
r.price.toString(),
|
r.rate.toString(),
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -324,7 +327,7 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MyDataRow> getCustomsRows(List<Custom> customs) {
|
List<MyDataRow> getCustomsRows(List<CustomDuty> customs) {
|
||||||
return customs.map((c) {
|
return customs.map((c) {
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (selected) {
|
onSelectChanged: (selected) {
|
||||||
@@ -352,7 +355,7 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MyDataRow> getDiscounts(List<DiscountRate> discounts) {
|
List<MyDataRow> getDiscounts(List<DiscountByWeight> discounts) {
|
||||||
return discounts.map((d) {
|
return discounts.map((d) {
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (selected) {
|
onSelectChanged: (selected) {
|
||||||
@@ -371,7 +374,7 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
MyDataCell(
|
MyDataCell(
|
||||||
Center(
|
Center(
|
||||||
child: new Text(
|
child: new Text(
|
||||||
d.discountRate.toString(),
|
d.discount.toString(),
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:fcs/domain/constants.dart';
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/cargo.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
import 'package:fcs/domain/entities/pickup.dart';
|
import 'package:fcs/domain/entities/shipment.dart';
|
||||||
import 'package:fcs/domain/vo/radio.dart';
|
import 'package:fcs/domain/vo/radio.dart';
|
||||||
import 'package:fcs/pages/main/model/base_model.dart';
|
import 'package:fcs/pages/main/model/base_model.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
@@ -78,9 +78,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
isCourier: true,
|
isCourier: true,
|
||||||
radioIndex: 2,
|
radioIndex: 2,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200125 - 12 May 2020",
|
id: "S200125 - 12 May 2020",
|
||||||
@@ -95,9 +95,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200441 - 13 Apr 2020",
|
id: "S200441 - 13 Apr 2020",
|
||||||
@@ -113,9 +113,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
radioIndex: 3,
|
radioIndex: 3,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200412 - 12 Apr 2020",
|
id: "S200412 - 12 Apr 2020",
|
||||||
@@ -130,9 +130,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200125 - 12 May 2020",
|
id: "S200125 - 12 May 2020",
|
||||||
@@ -147,9 +147,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200441 - 13 Apr 2020",
|
id: "S200441 - 13 Apr 2020",
|
||||||
@@ -164,9 +164,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200441 - 10 Apr 2020",
|
id: "S200441 - 10 Apr 2020",
|
||||||
@@ -181,9 +181,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200441 - 6 Apr 2020",
|
id: "S200441 - 6 Apr 2020",
|
||||||
@@ -198,9 +198,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
return pickups;
|
return pickups;
|
||||||
@@ -222,9 +222,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
isCourier: true,
|
isCourier: true,
|
||||||
radioIndex: 2,
|
radioIndex: 2,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200125 - 12 May 2020",
|
id: "S200125 - 12 May 2020",
|
||||||
@@ -239,9 +239,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200441 - 13 Apr 2020",
|
id: "S200441 - 13 Apr 2020",
|
||||||
@@ -257,9 +257,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
radioIndex: 3,
|
radioIndex: 3,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200412 - 12 Apr 2020",
|
id: "S200412 - 12 Apr 2020",
|
||||||
@@ -274,9 +274,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200125 - 12 May 2020",
|
id: "S200125 - 12 May 2020",
|
||||||
@@ -291,9 +291,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200441 - 13 Apr 2020",
|
id: "S200441 - 13 Apr 2020",
|
||||||
@@ -308,9 +308,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200441 - 10 Apr 2020",
|
id: "S200441 - 10 Apr 2020",
|
||||||
@@ -325,9 +325,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
Shipment(
|
Shipment(
|
||||||
id: "S200441 - 6 Apr 2020",
|
id: "S200441 - 6 Apr 2020",
|
||||||
@@ -342,9 +342,9 @@ class ShipmentModel extends BaseModel {
|
|||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
||||||
handlingFee: 50,
|
handlingFee: 50,
|
||||||
cargoTypes: [
|
cargoTypes: [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import 'package:fcs/domain/entities/box.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/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/box/cargo_type_editor.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/delivery_address/model/delivery_address_model.dart';
|
||||||
import 'package:fcs/pages/main/model/main_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/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
||||||
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
||||||
@@ -39,14 +40,15 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
DeliveryAddress _deliveryAddress;
|
DeliveryAddress _deliveryAddress;
|
||||||
double volumetricRatio = 0;
|
double volumetricRatio = 0;
|
||||||
double shipmentWeight = 0;
|
double shipmentWeight = 0;
|
||||||
List<Cargo> cargos = [];
|
List<CargoType> cargos = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
volumetricRatio =
|
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||||
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
|
.rate
|
||||||
|
.volumetricRatio;
|
||||||
|
|
||||||
if (widget.box != null) {
|
if (widget.box != null) {
|
||||||
_box = widget.box;
|
_box = widget.box;
|
||||||
@@ -145,7 +147,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Cargo cargo = await Navigator.push<Cargo>(
|
CargoType cargo = await Navigator.push<CargoType>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => CargoTypeEditor()));
|
builder: (context) => CargoTypeEditor()));
|
||||||
@@ -212,7 +214,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
total += c.weight;
|
total += c.weight;
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (bool selected) async {
|
onSelectChanged: (bool selected) async {
|
||||||
Cargo cargo = await Navigator.push<Cargo>(
|
CargoType cargo = await Navigator.push<CargoType>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => CargoTypeEditor(
|
builder: (context) => CargoTypeEditor(
|
||||||
@@ -222,7 +224,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
},
|
},
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(new Text(
|
MyDataCell(new Text(
|
||||||
c.type == null ? "" : c.type,
|
c.name == null ? "" : c.name,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
)),
|
||||||
MyDataCell(
|
MyDataCell(
|
||||||
@@ -270,7 +272,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
_addCargo(Cargo cargo) {
|
_addCargo(CargoType cargo) {
|
||||||
if (cargo == null) return;
|
if (cargo == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
cargos.remove(cargo);
|
cargos.remove(cargo);
|
||||||
@@ -278,7 +280,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_removeCargo(Cargo cargo) {
|
_removeCargo(CargoType cargo) {
|
||||||
setState(() {
|
setState(() {
|
||||||
cargos.remove(cargo);
|
cargos.remove(cargo);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:fcs/domain/constants.dart';
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/box.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/pickup.dart';
|
import 'package:fcs/domain/entities/shipment.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/box/model/box_model.dart';
|
import 'package:fcs/pages/box/model/box_model.dart';
|
||||||
@@ -93,10 +93,10 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
_pickupDate.text = dateFormatter.format(now);
|
_pickupDate.text = dateFormatter.format(now);
|
||||||
_fromTimeEditingController.text = "${(now.hour)}:${(now.minute)}";
|
_fromTimeEditingController.text = "${(now.hour)}:${(now.minute)}";
|
||||||
_toTimeEditingController.text = "${(now.hour)}:${(now.minute)}";
|
_toTimeEditingController.text = "${(now.hour)}:${(now.minute)}";
|
||||||
List<Cargo> _cargoTypes = [
|
List<CargoType> _cargoTypes = [
|
||||||
Cargo(type: 'General Cargo', weight: 25),
|
CargoType(name: 'General Cargo', weight: 25),
|
||||||
Cargo(type: 'Medicine', weight: 20),
|
CargoType(name: 'Medicine', weight: 20),
|
||||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||||
];
|
];
|
||||||
_pickUp = Shipment(cargoTypes: _cargoTypes);
|
_pickUp = Shipment(cargoTypes: _cargoTypes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -41,8 +41,8 @@ class _ShipmentListRowState extends State<ShipmentListRow> {
|
|||||||
padding: EdgeInsets.only(left: 15, right: 15),
|
padding: EdgeInsets.only(left: 15, right: 15),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context)
|
Navigator.of(context).push(CupertinoPageRoute(
|
||||||
.push(CupertinoPageRoute(builder: (context) => ShipmentEditor(shipment: _pickUp)));
|
builder: (context) => ShipmentEditor(shipment: _pickUp)));
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|||||||
@@ -23,16 +23,13 @@ class DeliveryAddressSelection extends StatelessWidget {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
),
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
title: LocalText(
|
|
||||||
context,
|
|
||||||
"delivery_addresses",
|
|
||||||
fontSize: 20,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
),
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
title: LocalText(context, 'delivery_addresses',
|
||||||
|
color: primaryColor, fontSize: 20),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton.extended(
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
Reference in New Issue
Block a user