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