add paginator
This commit is contained in:
@@ -338,6 +338,7 @@
|
|||||||
"shipment.popupmenu.delivered":"Delivered Shipments",
|
"shipment.popupmenu.delivered":"Delivered Shipments",
|
||||||
"shipment.create":"Create shipment",
|
"shipment.create":"Create shipment",
|
||||||
"shipment.update":"Update shipment",
|
"shipment.update":"Update shipment",
|
||||||
|
"shipment.info":"Shipment Info",
|
||||||
"Shipment End ================================================================":"",
|
"Shipment End ================================================================":"",
|
||||||
|
|
||||||
"Rate Start ================================================================":"",
|
"Rate Start ================================================================":"",
|
||||||
|
|||||||
@@ -338,6 +338,7 @@
|
|||||||
"shipment.popupmenu.delivered":"ပို့ပြီးသော အထုပ်များ",
|
"shipment.popupmenu.delivered":"ပို့ပြီးသော အထုပ်များ",
|
||||||
"shipment.create":"ပို့ဆောင်ခြင်း ပြုလုပ်မည်",
|
"shipment.create":"ပို့ဆောင်ခြင်း ပြုလုပ်မည်",
|
||||||
"shipment.update":"ပို့ဆောင်ခြင်းပြုပြင်မည်",
|
"shipment.update":"ပို့ဆောင်ခြင်းပြုပြင်မည်",
|
||||||
|
"shipment.info":"ပို့ဆောင်ခြင်း",
|
||||||
"Shipment End ================================================================":"",
|
"Shipment End ================================================================":"",
|
||||||
|
|
||||||
"Rate Start ================================================================":"",
|
"Rate Start ================================================================":"",
|
||||||
|
|||||||
43
lib/data/provider/shipment_data_provider.dart
Normal file
43
lib/data/provider/shipment_data_provider.dart
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:fcs/domain/entities/shipment.dart';
|
||||||
|
import 'package:fcs/helpers/api_helper.dart';
|
||||||
|
import 'package:fcs/helpers/firebase_helper.dart';
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
|
class ShipmentDataProvider {
|
||||||
|
final log = Logger('ShipmentDataProvider');
|
||||||
|
|
||||||
|
static final ShipmentDataProvider instance = ShipmentDataProvider._();
|
||||||
|
ShipmentDataProvider._();
|
||||||
|
|
||||||
|
Future<void> createShipment(Shipment shipment) async {
|
||||||
|
return await requestAPI("/shipments", "POST",
|
||||||
|
payload: shipment.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateShipment(Shipment shipment) async {
|
||||||
|
return await requestAPI("/shipments", "PUT",
|
||||||
|
payload: shipment.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> cancelShipment(Shipment shipment) async {
|
||||||
|
return await requestAPI("/shipment_cancel", "PUT",
|
||||||
|
payload: shipment.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> confirmShipment(Shipment shipment) async {
|
||||||
|
return await requestAPI("/shipment_confirm", "PUT",
|
||||||
|
payload: shipment.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> pickupShipment(Shipment shipment) async {
|
||||||
|
return await requestAPI("/shipment_pickup", "PUT",
|
||||||
|
payload: shipment.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> receiveShipment(Shipment shipment) async {
|
||||||
|
return await requestAPI("/shipment_receive", "PUT",
|
||||||
|
payload: shipment.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import 'package:fcs/data/provider/delivery_address_data_provider.dart';
|
|||||||
import 'package:fcs/data/provider/fcs_shipment_data_provider.dart';
|
import 'package:fcs/data/provider/fcs_shipment_data_provider.dart';
|
||||||
import 'package:fcs/data/provider/package_data_provider.dart';
|
import 'package:fcs/data/provider/package_data_provider.dart';
|
||||||
import 'package:fcs/data/provider/rate_data_provider.dart';
|
import 'package:fcs/data/provider/rate_data_provider.dart';
|
||||||
|
import 'package:fcs/data/provider/shipment_data_provider.dart';
|
||||||
import 'package:fcs/data/provider/user_data_provider.dart';
|
import 'package:fcs/data/provider/user_data_provider.dart';
|
||||||
import 'package:fcs/data/services/delivery_address_imp.dart';
|
import 'package:fcs/data/services/delivery_address_imp.dart';
|
||||||
import 'package:fcs/data/services/delivery_address_service.dart';
|
import 'package:fcs/data/services/delivery_address_service.dart';
|
||||||
@@ -11,6 +12,8 @@ import 'package:fcs/data/services/fcs_shipment_imp.dart';
|
|||||||
import 'package:fcs/data/services/fcs_shipment_service.dart';
|
import 'package:fcs/data/services/fcs_shipment_service.dart';
|
||||||
import 'package:fcs/data/services/rate_imp.dart';
|
import 'package:fcs/data/services/rate_imp.dart';
|
||||||
import 'package:fcs/data/services/rate_service.dart';
|
import 'package:fcs/data/services/rate_service.dart';
|
||||||
|
import 'package:fcs/data/services/shipment_imp.dart';
|
||||||
|
import 'package:fcs/data/services/shipment_service.dart';
|
||||||
|
|
||||||
import 'auth_imp.dart';
|
import 'auth_imp.dart';
|
||||||
import 'auth_service.dart';
|
import 'auth_service.dart';
|
||||||
@@ -34,6 +37,7 @@ class Services {
|
|||||||
FcsShipmentService _fcsShipmentService;
|
FcsShipmentService _fcsShipmentService;
|
||||||
DeliveryAddressService _deliveryAddressService;
|
DeliveryAddressService _deliveryAddressService;
|
||||||
RateService _rateService;
|
RateService _rateService;
|
||||||
|
ShipmentService _shipmentService;
|
||||||
Services._() {
|
Services._() {
|
||||||
_authService = AuthServiceImp(
|
_authService = AuthServiceImp(
|
||||||
authFb: AuthFb.instance,
|
authFb: AuthFb.instance,
|
||||||
@@ -52,6 +56,9 @@ class Services {
|
|||||||
deliveryAddressDataProvider: DeliveryAddressDataProvider());
|
deliveryAddressDataProvider: DeliveryAddressDataProvider());
|
||||||
_rateService = RateServiceImp(
|
_rateService = RateServiceImp(
|
||||||
rateDataProvider: RateDataProvider.instance, connectivity: null);
|
rateDataProvider: RateDataProvider.instance, connectivity: null);
|
||||||
|
_shipmentService = ShipmentServiceImp(
|
||||||
|
shipmentDataProvider: ShipmentDataProvider.instance,
|
||||||
|
connectivity: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthService get authService => _authService;
|
AuthService get authService => _authService;
|
||||||
@@ -62,4 +69,5 @@ class Services {
|
|||||||
FcsShipmentService get fcsShipmentService => _fcsShipmentService;
|
FcsShipmentService get fcsShipmentService => _fcsShipmentService;
|
||||||
DeliveryAddressService get deliveryAddressService => _deliveryAddressService;
|
DeliveryAddressService get deliveryAddressService => _deliveryAddressService;
|
||||||
RateService get rateService => _rateService;
|
RateService get rateService => _rateService;
|
||||||
|
ShipmentService get shipmentService => _shipmentService;
|
||||||
}
|
}
|
||||||
|
|||||||
52
lib/data/services/shipment_imp.dart
Normal file
52
lib/data/services/shipment_imp.dart
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import 'package:fcs/data/provider/rate_data_provider.dart';
|
||||||
|
import 'package:fcs/data/provider/shipment_data_provider.dart';
|
||||||
|
import 'package:fcs/data/services/shipment_service.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:fcs/domain/entities/shipment.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'rate_service.dart';
|
||||||
|
|
||||||
|
class ShipmentServiceImp implements ShipmentService {
|
||||||
|
ShipmentServiceImp({
|
||||||
|
@required this.shipmentDataProvider,
|
||||||
|
@required this.connectivity,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Connectivity connectivity;
|
||||||
|
final ShipmentDataProvider shipmentDataProvider;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> cancelShipment(Shipment shipment) {
|
||||||
|
return shipmentDataProvider.cancelShipment(shipment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> confirmShipment(Shipment shipment) {
|
||||||
|
return shipmentDataProvider.confirmShipment(shipment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> createShipment(Shipment shipment) {
|
||||||
|
return shipmentDataProvider.createShipment(shipment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> pickupShipment(Shipment shipment) {
|
||||||
|
return shipmentDataProvider.pickupShipment(shipment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> receiveShipment(Shipment shipment) {
|
||||||
|
return shipmentDataProvider.receiveShipment(shipment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateShipment(Shipment shipment) {
|
||||||
|
return shipmentDataProvider.updateShipment(shipment);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +1,10 @@
|
|||||||
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/shipment.dart';
|
||||||
import 'package:fcs/domain/entities/rate.dart';
|
|
||||||
|
|
||||||
abstract class RateService {
|
|
||||||
Stream<Rate> getRateStream();
|
|
||||||
|
|
||||||
|
abstract class ShipmentService {
|
||||||
Future<void> createShipment(Shipment shipment);
|
Future<void> createShipment(Shipment shipment);
|
||||||
|
Future<void> updateShipment(Shipment shipment);
|
||||||
Future<void> createCargoType(CargoType cargoType);
|
Future<void> cancelShipment(Shipment shipment);
|
||||||
Future<void> updateCargoType(CargoType cargoType);
|
Future<void> confirmShipment(Shipment shipment);
|
||||||
Future<void> deleteCargoType(String id);
|
Future<void> pickupShipment(Shipment shipment);
|
||||||
|
Future<void> receiveShipment(Shipment shipment);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const delivery_address_collection = "delivery_addresses";
|
|||||||
const cargo_types_collection = "cargo_types";
|
const cargo_types_collection = "cargo_types";
|
||||||
const custom_duties_collection = "custom_duties";
|
const custom_duties_collection = "custom_duties";
|
||||||
const discounts_by_weights_collection = "discounts_by_weight";
|
const discounts_by_weights_collection = "discounts_by_weight";
|
||||||
|
const shipments_collection = "shipments";
|
||||||
|
|
||||||
// docs
|
// docs
|
||||||
const setting_doc_id = "setting";
|
const setting_doc_id = "setting";
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||||
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
import 'package:fcs/domain/vo/shipment_status.dart';
|
import 'package:fcs/domain/vo/shipment_status.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
|
|
||||||
@@ -17,9 +19,9 @@ class Box {
|
|||||||
String status;
|
String status;
|
||||||
String cargoDesc;
|
String cargoDesc;
|
||||||
String desc;
|
String desc;
|
||||||
int width;
|
double width;
|
||||||
int height;
|
double height;
|
||||||
int length;
|
double length;
|
||||||
int shipmentWeight;
|
int shipmentWeight;
|
||||||
bool isChecked;
|
bool isChecked;
|
||||||
String cartonType;
|
String cartonType;
|
||||||
@@ -38,7 +40,7 @@ class Box {
|
|||||||
|
|
||||||
List<CargoType> cargoTypes;
|
List<CargoType> cargoTypes;
|
||||||
|
|
||||||
DeliveryAddress shippingAddress;
|
DeliveryAddress deliveryAddress;
|
||||||
|
|
||||||
int get amount => rate != null && weight != null ? rate * weight : 0;
|
int get amount => rate != null && weight != null ? rate * weight : 0;
|
||||||
|
|
||||||
@@ -46,6 +48,9 @@ class Box {
|
|||||||
shipmentNumber + "-" + receiverNumber + " #" + boxNumber;
|
shipmentNumber + "-" + receiverNumber + " #" + boxNumber;
|
||||||
double get price => rate.toDouble() * weight;
|
double get price => rate.toDouble() * weight;
|
||||||
|
|
||||||
|
double get actualWeight =>
|
||||||
|
cargoTypes == null ? 0 : cargoTypes.fold(0, (p, e) => e.weight + p);
|
||||||
|
|
||||||
double getShipmentWeight(double volumetricRatio) {
|
double getShipmentWeight(double volumetricRatio) {
|
||||||
if (length == null ||
|
if (length == null ||
|
||||||
length <= 0 ||
|
length <= 0 ||
|
||||||
@@ -59,6 +64,30 @@ class Box {
|
|||||||
return (length * width * height) / volumetricRatio;
|
return (length * width * height) / volumetricRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// calAmount returns total amount
|
||||||
|
double calAmount(Rate rate) {
|
||||||
|
// get shipment weight
|
||||||
|
double volume = (length ?? 0) * (width ?? 0) * (height ?? 0);
|
||||||
|
double sw = volume / rate.volumetricRatio ?? 0;
|
||||||
|
|
||||||
|
// get actual weight
|
||||||
|
double aw = cargoTypes.fold(0.0, (p, c) => p + c.weight);
|
||||||
|
if (aw == 0 || sw == 0) return 0;
|
||||||
|
|
||||||
|
DiscountByWeight discountByWeight =
|
||||||
|
rate.getDiscountByWeight(sw > aw ? sw : aw);
|
||||||
|
|
||||||
|
double total = 0;
|
||||||
|
cargoTypes.forEach((e) {
|
||||||
|
double cargoWeight = aw > sw ? e.weight : e.weight / aw * sw;
|
||||||
|
double r =
|
||||||
|
e.rate - (discountByWeight != null ? discountByWeight.discount : 0);
|
||||||
|
double amount = cargoWeight * r;
|
||||||
|
total += amount;
|
||||||
|
});
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
List<ShipmentStatus> shipmentHistory;
|
List<ShipmentStatus> shipmentHistory;
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
@@ -91,5 +120,17 @@ class Box {
|
|||||||
this.shipmentHistory,
|
this.shipmentHistory,
|
||||||
this.packages,
|
this.packages,
|
||||||
this.cargoTypes,
|
this.cargoTypes,
|
||||||
this.shippingAddress});
|
this.deliveryAddress});
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
List _cargoTypes = cargoTypes.map((c) => c.toMap()).toList();
|
||||||
|
return {
|
||||||
|
"id": id,
|
||||||
|
'cargo_types': _cargoTypes,
|
||||||
|
'length': length,
|
||||||
|
'width': width,
|
||||||
|
'height': height,
|
||||||
|
'delivery_address': deliveryAddress.toMap(),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ class CargoType {
|
|||||||
String id;
|
String id;
|
||||||
String name;
|
String name;
|
||||||
double rate;
|
double rate;
|
||||||
|
double weight;
|
||||||
|
|
||||||
|
int shipmentWeight;
|
||||||
|
double amount;
|
||||||
|
|
||||||
factory CargoType.fromMap(Map<String, dynamic> map, String id) {
|
factory CargoType.fromMap(Map<String, dynamic> map, String id) {
|
||||||
return CargoType(
|
return CargoType(
|
||||||
@@ -10,7 +14,6 @@ class CargoType {
|
|||||||
rate: (map['rate'] ?? 0).toDouble(),
|
rate: (map['rate'] ?? 0).toDouble(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
int weight;
|
|
||||||
CargoType({this.id, this.name, this.rate, this.weight});
|
CargoType({this.id, this.name, this.rate, this.weight});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
@@ -18,6 +21,7 @@ class CargoType {
|
|||||||
"id": id,
|
"id": id,
|
||||||
'name': name,
|
'name': name,
|
||||||
'rate': rate,
|
'rate': rate,
|
||||||
|
'weight': weight,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,4 +30,9 @@ class CargoType {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => id.hashCode;
|
int get hashCode => id.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ class Rate {
|
|||||||
List<CustomDuty> customDuties;
|
List<CustomDuty> customDuties;
|
||||||
List<DiscountByWeight> discountByWeights;
|
List<DiscountByWeight> discountByWeights;
|
||||||
|
|
||||||
|
DiscountByWeight getDiscountByWeight(double weight) {
|
||||||
|
discountByWeights.sort((d1, d2) => d2.weight.compareTo(d1.weight));
|
||||||
|
return discountByWeights.firstWhere((e) => e.weight < weight,
|
||||||
|
orElse: () => null);
|
||||||
|
}
|
||||||
|
|
||||||
CargoType get defaultCargoType => cargoTypes == null
|
CargoType get defaultCargoType => cargoTypes == null
|
||||||
? null
|
? null
|
||||||
: cargoTypes.firstWhere((e) => e.name == "General");
|
: cargoTypes.firstWhere((e) => e.name == "General");
|
||||||
|
|||||||
@@ -1,54 +1,77 @@
|
|||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:fcs/domain/entities/box.dart';
|
||||||
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
|
|
||||||
import 'cargo_type.dart';
|
import 'cargo_type.dart';
|
||||||
|
|
||||||
class Shipment {
|
class Shipment {
|
||||||
String id;
|
String id;
|
||||||
|
String shipmentNumber;
|
||||||
|
String shipmentType;
|
||||||
|
DeliveryAddress pickupAddress;
|
||||||
|
DateTime pickupDate;
|
||||||
|
String pickupTimeStart;
|
||||||
|
String pickupTimeEnd;
|
||||||
|
|
||||||
String userName;
|
String userName;
|
||||||
String phoneNumber;
|
String phoneNumber;
|
||||||
String fromTime;
|
|
||||||
String toTime;
|
|
||||||
int numberOfPackage;
|
int numberOfPackage;
|
||||||
int weight;
|
int weight;
|
||||||
int handlingFee;
|
int handlingFee;
|
||||||
String address;
|
String address;
|
||||||
String status;
|
String currentStatus;
|
||||||
DateTime date;
|
|
||||||
List<CargoType> cargoTypes;
|
|
||||||
bool isCourier;
|
bool isCourier;
|
||||||
int radioIndex;
|
int radioIndex;
|
||||||
|
List<Box> boxes;
|
||||||
|
|
||||||
Shipment(
|
Shipment(
|
||||||
{this.id,
|
{this.id,
|
||||||
|
this.shipmentNumber,
|
||||||
|
this.shipmentType,
|
||||||
this.userName,
|
this.userName,
|
||||||
this.phoneNumber,
|
this.phoneNumber,
|
||||||
this.fromTime,
|
this.pickupTimeStart,
|
||||||
this.toTime,
|
this.pickupTimeEnd,
|
||||||
this.numberOfPackage,
|
this.numberOfPackage,
|
||||||
this.weight,
|
this.weight,
|
||||||
this.handlingFee,
|
this.handlingFee,
|
||||||
this.address,
|
this.address,
|
||||||
this.status,
|
this.currentStatus,
|
||||||
this.date,
|
this.pickupDate,
|
||||||
this.cargoTypes,
|
|
||||||
this.isCourier = false,
|
this.isCourier = false,
|
||||||
this.radioIndex = 1});
|
this.radioIndex = 1,
|
||||||
|
this.boxes});
|
||||||
|
|
||||||
int get last => DateTime.now().difference(date).inDays;
|
int get last => DateTime.now().difference(pickupDate).inDays;
|
||||||
|
|
||||||
factory Shipment.fromMap(Map<String, dynamic> map, String id) {
|
factory Shipment.fromMap(Map<String, dynamic> map, String id) {
|
||||||
|
var pd = (map['pickup_date'] as Timestamp);
|
||||||
return Shipment(
|
return Shipment(
|
||||||
id: id,
|
id: id,
|
||||||
userName: map['user_name'],
|
userName: map['user_name'],
|
||||||
|
shipmentNumber: map['shipment_number'],
|
||||||
phoneNumber: map['phone_number'],
|
phoneNumber: map['phone_number'],
|
||||||
fromTime: map['from_time'],
|
pickupDate: pd == null ? null : pd.toDate(),
|
||||||
toTime: map['to_time'],
|
pickupTimeStart: map['pickup_time_start'],
|
||||||
numberOfPackage: map['number_of_package'],
|
pickupTimeEnd: map['pickup_time_end'],
|
||||||
weight: map['weight'],
|
currentStatus: map['current_status']);
|
||||||
address: map['address'],
|
}
|
||||||
status: map['status']);
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
List _boxes = boxes.map((l) => l.toMap()).toList();
|
||||||
|
return {
|
||||||
|
"id": id,
|
||||||
|
'boxes': _boxes,
|
||||||
|
'shipment_type': shipmentType,
|
||||||
|
'pickup_address': pickupAddress.toMap(),
|
||||||
|
"pickup_date": pickupDate?.toUtc()?.toIso8601String(),
|
||||||
|
'pickup_time_start': pickupTimeStart,
|
||||||
|
'pickup_time_end': pickupTimeEnd,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'PickUp{id:$id, userName:$userName,phoneNumber:$phoneNumber,fromTime:$fromTime,toTime:$toTime,numberOfPackage:$numberOfPackage,weight:$weight,status:$status}';
|
return 'PickUp{id:$id, userName:$userName,phoneNumber:$phoneNumber,numberOfPackage:$numberOfPackage,weight:$weight,currentStatus:$currentStatus}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
|
|
||||||
if (widget.box != null) {
|
if (widget.box != null) {
|
||||||
_box = widget.box;
|
_box = widget.box;
|
||||||
_deliveryAddress = _box.shippingAddress;
|
_deliveryAddress = _box.deliveryAddress;
|
||||||
_cargoTypes = _box.cargoTypes;
|
_cargoTypes = _box.cargoTypes;
|
||||||
_selectShipmentNumber = _box.shipmentNumber;
|
_selectShipmentNumber = _box.shipmentNumber;
|
||||||
_widthController.text = _box.width.toString();
|
_widthController.text = _box.width.toString();
|
||||||
@@ -397,7 +397,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
if (_cargoTypes == null) {
|
if (_cargoTypes == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
int total = 0;
|
double total = 0;
|
||||||
|
|
||||||
var rows = _cargoTypes.asMap().entries.map((c) {
|
var rows = _cargoTypes.asMap().entries.map((c) {
|
||||||
total += c.value.weight;
|
total += c.value.weight;
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class _BoxInfoState extends State<BoxInfo> {
|
|||||||
_lengthController.text = _box.length.toString();
|
_lengthController.text = _box.length.toString();
|
||||||
|
|
||||||
_cargoTypes = _box.cargoTypes;
|
_cargoTypes = _box.cargoTypes;
|
||||||
_deliveryAddress = _box.shippingAddress;
|
_deliveryAddress = _box.deliveryAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
_calShipmentWeight() {
|
_calShipmentWeight() {
|
||||||
@@ -324,7 +324,7 @@ class _BoxInfoState extends State<BoxInfo> {
|
|||||||
if (_cargoTypes == null) {
|
if (_cargoTypes == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
int total = 0;
|
double total = 0;
|
||||||
|
|
||||||
var rows = _cargoTypes.asMap().entries.map((c) {
|
var rows = _cargoTypes.asMap().entries.map((c) {
|
||||||
total += c.value.weight;
|
total += c.value.weight;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
|||||||
context,
|
context,
|
||||||
getLocalString(context, 'box.cargo.save.btn'),
|
getLocalString(context, 'box.cargo.save.btn'),
|
||||||
callack: () {
|
callack: () {
|
||||||
_cargo.weight = int.parse(_weightController.text, onError: (s) => 0);
|
_cargo.weight = double.tryParse(_weightController.text) ?? 0;
|
||||||
Navigator.pop(context, _cargo);
|
Navigator.pop(context, _cargo);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class BoxModel extends BaseModel {
|
|||||||
shipmentWeight: 6,
|
shipmentWeight: 6,
|
||||||
packages: packages,
|
packages: packages,
|
||||||
shipmentHistory: statusHistory,
|
shipmentHistory: statusHistory,
|
||||||
shippingAddress: DeliveryAddress(
|
deliveryAddress: DeliveryAddress(
|
||||||
fullName: 'U Nyi Nyi',
|
fullName: 'U Nyi Nyi',
|
||||||
addressLine1: '154-19 64th Ave.',
|
addressLine1: '154-19 64th Ave.',
|
||||||
addressLine2: 'Flushing',
|
addressLine2: 'Flushing',
|
||||||
@@ -79,7 +79,7 @@ class BoxModel extends BaseModel {
|
|||||||
packages: packages,
|
packages: packages,
|
||||||
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
|
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
|
||||||
cartonType: carton_from_shipments,
|
cartonType: carton_from_shipments,
|
||||||
shippingAddress: DeliveryAddress(
|
deliveryAddress: DeliveryAddress(
|
||||||
fullName: 'Mg Myo',
|
fullName: 'Mg Myo',
|
||||||
addressLine1: '153-154 5th Thitsar.',
|
addressLine1: '153-154 5th Thitsar.',
|
||||||
addressLine2: 'South Okkalapa Township',
|
addressLine2: 'South Okkalapa Township',
|
||||||
@@ -111,7 +111,7 @@ class BoxModel extends BaseModel {
|
|||||||
shipmentHistory: statusHistory,
|
shipmentHistory: statusHistory,
|
||||||
packages: packages,
|
packages: packages,
|
||||||
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
|
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
|
||||||
shippingAddress: DeliveryAddress(
|
deliveryAddress: DeliveryAddress(
|
||||||
fullName: 'Mg Myo',
|
fullName: 'Mg Myo',
|
||||||
addressLine1: '153-154 5th Thitsar.',
|
addressLine1: '153-154 5th Thitsar.',
|
||||||
addressLine2: 'South Okkalapa Township',
|
addressLine2: 'South Okkalapa Township',
|
||||||
@@ -142,7 +142,7 @@ class BoxModel extends BaseModel {
|
|||||||
shipmentHistory: statusHistory,
|
shipmentHistory: statusHistory,
|
||||||
packages: packages,
|
packages: packages,
|
||||||
receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon',
|
receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon',
|
||||||
shippingAddress: DeliveryAddress(
|
deliveryAddress: DeliveryAddress(
|
||||||
fullName: 'U Nyi Nyi',
|
fullName: 'U Nyi Nyi',
|
||||||
addressLine1: '154-19 64th Ave.',
|
addressLine1: '154-19 64th Ave.',
|
||||||
addressLine2: 'Flushing',
|
addressLine2: 'Flushing',
|
||||||
@@ -172,7 +172,7 @@ class BoxModel extends BaseModel {
|
|||||||
shipmentHistory: statusHistory,
|
shipmentHistory: statusHistory,
|
||||||
packages: packages,
|
packages: packages,
|
||||||
receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon',
|
receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon',
|
||||||
shippingAddress: DeliveryAddress(
|
deliveryAddress: DeliveryAddress(
|
||||||
fullName: 'U Nyi Nyi',
|
fullName: 'U Nyi Nyi',
|
||||||
addressLine1: '154-19 64th Ave.',
|
addressLine1: '154-19 64th Ave.',
|
||||||
addressLine2: 'Flushing',
|
addressLine2: 'Flushing',
|
||||||
@@ -202,7 +202,7 @@ class BoxModel extends BaseModel {
|
|||||||
shipmentHistory: statusHistory,
|
shipmentHistory: statusHistory,
|
||||||
packages: packages,
|
packages: packages,
|
||||||
receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon',
|
receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon',
|
||||||
shippingAddress: DeliveryAddress(
|
deliveryAddress: DeliveryAddress(
|
||||||
fullName: 'U Nyi Nyi',
|
fullName: 'U Nyi Nyi',
|
||||||
addressLine1: '154-19 64th Ave.',
|
addressLine1: '154-19 64th Ave.',
|
||||||
addressLine2: 'Flushing',
|
addressLine2: 'Flushing',
|
||||||
@@ -232,7 +232,7 @@ class BoxModel extends BaseModel {
|
|||||||
shipmentHistory: statusHistory,
|
shipmentHistory: statusHistory,
|
||||||
packages: packages,
|
packages: packages,
|
||||||
receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon',
|
receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon',
|
||||||
shippingAddress: DeliveryAddress(
|
deliveryAddress: DeliveryAddress(
|
||||||
fullName: 'U Nyi Nyi',
|
fullName: 'U Nyi Nyi',
|
||||||
addressLine1: '154-19 64th Ave.',
|
addressLine1: '154-19 64th Ave.',
|
||||||
addressLine2: 'Flushing',
|
addressLine2: 'Flushing',
|
||||||
@@ -262,7 +262,7 @@ class BoxModel extends BaseModel {
|
|||||||
shipmentHistory: statusHistory,
|
shipmentHistory: statusHistory,
|
||||||
packages: packages,
|
packages: packages,
|
||||||
receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon',
|
receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon',
|
||||||
shippingAddress: DeliveryAddress(
|
deliveryAddress: DeliveryAddress(
|
||||||
fullName: 'U Nyi Nyi',
|
fullName: 'U Nyi Nyi',
|
||||||
addressLine1: '154-19 64th Ave.',
|
addressLine1: '154-19 64th Ave.',
|
||||||
addressLine2: 'Flushing',
|
addressLine2: 'Flushing',
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
|
||||||
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'invoice_shipment_list_row.dart';
|
import 'invoice_shipment_list_row.dart';
|
||||||
|
|
||||||
@@ -31,7 +28,7 @@ class _InvoiceShipmentListState extends State<InvoiceShipmentList> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var pickupModel = Provider.of<ShipmentModel>(context);
|
ShipmentModel shipmentModel = Provider.of<ShipmentModel>(context);
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
child: DefaultTabController(
|
child: DefaultTabController(
|
||||||
@@ -64,10 +61,10 @@ class _InvoiceShipmentListState extends State<InvoiceShipmentList> {
|
|||||||
scrollDirection: Axis.vertical,
|
scrollDirection: Axis.vertical,
|
||||||
padding: EdgeInsets.only(top: 15),
|
padding: EdgeInsets.only(top: 15),
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemCount: pickupModel.pickups.length,
|
itemCount: shipmentModel.shipments.length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return InvoiceShipmentListRow(
|
return InvoiceShipmentListRow(
|
||||||
pickUp: pickupModel.pickups[index]);
|
pickUp: shipmentModel.shipments[index]);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ class _InvoiceShipmentListRowState extends State<InvoiceShipmentListRow> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
print('_pickup $_pickUp');
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(left: 15, right: 15),
|
padding: EdgeInsets.only(left: 15, right: 15),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
@@ -83,7 +82,7 @@ class _InvoiceShipmentListRowState extends State<InvoiceShipmentListRow> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
child: getStatus(_pickUp.status),
|
child: getStatus(_pickUp.currentStatus),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
icon: Octicons.package,
|
icon: Octicons.package,
|
||||||
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
|
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
|
||||||
builder: (context) => PackageList(
|
builder: (context) => PackageList(
|
||||||
onlyFcs: true,
|
forCustomer: false,
|
||||||
))));
|
))));
|
||||||
|
|
||||||
final receivingBtn = TaskButton("receiving.title",
|
final receivingBtn = TaskButton("receiving.title",
|
||||||
@@ -249,8 +249,10 @@ class _HomePageState extends State<HomePage> {
|
|||||||
|
|
||||||
final shipmentBtnFcs = TaskButton("shipment",
|
final shipmentBtnFcs = TaskButton("shipment",
|
||||||
icon: SimpleLineIcons.direction,
|
icon: SimpleLineIcons.direction,
|
||||||
btnCallback: () => Navigator.of(context)
|
btnCallback: () => Navigator.of(context).push(CupertinoPageRoute(
|
||||||
.push(CupertinoPageRoute(builder: (context) => ShipmentList())));
|
builder: (context) => ShipmentList(
|
||||||
|
forCustomer: false,
|
||||||
|
))));
|
||||||
|
|
||||||
final fcsShipmentBtn = TaskButton("FCSshipment.title",
|
final fcsShipmentBtn = TaskButton("FCSshipment.title",
|
||||||
icon: Ionicons.ios_airplane,
|
icon: Ionicons.ios_airplane,
|
||||||
|
|||||||
@@ -18,72 +18,55 @@ class PackageModel extends BaseModel {
|
|||||||
final log = Logger('PackageModel');
|
final log = Logger('PackageModel');
|
||||||
|
|
||||||
StreamSubscription<QuerySnapshot> listener;
|
StreamSubscription<QuerySnapshot> listener;
|
||||||
StreamSubscription<QuerySnapshot> customerPackageListener;
|
|
||||||
|
|
||||||
List<Package> get packages =>
|
List<Package> get packages => _menuSelectedIndex == 1
|
||||||
_selectedIndex == 1 ? _packages : List<Package>.from(_delivered.values);
|
? _packages
|
||||||
List<Package> get customerPackages => _selectedIndex == 1
|
: List<Package>.from(_delivered.values);
|
||||||
? _customerPackages
|
|
||||||
: List<Package>.from(_customerDelivered.values);
|
|
||||||
|
|
||||||
List<Package> _packages = [];
|
List<Package> _packages = [];
|
||||||
List<Package> _customerPackages = [];
|
|
||||||
|
|
||||||
Paginator _delivered;
|
Paginator _delivered;
|
||||||
Paginator _customerDelivered;
|
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
bool isPackagesEnded = false;
|
int _menuSelectedIndex = 1;
|
||||||
bool isCustomerPackagesEnded = false;
|
|
||||||
int _selectedIndex = 1;
|
set menuSelectedIndex(int index) {
|
||||||
set selectedIndex(int index) {
|
_menuSelectedIndex = index;
|
||||||
_selectedIndex = index;
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
get selectedIndex => _selectedIndex;
|
get menuSelectedIndex => _menuSelectedIndex;
|
||||||
|
|
||||||
@override
|
initData(bool forCustomer) {
|
||||||
void privilegeChanged() {
|
logout();
|
||||||
super.privilegeChanged();
|
_menuSelectedIndex = 1;
|
||||||
_loadPackages();
|
_loadPackages(forCustomer);
|
||||||
_loadCustomerPackages();
|
_delivered = _getDeliveredExample(forCustomer);
|
||||||
|
_delivered.load();
|
||||||
if (_delivered != null) _delivered.close();
|
|
||||||
_delivered = _getDeliveredExample(false);
|
|
||||||
loadMore(isCustomer: false);
|
|
||||||
if (_customerDelivered != null) _customerDelivered.close();
|
|
||||||
_customerDelivered = _getDeliveredExample(false);
|
|
||||||
loadMore(isCustomer: true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
logout() async {
|
logout() async {
|
||||||
if (_delivered != null) _delivered.close();
|
if (_delivered != null) _delivered.close();
|
||||||
if (_customerDelivered != null) _customerDelivered.close();
|
|
||||||
if (listener != null) await listener.cancel();
|
if (listener != null) await listener.cancel();
|
||||||
if (customerPackageListener != null) await customerPackageListener.cancel();
|
|
||||||
_packages = [];
|
_packages = [];
|
||||||
_customerPackages = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadMore({bool isCustomer}) async {
|
Future<void> loadMore({bool isCustomer}) async {
|
||||||
if (selectedIndex == 1)
|
if (menuSelectedIndex == 1)
|
||||||
return; // when delivered menu is not selected return
|
return; // when delivered menu is not selected return
|
||||||
var p = isCustomer ? _customerDelivered : _delivered;
|
if (_delivered.ended) return;
|
||||||
if (p.ended) return;
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await p.load(onFinished: () {
|
await _delivered.load(onFinished: () {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> refresh({bool isCustomer}) async {
|
Future<void> refresh({bool isCustomer}) async {
|
||||||
if (selectedIndex == 1)
|
if (menuSelectedIndex == 1)
|
||||||
return; // when delivered menu is not selected return
|
return; // when delivered menu is not selected return
|
||||||
var p = isCustomer ? _customerDelivered : _delivered;
|
await _delivered.refresh(onFinished: () {
|
||||||
await p.refresh(onFinished: () {
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -129,8 +112,9 @@ class PackageModel extends BaseModel {
|
|||||||
return paginator;
|
return paginator;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadPackages() async {
|
Future<void> _loadPackages(bool forCustomer) async {
|
||||||
if (user == null ||
|
if (user == null) return;
|
||||||
|
if (!forCustomer &&
|
||||||
!((user.hasPackages() || user.hasReceiving() || user.hasProcessing())))
|
!((user.hasPackages() || user.hasReceiving() || user.hasProcessing())))
|
||||||
return;
|
return;
|
||||||
String path = "/$packages_collection";
|
String path = "/$packages_collection";
|
||||||
@@ -143,6 +127,10 @@ class PackageModel extends BaseModel {
|
|||||||
.where("is_delivered", isEqualTo: false)
|
.where("is_delivered", isEqualTo: false)
|
||||||
.where("is_deleted", isEqualTo: false);
|
.where("is_deleted", isEqualTo: false);
|
||||||
|
|
||||||
|
if (forCustomer) {
|
||||||
|
q = q.where("user_id", isEqualTo: user.id);
|
||||||
|
}
|
||||||
|
|
||||||
listener = q.snapshots().listen((QuerySnapshot snapshot) {
|
listener = q.snapshots().listen((QuerySnapshot snapshot) {
|
||||||
_packages.clear();
|
_packages.clear();
|
||||||
_packages = snapshot.documents.map((documentSnapshot) {
|
_packages = snapshot.documents.map((documentSnapshot) {
|
||||||
@@ -157,33 +145,6 @@ class PackageModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadCustomerPackages() async {
|
|
||||||
if (user == null) return;
|
|
||||||
String path = "/$packages_collection";
|
|
||||||
if (customerPackageListener != null) customerPackageListener.cancel();
|
|
||||||
_customerPackages = [];
|
|
||||||
|
|
||||||
try {
|
|
||||||
var q = Firestore.instance
|
|
||||||
.collection("$path")
|
|
||||||
.where("is_delivered", isEqualTo: false)
|
|
||||||
.where("is_deleted", isEqualTo: false)
|
|
||||||
.where("user_id", isEqualTo: user.id);
|
|
||||||
|
|
||||||
customerPackageListener = q.snapshots().listen((QuerySnapshot snapshot) {
|
|
||||||
_customerPackages.clear();
|
|
||||||
_customerPackages = snapshot.documents.map((documentSnapshot) {
|
|
||||||
var package = Package.fromMap(
|
|
||||||
documentSnapshot.data, documentSnapshot.documentID);
|
|
||||||
return package;
|
|
||||||
}).toList();
|
|
||||||
notifyListeners();
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
log.warning("Error!! $e");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Package> getPackage(String id) async {
|
Future<Package> getPackage(String id) async {
|
||||||
if (user == null) return null;
|
if (user == null) return null;
|
||||||
String path = "/$packages_collection";
|
String path = "/$packages_collection";
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
import 'package:fcs/helpers/paginator.dart';
|
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/package/model/package_model.dart';
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
import 'package:fcs/pages/package/package_info.dart';
|
import 'package:fcs/pages/package/package_info.dart';
|
||||||
@@ -14,9 +13,9 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class PackageList extends StatefulWidget {
|
class PackageList extends StatefulWidget {
|
||||||
final bool onlyFcs;
|
final bool forCustomer;
|
||||||
|
|
||||||
const PackageList({Key key, this.onlyFcs = false}) : super(key: key);
|
const PackageList({Key key, this.forCustomer = true}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_PackageListState createState() => _PackageListState();
|
_PackageListState createState() => _PackageListState();
|
||||||
}
|
}
|
||||||
@@ -32,31 +31,31 @@ class _PackageListState extends State<PackageList> {
|
|||||||
_controller.addListener(() async {
|
_controller.addListener(() async {
|
||||||
if (_controller.position.pixels == _controller.position.maxScrollExtent) {
|
if (_controller.position.pixels == _controller.position.maxScrollExtent) {
|
||||||
Provider.of<PackageModel>(context, listen: false)
|
Provider.of<PackageModel>(context, listen: false)
|
||||||
.loadMore(isCustomer: !widget.onlyFcs);
|
.loadMore(isCustomer: widget.forCustomer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Provider.of<PackageModel>(context, listen: false)
|
||||||
|
.initData(widget.forCustomer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var packageModel = Provider.of<PackageModel>(context);
|
var packageModel = Provider.of<PackageModel>(context);
|
||||||
bool onlyFcs = widget.onlyFcs;
|
var packages = packageModel.packages;
|
||||||
var packages =
|
|
||||||
onlyFcs ? packageModel.packages : packageModel.customerPackages;
|
|
||||||
|
|
||||||
final popupMenu = LocalPopupMenuButton(
|
final popupMenu = LocalPopupMenuButton(
|
||||||
popmenus: [
|
popmenus: [
|
||||||
LocalPopupMenu(
|
LocalPopupMenu(
|
||||||
id: 1,
|
id: 1,
|
||||||
textKey: "package.popupmenu.active",
|
textKey: "package.popupmenu.active",
|
||||||
selected: packageModel.selectedIndex == 1),
|
selected: packageModel.menuSelectedIndex == 1),
|
||||||
LocalPopupMenu(
|
LocalPopupMenu(
|
||||||
id: 2,
|
id: 2,
|
||||||
textKey: "package.popupmenu.delivered",
|
textKey: "package.popupmenu.delivered",
|
||||||
selected: packageModel.selectedIndex == 2)
|
selected: packageModel.menuSelectedIndex == 2)
|
||||||
],
|
],
|
||||||
popupMenuCallback: (p) => this.setState(() {
|
popupMenuCallback: (p) => this.setState(() {
|
||||||
packageModel.selectedIndex = p.id;
|
packageModel.menuSelectedIndex = p.id;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -77,8 +76,9 @@ class _PackageListState extends State<PackageList> {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
onlyFcs
|
widget.forCustomer
|
||||||
? IconButton(
|
? Container()
|
||||||
|
: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.search,
|
Icons.search,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@@ -86,8 +86,7 @@ class _PackageListState extends State<PackageList> {
|
|||||||
iconSize: 30,
|
iconSize: 30,
|
||||||
onPressed: () => searchPackage(context,
|
onPressed: () => searchPackage(context,
|
||||||
callbackPackageSelect: _searchCallback),
|
callbackPackageSelect: _searchCallback),
|
||||||
)
|
),
|
||||||
: Container(),
|
|
||||||
popupMenu
|
popupMenu
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -111,7 +110,7 @@ class _PackageListState extends State<PackageList> {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
onRefresh: () =>
|
onRefresh: () =>
|
||||||
packageModel.refresh(isCustomer: !widget.onlyFcs),
|
packageModel.refresh(isCustomer: widget.forCustomer),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
packageModel.isLoading
|
packageModel.isLoading
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
|
import 'package:fcs/domain/entities/box.dart';
|
||||||
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/input_text.dart';
|
||||||
import 'package:fcs/pages/widgets/length_picker.dart';
|
import 'package:fcs/pages/widgets/length_picker.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/local_title.dart';
|
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class ShipmentRatesCal extends StatefulWidget {
|
class ShipmentRatesCal extends StatefulWidget {
|
||||||
ShipmentRatesCal();
|
ShipmentRatesCal();
|
||||||
|
|
||||||
@@ -21,27 +22,52 @@ class ShipmentRatesCal extends StatefulWidget {
|
|||||||
|
|
||||||
class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
String cargoType;
|
CargoType _cargoType;
|
||||||
TextEditingController _widthController = new TextEditingController();
|
TextEditingController _widthController = new TextEditingController();
|
||||||
TextEditingController _heightController = new TextEditingController();
|
TextEditingController _heightController = new TextEditingController();
|
||||||
TextEditingController _lengthController = new TextEditingController();
|
TextEditingController _lengthController = new TextEditingController();
|
||||||
double shipmentWeight = 0;
|
TextEditingController _actualWeightCtl = new TextEditingController();
|
||||||
double volumetricRatio = 0;
|
double _shipmentWeight = 0;
|
||||||
|
double _amount = 0;
|
||||||
|
double _deliveryFee = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
//for shipment weight
|
//for shipment weight
|
||||||
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
Rate rate = Provider.of<ShipmentRateModel>(context, listen: false).rate;
|
||||||
.rate
|
_lengthController.addListener(_calShipmentWeight);
|
||||||
.volumetricRatio;
|
_widthController.addListener(_calShipmentWeight);
|
||||||
// _lengthController.addListener(_calShipmentWeight);
|
_heightController.addListener(_calShipmentWeight);
|
||||||
// _widthController.addListener(_calShipmentWeight);
|
_actualWeightCtl.addListener(_calShipmentWeight);
|
||||||
// _heightController.addListener(_calShipmentWeight);
|
_cargoType = rate.defaultCargoType;
|
||||||
_lengthController.text = '10';
|
_lengthController.text = '12';
|
||||||
_widthController.text = '10';
|
_widthController.text = '12';
|
||||||
_heightController.text = '10';
|
_heightController.text = '12';
|
||||||
|
_actualWeightCtl.text = "10";
|
||||||
|
_calShipmentWeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
_calShipmentWeight() {
|
||||||
|
Rate rate = Provider.of<ShipmentRateModel>(context, listen: false).rate;
|
||||||
|
|
||||||
|
double l = double.parse(_lengthController.text, (s) => 0);
|
||||||
|
double w = double.parse(_widthController.text, (s) => 0);
|
||||||
|
double h = double.parse(_heightController.text, (s) => 0);
|
||||||
|
_cargoType.weight = double.tryParse(_actualWeightCtl.text) ?? 0;
|
||||||
|
Box box = Box(cargoTypes: [_cargoType], length: l, width: w, height: h);
|
||||||
|
var amount = box.calAmount(rate);
|
||||||
|
var shipmentWeight = box.getShipmentWeight(rate.volumetricRatio);
|
||||||
|
var effectiveWeight =
|
||||||
|
_cargoType.weight > shipmentWeight ? _cargoType.weight : shipmentWeight;
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_deliveryFee =
|
||||||
|
effectiveWeight > rate.freeDeliveryWeight ? 0 : rate.deliveryFee;
|
||||||
|
_amount = amount == null ? 0 : amount + _deliveryFee;
|
||||||
|
_shipmentWeight = shipmentWeight;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -80,15 +106,16 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final shipmentWeightBox = DisplayText(
|
final shipmentWeightBox = DisplayText(
|
||||||
text: shipmentWeight != null ? shipmentWeight.toStringAsFixed(0) : "6",
|
text: _shipmentWeight != null ? _shipmentWeight.toStringAsFixed(2) : "0",
|
||||||
labelTextKey: "box.shipment_weight",
|
labelTextKey: "box.shipment_weight",
|
||||||
iconData: MaterialCommunityIcons.weight,
|
iconData: MaterialCommunityIcons.weight,
|
||||||
);
|
);
|
||||||
|
|
||||||
final actualWeightBox = DisplayText(
|
final actualWeightBox = InputText(
|
||||||
text: shipmentWeight != null ? shipmentWeight.toStringAsFixed(0) : "",
|
controller: _actualWeightCtl,
|
||||||
labelTextKey: "box.actual_weight",
|
labelTextKey: "box.actual_weight",
|
||||||
iconData: MaterialCommunityIcons.weight,
|
iconData: MaterialCommunityIcons.weight,
|
||||||
|
textInputType: TextInputType.number,
|
||||||
);
|
);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
@@ -119,17 +146,19 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
|||||||
Container(
|
Container(
|
||||||
width: 150.0,
|
width: 150.0,
|
||||||
child: DropdownButtonFormField(
|
child: DropdownButtonFormField(
|
||||||
|
value: _cargoType,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
hintText: shipmentRateModel.rate.cargoTypes[0].name,
|
hintText: shipmentRateModel.rate.cargoTypes[0].name,
|
||||||
hintStyle: TextStyle(color: Colors.black87)),
|
hintStyle: TextStyle(color: Colors.black87)),
|
||||||
items: shipmentRateModel.rate.cargoTypes
|
items: shipmentRateModel.rate.cargoTypes
|
||||||
.map((e) => DropdownMenuItem(
|
.map((e) =>
|
||||||
child: Text(e.name), value: e.name))
|
DropdownMenuItem(child: Text(e.name), value: e))
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (selected) => {
|
onChanged: (selected) => {
|
||||||
setState(() {
|
setState(() {
|
||||||
cargoType = selected;
|
_cargoType = selected;
|
||||||
|
_calShipmentWeight();
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -137,51 +166,40 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
actualWeightBox,
|
||||||
// LocalTitle(textKey: "box.dimension"),
|
// LocalTitle(textKey: "box.dimension"),
|
||||||
dimBox,
|
dimBox,
|
||||||
shipmentWeightBox,
|
shipmentWeightBox,
|
||||||
actualWeightBox,
|
|
||||||
|
|
||||||
SizedBox(height: 50),
|
SizedBox(height: 50),
|
||||||
Center(
|
Row(
|
||||||
child: Container(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
alignment: Alignment.center,
|
children: [
|
||||||
width: 150,
|
LocalText(context, "rate.delivery_fee",
|
||||||
child: Row(
|
color: primaryColor, fontSize: 16),
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
Text(
|
||||||
children: [
|
':\$ $_deliveryFee',
|
||||||
LocalText(context, "rate.delivery_fee",
|
style: TextStyle(
|
||||||
color: primaryColor, fontSize: 16),
|
color: primaryColor,
|
||||||
Text(
|
fontSize: 16,
|
||||||
':\$ 5',
|
),
|
||||||
style: TextStyle(
|
)
|
||||||
color: primaryColor,
|
],
|
||||||
fontSize: 16,
|
),
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
Center(
|
Row(
|
||||||
child: Container(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
width: 220,
|
children: [
|
||||||
alignment: Alignment.center,
|
LocalText(context, "rate.total_estimated_amount",
|
||||||
child: Row(
|
color: primaryColor, fontSize: 16),
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
Text(
|
||||||
children: [
|
':\$${_amount.toStringAsFixed(2)}',
|
||||||
LocalText(context, "rate.total_estimated_amount",
|
style: TextStyle(
|
||||||
color: primaryColor, fontSize: 16),
|
color: primaryColor,
|
||||||
Text(
|
fontSize: 16,
|
||||||
':\$ 41',
|
),
|
||||||
style: TextStyle(
|
)
|
||||||
color: primaryColor,
|
],
|
||||||
fontSize: 16,
|
)
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
))
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ class BoxRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
box.shippingAddress.fullName == null
|
box.deliveryAddress.fullName == null
|
||||||
? ''
|
? ''
|
||||||
: box.shippingAddress.fullName,
|
: box.deliveryAddress.fullName,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0,
|
fontSize: 15.0,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
@@ -39,9 +39,9 @@ class BoxRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
box.shippingAddress.addressLine1 == null
|
box.deliveryAddress.addressLine1 == null
|
||||||
? ''
|
? ''
|
||||||
: box.shippingAddress.addressLine1,
|
: box.deliveryAddress.addressLine1,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 14.0, color: Colors.grey),
|
fontSize: 14.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
@@ -49,9 +49,9 @@ class BoxRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
box.shippingAddress.addressLine2 == null
|
box.deliveryAddress.addressLine2 == null
|
||||||
? ''
|
? ''
|
||||||
: box.shippingAddress.addressLine2,
|
: box.deliveryAddress.addressLine2,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 14.0, color: Colors.grey),
|
fontSize: 14.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
@@ -59,9 +59,9 @@ class BoxRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
box.shippingAddress.city == null
|
box.deliveryAddress.city == null
|
||||||
? ''
|
? ''
|
||||||
: box.shippingAddress.city,
|
: box.deliveryAddress.city,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 14.0, color: Colors.grey),
|
fontSize: 14.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
@@ -69,9 +69,9 @@ class BoxRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
box.shippingAddress.state == null
|
box.deliveryAddress.state == null
|
||||||
? ''
|
? ''
|
||||||
: box.shippingAddress.state,
|
: box.deliveryAddress.state,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 14.0, color: Colors.grey),
|
fontSize: 14.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
@@ -79,9 +79,9 @@ class BoxRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
box.shippingAddress.phoneNumber == null
|
box.deliveryAddress.phoneNumber == null
|
||||||
? ''
|
? ''
|
||||||
: "Phone:${box.shippingAddress.phoneNumber}",
|
: "Phone:${box.deliveryAddress.phoneNumber}",
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 14.0, color: Colors.grey),
|
fontSize: 14.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
@@ -99,25 +99,14 @@ class BoxRow extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
"L${box.length}xW${box.weight}xH${box.height}",
|
"L${box.length}xW${box.width}xH${box.height}",
|
||||||
style: new TextStyle(fontSize: 15.0, color: Colors.black),
|
style: new TextStyle(fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
box.weight == null
|
"Actual Weight:${box.actualWeight.toString()}lb",
|
||||||
? ''
|
|
||||||
: "Actual Weight:${box.weight.toString()}lb",
|
|
||||||
style: new TextStyle(fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
box.shipmentWeight == null
|
|
||||||
? ''
|
|
||||||
: "Shipment Weight:${box.shipmentWeight.toString()}lb",
|
|
||||||
style: new TextStyle(fontSize: 14.0, color: Colors.grey),
|
style: new TextStyle(fontSize: 14.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:fcs/data/services/services.dart';
|
||||||
import 'package:fcs/domain/constants.dart';
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
|
||||||
import 'package:fcs/domain/entities/shipment.dart';
|
import 'package:fcs/domain/entities/shipment.dart';
|
||||||
import 'package:fcs/domain/vo/radio.dart';
|
import 'package:fcs/domain/vo/message.dart';
|
||||||
|
import 'package:fcs/helpers/paginator.dart';
|
||||||
import 'package:fcs/pages/main/model/base_model.dart';
|
import 'package:fcs/pages/main/model/base_model.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
@@ -13,376 +14,145 @@ class ShipmentModel extends BaseModel {
|
|||||||
|
|
||||||
StreamSubscription<QuerySnapshot> listener;
|
StreamSubscription<QuerySnapshot> listener;
|
||||||
|
|
||||||
List<RadioGroup> radioGroups1 = [
|
List<Shipment> get shipments => _menuSelectedIndex == 1
|
||||||
RadioGroup(
|
? _shipments
|
||||||
text: "FCS Pickup",
|
: List<Shipment>.from(_delivered.values);
|
||||||
index: 1,
|
|
||||||
),
|
|
||||||
RadioGroup(
|
|
||||||
text: "Courier Pickup",
|
|
||||||
index: 2,
|
|
||||||
),
|
|
||||||
RadioGroup(
|
|
||||||
text: "FCS Drop-off",
|
|
||||||
index: 3,
|
|
||||||
),
|
|
||||||
RadioGroup(
|
|
||||||
text: "Courier Drop-off",
|
|
||||||
index: 4,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
List<String> pickupTypes = [
|
List<Shipment> _shipments = [];
|
||||||
|
|
||||||
|
Paginator _delivered;
|
||||||
|
bool isLoading = false;
|
||||||
|
int _menuSelectedIndex = 1;
|
||||||
|
|
||||||
|
set menuSelectedIndex(int index) {
|
||||||
|
_menuSelectedIndex = index;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
get menuSelectedIndex => _menuSelectedIndex;
|
||||||
|
|
||||||
|
initData(bool forCustomer) {
|
||||||
|
logout();
|
||||||
|
_menuSelectedIndex = 1;
|
||||||
|
_loadShipments(forCustomer);
|
||||||
|
_delivered = _getDeliveredExample(forCustomer);
|
||||||
|
_delivered.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
logout() async {
|
||||||
|
if (_delivered != null) _delivered.close();
|
||||||
|
if (listener != null) await listener.cancel();
|
||||||
|
_shipments = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadMore({bool isCustomer}) async {
|
||||||
|
if (menuSelectedIndex == 1)
|
||||||
|
return; // when delivered menu is not selected return
|
||||||
|
if (_delivered.ended) return;
|
||||||
|
isLoading = true;
|
||||||
|
notifyListeners();
|
||||||
|
await _delivered.load(onFinished: () {
|
||||||
|
isLoading = false;
|
||||||
|
notifyListeners();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> refresh({bool isCustomer}) async {
|
||||||
|
if (menuSelectedIndex == 1)
|
||||||
|
return; // when delivered menu is not selected return
|
||||||
|
await _delivered.refresh(onFinished: () {
|
||||||
|
notifyListeners();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Paginator _getDelivered(bool isCustomer) {
|
||||||
|
if (!isCustomer) {
|
||||||
|
if (user == null ||
|
||||||
|
!((user.hasPackages() ||
|
||||||
|
user.hasReceiving() ||
|
||||||
|
user.hasProcessing()))) throw "No privilege";
|
||||||
|
}
|
||||||
|
var pageQuery = Firestore.instance
|
||||||
|
.collection("/$packages_collection")
|
||||||
|
.where("is_delivered", isEqualTo: true)
|
||||||
|
.where("is_deleted", isEqualTo: false);
|
||||||
|
if (isCustomer) {
|
||||||
|
pageQuery = pageQuery.where("user_id", isEqualTo: user.id);
|
||||||
|
}
|
||||||
|
pageQuery = pageQuery.orderBy("current_status_date", descending: true);
|
||||||
|
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
||||||
|
return Shipment.fromMap(data, id);
|
||||||
|
});
|
||||||
|
return paginator;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
Paginator _getDeliveredExample(bool onlyFcs) {
|
||||||
|
count = 1;
|
||||||
|
var pageQuery = Firestore.instance
|
||||||
|
.collection(
|
||||||
|
"/users/8OTfsbVvsUOn1SLxy1OrKk7Y_yNKkVoGalPcIlcHnAY/messages")
|
||||||
|
.orderBy("date", descending: true);
|
||||||
|
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
||||||
|
var m = Message.fromMap(data, id);
|
||||||
|
return Shipment(
|
||||||
|
id: m.id,
|
||||||
|
shipmentNumber: m.message,
|
||||||
|
currentStatus: m.senderName,
|
||||||
|
pickupDate: m.date,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
return paginator;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadShipments(bool forCustomer) async {
|
||||||
|
if (user == null) return;
|
||||||
|
if (!forCustomer && !user.hasShipment()) return;
|
||||||
|
String path = "/$shipments_collection";
|
||||||
|
if (listener != null) listener.cancel();
|
||||||
|
_shipments = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
var q = Firestore.instance
|
||||||
|
.collection("$path")
|
||||||
|
.where("is_delivered", isEqualTo: false)
|
||||||
|
.where("is_deleted", isEqualTo: false);
|
||||||
|
|
||||||
|
if (forCustomer) {
|
||||||
|
q = q.where("user_id", isEqualTo: user.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
listener = q.snapshots().listen((QuerySnapshot snapshot) {
|
||||||
|
_shipments.clear();
|
||||||
|
_shipments = snapshot.documents.map((documentSnapshot) {
|
||||||
|
var s = Shipment.fromMap(
|
||||||
|
documentSnapshot.data, documentSnapshot.documentID);
|
||||||
|
return s;
|
||||||
|
}).toList();
|
||||||
|
notifyListeners();
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
log.warning("Error!! $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> shipmentTypes = [
|
||||||
shipment_local_pickup,
|
shipment_local_pickup,
|
||||||
shipment_courier_pickup,
|
shipment_courier_pickup,
|
||||||
shipment_local_dropoff,
|
shipment_local_dropoff,
|
||||||
shipment_courier_dropoff
|
shipment_courier_dropoff
|
||||||
];
|
];
|
||||||
|
|
||||||
List<RadioGroup> get radioGroups {
|
|
||||||
List<RadioGroup> radioGroups = [
|
|
||||||
RadioGroup(
|
|
||||||
text: "Local Pickup",
|
|
||||||
index: 1,
|
|
||||||
),
|
|
||||||
RadioGroup(
|
|
||||||
text: "Courier Pickup",
|
|
||||||
index: 2,
|
|
||||||
),
|
|
||||||
RadioGroup(
|
|
||||||
text: "Local Drop-off",
|
|
||||||
index: 3,
|
|
||||||
),
|
|
||||||
RadioGroup(
|
|
||||||
text: "Courier Drop-off",
|
|
||||||
index: 4,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
return radioGroups;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Shipment> get pickups {
|
|
||||||
List<Shipment> pickups = [
|
|
||||||
Shipment(
|
|
||||||
id: "S200412 - 12 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: 'Pending',
|
|
||||||
date: DateTime(2020, 5, 1),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
isCourier: true,
|
|
||||||
radioIndex: 2,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200125 - 12 May 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: 'Confirmed',
|
|
||||||
date: DateTime(2020, 5, 6),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200441 - 13 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: "Pickuped",
|
|
||||||
date: DateTime(2020, 5, 9),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
radioIndex: 3,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200412 - 12 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: 'Pickuped',
|
|
||||||
date: DateTime(2020, 5, 15),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200125 - 12 May 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: 'Pickuped',
|
|
||||||
date: DateTime(2020, 5, 20),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200441 - 13 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: "Pickuped",
|
|
||||||
date: DateTime(2020, 5, 21),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200441 - 10 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: "Canceled",
|
|
||||||
date: DateTime(2020, 5, 25),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200441 - 6 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: "Canceled",
|
|
||||||
date: DateTime(2020, 5, 27),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
];
|
|
||||||
return pickups;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Shipment> pickups1 = [
|
|
||||||
Shipment(
|
|
||||||
id: "S200412 - 12 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: 'Pending',
|
|
||||||
date: DateTime(2020, 5, 1),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
isCourier: true,
|
|
||||||
radioIndex: 2,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200125 - 12 May 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: 'Confirmed',
|
|
||||||
date: DateTime(2020, 5, 6),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200441 - 13 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: "Pickuped",
|
|
||||||
date: DateTime(2020, 5, 9),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
radioIndex: 3,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200412 - 12 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: 'Pickuped',
|
|
||||||
date: DateTime(2020, 5, 15),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200125 - 12 May 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: 'Pickuped',
|
|
||||||
date: DateTime(2020, 5, 20),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200441 - 13 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: "Pickuped",
|
|
||||||
date: DateTime(2020, 5, 21),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200441 - 10 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: "Canceled",
|
|
||||||
date: DateTime(2020, 5, 25),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
Shipment(
|
|
||||||
id: "S200441 - 6 Apr 2020",
|
|
||||||
userName: "Ko Kyaw Nyi",
|
|
||||||
phoneNumber: '+959111111111',
|
|
||||||
fromTime: '1PM',
|
|
||||||
toTime: '3PM',
|
|
||||||
numberOfPackage: 5,
|
|
||||||
weight: 25,
|
|
||||||
status: "Canceled",
|
|
||||||
date: DateTime(2020, 5, 27),
|
|
||||||
address: '154-19 64th Ave.\nFlushing, NY 11367',
|
|
||||||
handlingFee: 50,
|
|
||||||
cargoTypes: [
|
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
|
||||||
]),
|
|
||||||
];
|
|
||||||
|
|
||||||
List<Shipment> get canceled {
|
|
||||||
List<Shipment> _p = pickups.where((e) => e.status == "Canceled").toList()
|
|
||||||
..sort((e1, e2) {
|
|
||||||
return e2.date.compareTo(e1.date);
|
|
||||||
});
|
|
||||||
return _p;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Shipment> get completed {
|
|
||||||
return pickups.where((e) => e.status == "Pickuped").toList()
|
|
||||||
..sort((e1, e2) {
|
|
||||||
return e2.date.compareTo(e1.date);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Shipment> get upcoming {
|
|
||||||
return pickups
|
|
||||||
.where((e) =>
|
|
||||||
e.status == "Pending" ||
|
|
||||||
e.status == "Confirmed" ||
|
|
||||||
e.status == "Processed" ||
|
|
||||||
e.status == "Rescheduled")
|
|
||||||
.toList()
|
|
||||||
..sort((e1, e2) {
|
|
||||||
return e2.date.compareTo(e1.date);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void initUser(user) {
|
void initUser(user) {
|
||||||
super.initUser(user);
|
super.initUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
Future<void> createShipment(Shipment shipment) {
|
||||||
logout() async {
|
return Services.instance.shipmentService.createShipment(shipment);
|
||||||
if (listener != null) await listener.cancel();
|
}
|
||||||
// pickups = [];
|
|
||||||
|
Future<void> updateShipment(Shipment shipment) {
|
||||||
|
return Services.instance.shipmentService.updateShipment(shipment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import 'package:fcs/domain/vo/delivery_address.dart';
|
|||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/box/cargo_type_editor.dart';
|
import 'package:fcs/pages/box/cargo_type_editor.dart';
|
||||||
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
||||||
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
||||||
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
@@ -37,10 +35,8 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
Box _box;
|
Box _box;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool _isNew;
|
bool _isNew;
|
||||||
DeliveryAddress _deliveryAddress;
|
|
||||||
double volumetricRatio = 0;
|
double volumetricRatio = 0;
|
||||||
double shipmentWeight = 0;
|
double shipmentWeight = 0;
|
||||||
List<CargoType> cargos = [];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -52,22 +48,26 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
|
|
||||||
if (widget.box != null) {
|
if (widget.box != null) {
|
||||||
_box = widget.box;
|
_box = widget.box;
|
||||||
_deliveryAddress = _box.shippingAddress;
|
|
||||||
_isNew = false;
|
_isNew = false;
|
||||||
|
_lengthCtl.text = _box.length.toString();
|
||||||
|
_widthCtl.text = _box.width.toString();
|
||||||
|
_heightCtl.text = _box.height.toString();
|
||||||
} else {
|
} else {
|
||||||
var shipmentModel =
|
var shipmentModel =
|
||||||
Provider.of<DeliveryAddressModel>(context, listen: false);
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
_deliveryAddress = shipmentModel.defalutAddress;
|
|
||||||
|
|
||||||
_isNew = true;
|
_isNew = true;
|
||||||
_box = Box();
|
_box = Box(cargoTypes: []);
|
||||||
_lengthCtl.text = "0";
|
_box.deliveryAddress = shipmentModel.defalutAddress;
|
||||||
_widthCtl.text = "0";
|
|
||||||
_heightCtl.text = "0";
|
_lengthCtl.text = "12";
|
||||||
|
_widthCtl.text = "12";
|
||||||
|
_heightCtl.text = "12";
|
||||||
}
|
}
|
||||||
_lengthCtl.addListener(_calShipmentWeight);
|
_lengthCtl.addListener(_calShipmentWeight);
|
||||||
_widthCtl.addListener(_calShipmentWeight);
|
_widthCtl.addListener(_calShipmentWeight);
|
||||||
_heightCtl.addListener(_calShipmentWeight);
|
_heightCtl.addListener(_calShipmentWeight);
|
||||||
|
_calShipmentWeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
_calShipmentWeight() {
|
_calShipmentWeight() {
|
||||||
@@ -75,7 +75,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
double w = double.parse(_widthCtl.text, (s) => 0);
|
double w = double.parse(_widthCtl.text, (s) => 0);
|
||||||
double h = double.parse(_heightCtl.text, (s) => 0);
|
double h = double.parse(_heightCtl.text, (s) => 0);
|
||||||
setState(() {
|
setState(() {
|
||||||
shipmentWeight = l * w * h / volumetricRatio;
|
shipmentWeight = (l * w * h / volumetricRatio).ceilToDouble();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +113,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
);
|
);
|
||||||
final createBtn = LocalButton(
|
final createBtn = LocalButton(
|
||||||
textKey: "shipment.box.add",
|
textKey: "shipment.box.add",
|
||||||
|
callBack: _creatCarton,
|
||||||
);
|
);
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
@@ -182,19 +183,19 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
shipmentWeightBox,
|
shipmentWeightBox,
|
||||||
LocalTitle(textKey: "shipment.box.delivery"),
|
LocalTitle(textKey: "shipment.box.delivery"),
|
||||||
DefaultDeliveryAddress(
|
DefaultDeliveryAddress(
|
||||||
deliveryAddress: _deliveryAddress,
|
deliveryAddress: _box.deliveryAddress,
|
||||||
labelKey: "shipment.box.delivery",
|
labelKey: "shipment.box.delivery",
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
|
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => DeliveryAddressSelection(
|
builder: (context) => DeliveryAddressSelection(
|
||||||
deliveryAddress: _deliveryAddress,
|
deliveryAddress: _box.deliveryAddress,
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
if (d == null) return;
|
if (d == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
this._deliveryAddress = d;
|
_box.deliveryAddress = d;
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
createBtn
|
createBtn
|
||||||
@@ -206,11 +207,11 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<MyDataRow> getCargoRows(BuildContext context) {
|
List<MyDataRow> getCargoRows(BuildContext context) {
|
||||||
if (cargos == null || cargos == null) {
|
if (_box.cargoTypes == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
int total = 0;
|
double total = 0;
|
||||||
var rows = cargos.map((c) {
|
var rows = _box.cargoTypes.map((c) {
|
||||||
total += c.weight;
|
total += c.weight;
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (bool selected) async {
|
onSelectChanged: (bool selected) async {
|
||||||
@@ -258,7 +259,6 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
color: Colors.black87,
|
color: Colors.black87,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
|
|
||||||
)),
|
)),
|
||||||
MyDataCell(
|
MyDataCell(
|
||||||
Padding(
|
Padding(
|
||||||
@@ -278,14 +278,24 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
_addCargo(CargoType cargo) {
|
_addCargo(CargoType cargo) {
|
||||||
if (cargo == null) return;
|
if (cargo == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
cargos.remove(cargo);
|
_box.cargoTypes.remove(cargo);
|
||||||
cargos.add(cargo);
|
_box.cargoTypes.add(cargo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_removeCargo(CargoType cargo) {
|
_removeCargo(CargoType cargo) {
|
||||||
setState(() {
|
setState(() {
|
||||||
cargos.remove(cargo);
|
_box.cargoTypes.remove(cargo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_creatCarton() {
|
||||||
|
double l = double.parse(_lengthCtl.text, (s) => 0);
|
||||||
|
double w = double.parse(_widthCtl.text, (s) => 0);
|
||||||
|
double h = double.parse(_heightCtl.text, (s) => 0);
|
||||||
|
_box.length = l;
|
||||||
|
_box.width = w;
|
||||||
|
_box.height = h;
|
||||||
|
Navigator.pop(context, _box);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import 'package:fcs/domain/constants.dart';
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/box.dart';
|
import 'package:fcs/domain/entities/box.dart';
|
||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
|
||||||
import 'package:fcs/domain/entities/shipment.dart';
|
import 'package:fcs/domain/entities/shipment.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/box/model/box_model.dart';
|
import 'package:fcs/pages/box/model/box_model.dart';
|
||||||
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
||||||
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
||||||
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
@@ -21,7 +20,6 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/local_title.dart';
|
import 'package:fcs/pages/widgets/local_title.dart';
|
||||||
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:fcs/pages/widgets/title_with_add_button.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
@@ -32,8 +30,6 @@ import 'package:provider/provider.dart';
|
|||||||
import 'box_row.dart';
|
import 'box_row.dart';
|
||||||
import 'shipment_box_editor.dart';
|
import 'shipment_box_editor.dart';
|
||||||
|
|
||||||
enum SingingCharacter { lafayette, jefferson }
|
|
||||||
|
|
||||||
class ShipmentEditor extends StatefulWidget {
|
class ShipmentEditor extends StatefulWidget {
|
||||||
final Shipment shipment;
|
final Shipment shipment;
|
||||||
ShipmentEditor({this.shipment});
|
ShipmentEditor({this.shipment});
|
||||||
@@ -63,46 +59,42 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
TextEditingController _pickupDate = new TextEditingController();
|
TextEditingController _pickupDate = new TextEditingController();
|
||||||
TextEditingController _handlingFeeController = new TextEditingController();
|
TextEditingController _handlingFeeController = new TextEditingController();
|
||||||
|
|
||||||
Shipment _pickUp;
|
Shipment _shipment;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
var now = new DateTime.now();
|
var now = new DateTime.now();
|
||||||
bool _isNew;
|
bool _isNew;
|
||||||
DeliveryAddress _pickupAddress = new DeliveryAddress();
|
|
||||||
|
|
||||||
int _currVal = 1;
|
int _currVal = 1;
|
||||||
String _selectedPickupType;
|
String _selectedShipmentType;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_selectedPickupType = shipment_local_pickup;
|
_selectedShipmentType = shipment_local_pickup;
|
||||||
|
|
||||||
if (widget.shipment != null) {
|
if (widget.shipment != null) {
|
||||||
_isNew = false;
|
_isNew = false;
|
||||||
_pickUp = widget.shipment;
|
_shipment = widget.shipment;
|
||||||
_addressEditingController.text = _pickUp.address;
|
_addressEditingController.text = _shipment.address;
|
||||||
_fromTimeEditingController.text = _pickUp.fromTime;
|
_fromTimeEditingController.text = _shipment.pickupTimeStart;
|
||||||
_toTimeEditingController.text = _pickUp.toTime;
|
_toTimeEditingController.text = _shipment.pickupTimeEnd;
|
||||||
_noOfPackageEditingController.text = _pickUp.numberOfPackage.toString();
|
_noOfPackageEditingController.text = _shipment.numberOfPackage.toString();
|
||||||
_weightEditingController.text = _pickUp.weight.toString();
|
_weightEditingController.text = _shipment.weight.toString();
|
||||||
_pickupDate.text = dateFormatter.format(now);
|
_pickupDate.text = dateFormatter.format(_shipment.pickupDate ?? now);
|
||||||
_handlingFeeController.text = numberFormatter.format(_pickUp.handlingFee);
|
// _handlingFeeController.text =
|
||||||
_currVal = _pickUp.radioIndex;
|
// numberFormatter.format(_shipment.handlingFee);
|
||||||
|
_currVal = _shipment.radioIndex;
|
||||||
} else {
|
} else {
|
||||||
_isNew = true;
|
_isNew = true;
|
||||||
_pickupDate.text = dateFormatter.format(now);
|
_pickupDate.text = dateFormatter.format(now);
|
||||||
_fromTimeEditingController.text = "${(now.hour)}:${(now.minute)}";
|
_fromTimeEditingController.text = "${(now.hour)}:${(now.minute)}";
|
||||||
_toTimeEditingController.text = "${(now.hour)}:${(now.minute)}";
|
_toTimeEditingController.text = "${(now.hour)}:${(now.minute)}";
|
||||||
List<CargoType> _cargoTypes = [
|
_shipment = Shipment(boxes: []);
|
||||||
CargoType(name: 'General Cargo', weight: 25),
|
var shipmentModel =
|
||||||
CargoType(name: 'Medicine', weight: 20),
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
_shipment.pickupAddress = shipmentModel.defalutAddress;
|
||||||
];
|
_pickupDate.text = dateFormatter.format(now);
|
||||||
_pickUp = Shipment(cargoTypes: _cargoTypes);
|
|
||||||
}
|
}
|
||||||
var shipmentModel =
|
|
||||||
Provider.of<DeliveryAddressModel>(context, listen: false);
|
|
||||||
_pickupAddress = shipmentModel.defalutAddress;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -110,8 +102,6 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
SingingCharacter _character = SingingCharacter.lafayette;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
MainModel mainModel = Provider.of<MainModel>(context);
|
MainModel mainModel = Provider.of<MainModel>(context);
|
||||||
@@ -149,20 +139,20 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
);
|
);
|
||||||
final pickupAddressBox = DefaultDeliveryAddress(
|
final pickupAddressBox = DefaultDeliveryAddress(
|
||||||
deliveryAddress: _pickupAddress,
|
deliveryAddress: _shipment.pickupAddress,
|
||||||
iconData: Icons.location_on,
|
iconData: Icons.location_on,
|
||||||
labelKey: "shipment.location",
|
labelKey: "shipment.location",
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
|
DeliveryAddress address = await Navigator.push<DeliveryAddress>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => DeliveryAddressSelection(
|
builder: (context) => DeliveryAddressSelection(
|
||||||
deliveryAddress: _pickupAddress,
|
deliveryAddress: _shipment.pickupAddress,
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
if (d == null) return;
|
if (address == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
this._pickupAddress = d;
|
_shipment.pickupAddress = address;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -174,15 +164,16 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
var shipmentTypeBox = LocalDropdown<String>(
|
var shipmentTypeBox = LocalDropdown<String>(
|
||||||
callback: (v) {
|
callback: (v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedPickupType = v;
|
_selectedShipmentType = v;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
iconData: SimpleLineIcons.direction,
|
iconData: SimpleLineIcons.direction,
|
||||||
selectedValue: _selectedPickupType,
|
selectedValue: _selectedShipmentType,
|
||||||
values: pickupModel.pickupTypes,
|
values: pickupModel.shipmentTypes,
|
||||||
);
|
);
|
||||||
final createBtn = LocalButton(
|
final createBtn = LocalButton(
|
||||||
textKey: "shipment.create",
|
textKey: "shipment.create",
|
||||||
|
callBack: _create,
|
||||||
);
|
);
|
||||||
|
|
||||||
final updateBtn = LocalButton(
|
final updateBtn = LocalButton(
|
||||||
@@ -216,11 +207,11 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
LocalTitle(textKey: "shipment.type"),
|
LocalTitle(textKey: "shipment.type"),
|
||||||
LocalRadioButtons(
|
LocalRadioButtons(
|
||||||
values: pickupModel.pickupTypes,
|
values: pickupModel.shipmentTypes,
|
||||||
selectedValue: _selectedPickupType,
|
selectedValue: _selectedShipmentType,
|
||||||
callback: (v) {
|
callback: (v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedPickupType = v;
|
_selectedShipmentType = v;
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
// handlingFeeBox,
|
// handlingFeeBox,
|
||||||
@@ -240,17 +231,18 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
Icons.add_circle,
|
Icons.add_circle,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
Navigator.push(
|
Box box = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => ShipmentBoxEditor()),
|
builder: (context) => ShipmentBoxEditor()),
|
||||||
);
|
);
|
||||||
|
_addBox(box);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
children: getBoxList(context, boxModel.boxes),
|
children: getBoxList(context, _shipment.boxes),
|
||||||
),
|
),
|
||||||
_isNew ? createBtn : updateBtn,
|
_isNew ? createBtn : updateBtn,
|
||||||
],
|
],
|
||||||
@@ -263,14 +255,67 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
List<Widget> getBoxList(BuildContext context, List<Box> boxes) {
|
List<Widget> getBoxList(BuildContext context, List<Box> boxes) {
|
||||||
return boxes.asMap().entries.map((_box) {
|
return boxes.asMap().entries.map((_box) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
Navigator.of(context).push(CupertinoPageRoute(
|
Box box = await Navigator.of(context).push(CupertinoPageRoute(
|
||||||
builder: (context) => ShipmentBoxEditor(box: _box.value)));
|
builder: (context) => ShipmentBoxEditor(box: _box.value)));
|
||||||
|
_saveBox(box);
|
||||||
},
|
},
|
||||||
child: BoxRow(box: _box.value),
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(child: BoxRow(box: _box.value)),
|
||||||
|
InkWell(
|
||||||
|
onTap: () => _removeBox(_box.value),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Icon(Icons.remove, color: primaryColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
_addBox() {}
|
_addBox(Box box) {
|
||||||
|
if (box == null) return;
|
||||||
|
_shipment.boxes.add(box);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
_saveBox(Box box) {
|
||||||
|
if (box == null) return;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
_removeBox(Box box) {
|
||||||
|
if (box == null) return;
|
||||||
|
_shipment.boxes.remove(box);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
_create() async {
|
||||||
|
_shipment.shipmentType = this._selectedShipmentType;
|
||||||
|
_shipment.pickupDate = dateFormatter.parse(_pickupDate.text);
|
||||||
|
_shipment.pickupTimeStart = _fromTimeEditingController.text;
|
||||||
|
_shipment.pickupTimeEnd = _toTimeEditingController.text;
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
ShipmentModel shipmentModel =
|
||||||
|
Provider.of<ShipmentModel>(context, listen: false);
|
||||||
|
if (_isNew) {
|
||||||
|
await shipmentModel.createShipment(_shipment);
|
||||||
|
} else {
|
||||||
|
await shipmentModel.createShipment(_shipment);
|
||||||
|
}
|
||||||
|
Navigator.pop(context);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
248
lib/pages/shipment/shipment_info.dart
Normal file
248
lib/pages/shipment/shipment_info.dart
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
import 'package:fcs/domain/constants.dart';
|
||||||
|
import 'package:fcs/domain/entities/box.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';
|
||||||
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
|
import 'package:fcs/pages/shipment/model/shipment_model.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';
|
||||||
|
import 'package:fcs/pages/widgets/input_date.dart';
|
||||||
|
import 'package:fcs/pages/widgets/input_time.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_title.dart';
|
||||||
|
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
||||||
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import 'box_row.dart';
|
||||||
|
|
||||||
|
class ShipmentInfo extends StatefulWidget {
|
||||||
|
final Shipment shipment;
|
||||||
|
ShipmentInfo({this.shipment});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ShipmentInfoState createState() => _ShipmentInfoState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ShipmentInfoState extends State<ShipmentInfo> {
|
||||||
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||||
|
final numberFormatter = new NumberFormat("#,###");
|
||||||
|
MultiImgController multiImgController = MultiImgController();
|
||||||
|
|
||||||
|
TextEditingController _addressEditingController = new TextEditingController();
|
||||||
|
TextEditingController _fromTimeEditingController =
|
||||||
|
new TextEditingController();
|
||||||
|
TextEditingController _toTimeEditingController = new TextEditingController();
|
||||||
|
TextEditingController _noOfPackageEditingController =
|
||||||
|
new TextEditingController();
|
||||||
|
TextEditingController _weightEditingController = new TextEditingController();
|
||||||
|
TextEditingController _recipientNameEditingController =
|
||||||
|
new TextEditingController();
|
||||||
|
TextEditingController _recipientPhoneEditingController =
|
||||||
|
new TextEditingController();
|
||||||
|
TextEditingController _recipientAddressEditingController =
|
||||||
|
new TextEditingController();
|
||||||
|
TextEditingController _pickupDate = new TextEditingController();
|
||||||
|
TextEditingController _handlingFeeController = new TextEditingController();
|
||||||
|
|
||||||
|
Shipment _shipment;
|
||||||
|
bool _isLoading = false;
|
||||||
|
var now = new DateTime.now();
|
||||||
|
|
||||||
|
int _currVal = 1;
|
||||||
|
String _selectedShipmentType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_selectedShipmentType = shipment_local_pickup;
|
||||||
|
_shipment = widget.shipment;
|
||||||
|
|
||||||
|
if (widget.shipment != null) {
|
||||||
|
_addressEditingController.text = _shipment.address;
|
||||||
|
_fromTimeEditingController.text = _shipment.pickupTimeStart;
|
||||||
|
_toTimeEditingController.text = _shipment.pickupTimeEnd;
|
||||||
|
_noOfPackageEditingController.text = _shipment.numberOfPackage.toString();
|
||||||
|
_weightEditingController.text = _shipment.weight.toString();
|
||||||
|
_pickupDate.text = dateFormatter.format(_shipment.pickupDate ?? now);
|
||||||
|
// _handlingFeeController.text =
|
||||||
|
// numberFormatter.format(_shipment.handlingFee);
|
||||||
|
_currVal = _shipment.radioIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
MainModel mainModel = Provider.of<MainModel>(context);
|
||||||
|
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
|
||||||
|
|
||||||
|
final fromTimeBox = InputTime(
|
||||||
|
labelTextKey: 'shipment.from',
|
||||||
|
iconData: Icons.timer,
|
||||||
|
controller: _fromTimeEditingController);
|
||||||
|
|
||||||
|
final toTimeBox = Container(
|
||||||
|
width: 150,
|
||||||
|
child: InputTime(
|
||||||
|
iconData: Icons.timer_off,
|
||||||
|
labelTextKey: 'shipment.to',
|
||||||
|
controller: _toTimeEditingController));
|
||||||
|
|
||||||
|
final pickupDateBox = InputDate(
|
||||||
|
labelTextKey: "shipment.date",
|
||||||
|
iconData: Icons.date_range,
|
||||||
|
controller: _pickupDate,
|
||||||
|
);
|
||||||
|
final localDropoffAddress = DisplayText(
|
||||||
|
iconData: Icons.location_on,
|
||||||
|
labelTextKey: "Local Dropoff Address",
|
||||||
|
text: mainModel.setting.usaAddress);
|
||||||
|
final curierDropoffAddress = FloatingActionButton.extended(
|
||||||
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
onPressed: () {},
|
||||||
|
icon: Icon(Icons.arrow_right),
|
||||||
|
label: Text(
|
||||||
|
'Visit courier websie for nearest drop-off',
|
||||||
|
style: TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
|
backgroundColor: primaryColor,
|
||||||
|
);
|
||||||
|
final pickupAddressBox = DefaultDeliveryAddress(
|
||||||
|
deliveryAddress: _shipment.pickupAddress,
|
||||||
|
iconData: Icons.location_on,
|
||||||
|
labelKey: "shipment.location",
|
||||||
|
onTap: () async {
|
||||||
|
DeliveryAddress address = await Navigator.push<DeliveryAddress>(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => DeliveryAddressSelection(
|
||||||
|
deliveryAddress: _shipment.pickupAddress,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
if (address == null) return;
|
||||||
|
setState(() {
|
||||||
|
_shipment.pickupAddress = address;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
var boxModel = Provider.of<BoxModel>(context);
|
||||||
|
var handlingFeeBox = DisplayText(
|
||||||
|
labelTextKey: "shipment.handling.fee",
|
||||||
|
text: "10",
|
||||||
|
iconData: FontAwesomeIcons.moneyBill);
|
||||||
|
var shipmentTypeBox = LocalDropdown<String>(
|
||||||
|
callback: (v) {
|
||||||
|
setState(() {
|
||||||
|
_selectedShipmentType = v;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
iconData: SimpleLineIcons.direction,
|
||||||
|
selectedValue: _selectedShipmentType,
|
||||||
|
values: pickupModel.shipmentTypes,
|
||||||
|
);
|
||||||
|
|
||||||
|
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(),
|
||||||
|
),
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
title: LocalText(
|
||||||
|
context,
|
||||||
|
"shipment.info",
|
||||||
|
fontSize: 20,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.edit, color: primaryColor),
|
||||||
|
onPressed: _edit,
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
child: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
LocalTitle(textKey: "shipment.type"),
|
||||||
|
LocalRadioButtons(
|
||||||
|
values: pickupModel.shipmentTypes,
|
||||||
|
selectedValue: _selectedShipmentType,
|
||||||
|
callback: (v) {
|
||||||
|
setState(() {
|
||||||
|
_selectedShipmentType = v;
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
// handlingFeeBox,
|
||||||
|
// shipmentTypeBox,
|
||||||
|
LocalTitle(textKey: "shipment.location"),
|
||||||
|
pickupAddressBox,
|
||||||
|
LocalTitle(textKey: "shipment.date.time"),
|
||||||
|
pickupDateBox,
|
||||||
|
fromTimeBox,
|
||||||
|
toTimeBox,
|
||||||
|
// localDropoffAddress,
|
||||||
|
// curierDropoffAddress,
|
||||||
|
LocalTitle(
|
||||||
|
textKey: "boxes.name",
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.add_circle,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () async {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Column(
|
||||||
|
// children: getBoxList(context, _shipment.boxes),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> getBoxList(BuildContext context, List<Box> boxes) {
|
||||||
|
return boxes.asMap().entries.map((_box) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () async {},
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(child: BoxRow(box: _box.value)),
|
||||||
|
InkWell(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Icon(Icons.remove, color: primaryColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
_edit() {}
|
||||||
|
}
|
||||||
@@ -15,17 +15,28 @@ import 'shipment_editor.dart';
|
|||||||
import 'shipment_list_row.dart';
|
import 'shipment_list_row.dart';
|
||||||
|
|
||||||
class ShipmentList extends StatefulWidget {
|
class ShipmentList extends StatefulWidget {
|
||||||
|
final bool forCustomer;
|
||||||
|
|
||||||
|
const ShipmentList({Key key, this.forCustomer = true}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_ShipmentListState createState() => _ShipmentListState();
|
_ShipmentListState createState() => _ShipmentListState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ShipmentListState extends State<ShipmentList> {
|
class _ShipmentListState extends State<ShipmentList> {
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool _showDelivered = false;
|
var _controller = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_controller.addListener(() async {
|
||||||
|
if (_controller.position.pixels == _controller.position.maxScrollExtent) {
|
||||||
|
Provider.of<ShipmentModel>(context, listen: false)
|
||||||
|
.loadMore(isCustomer: widget.forCustomer);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Provider.of<ShipmentModel>(context, listen: false).initData(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -35,7 +46,7 @@ class _ShipmentListState extends State<ShipmentList> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var pickupModel = Provider.of<ShipmentModel>(context);
|
ShipmentModel shipmentModel = Provider.of<ShipmentModel>(context);
|
||||||
final popupMenu = LocalPopupMenuButton(
|
final popupMenu = LocalPopupMenuButton(
|
||||||
popmenus: [
|
popmenus: [
|
||||||
LocalPopupMenu(
|
LocalPopupMenu(
|
||||||
@@ -43,7 +54,7 @@ class _ShipmentListState extends State<ShipmentList> {
|
|||||||
LocalPopupMenu(id: 2, textKey: "shipment.popupmenu.delivered")
|
LocalPopupMenu(id: 2, textKey: "shipment.popupmenu.delivered")
|
||||||
],
|
],
|
||||||
popupMenuCallback: (p) => this.setState(() {
|
popupMenuCallback: (p) => this.setState(() {
|
||||||
_showDelivered = p.id == 2;
|
shipmentModel.menuSelectedIndex = p.id;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
@@ -72,25 +83,53 @@ class _ShipmentListState extends State<ShipmentList> {
|
|||||||
popupMenu
|
popupMenu
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton.extended(
|
floatingActionButton: shipmentModel.menuSelectedIndex == 1
|
||||||
onPressed: () {
|
? FloatingActionButton.extended(
|
||||||
_newPickup();
|
onPressed: () {
|
||||||
},
|
_newPickup();
|
||||||
icon: Icon(Icons.add),
|
},
|
||||||
label: LocalText(context, "shipment.new", color: Colors.white),
|
icon: Icon(Icons.add),
|
||||||
backgroundColor: primaryColor,
|
label:
|
||||||
|
LocalText(context, "shipment.new", color: Colors.white),
|
||||||
|
backgroundColor: primaryColor,
|
||||||
|
)
|
||||||
|
: Container(),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: RefreshIndicator(
|
||||||
|
child: ListView.separated(
|
||||||
|
controller: _controller,
|
||||||
|
separatorBuilder: (context, index) => Divider(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
padding: EdgeInsets.only(top: 15),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: shipmentModel.shipments.length,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return ShipmentListRow(
|
||||||
|
pickUp: shipmentModel.shipments[index]);
|
||||||
|
}),
|
||||||
|
onRefresh: () =>
|
||||||
|
shipmentModel.refresh(isCustomer: widget.forCustomer),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
shipmentModel.isLoading
|
||||||
|
? Container(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
|
color: primaryColor,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text("Loading...",
|
||||||
|
style: TextStyle(color: Colors.white)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container(),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
body: new ListView.separated(
|
|
||||||
separatorBuilder: (context, index) => Divider(
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
scrollDirection: Axis.vertical,
|
|
||||||
padding: EdgeInsets.only(top: 15),
|
|
||||||
shrinkWrap: true,
|
|
||||||
itemCount: pickupModel.pickups.length,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
return ShipmentListRow(pickUp: pickupModel.pickups[index]);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:flutter_icons/flutter_icons.dart';
|
|||||||
|
|
||||||
import '../main/util.dart';
|
import '../main/util.dart';
|
||||||
import 'shipment_editor.dart';
|
import 'shipment_editor.dart';
|
||||||
|
import 'shipment_info.dart';
|
||||||
|
|
||||||
class ShipmentListRow extends StatefulWidget {
|
class ShipmentListRow extends StatefulWidget {
|
||||||
final Shipment pickUp;
|
final Shipment pickUp;
|
||||||
@@ -36,13 +37,12 @@ class _ShipmentListRowState extends State<ShipmentListRow> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
print('_pickup $_pickUp');
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(left: 15, right: 15),
|
padding: EdgeInsets.only(left: 15, right: 15),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).push(CupertinoPageRoute(
|
Navigator.of(context).push(CupertinoPageRoute(
|
||||||
builder: (context) => ShipmentEditor(shipment: _pickUp)));
|
builder: (context) => ShipmentInfo(shipment: _pickUp)));
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -64,7 +64,7 @@ class _ShipmentListRowState extends State<ShipmentListRow> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: new Text(
|
child: new Text(
|
||||||
_pickUp.id == null ? '' : _pickUp.id,
|
_pickUp.shipmentNumber,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 15.0, color: Colors.black),
|
fontSize: 15.0, color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -90,7 +90,7 @@ class _ShipmentListRowState extends State<ShipmentListRow> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
child: getStatus(_pickUp.status),
|
child: getStatus(_pickUp.currentStatus),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
||||||
|
|||||||
@@ -32,9 +32,10 @@ class _LengthPickerState extends State<LengthPicker> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_setText() {
|
_setText() {
|
||||||
int v = int.parse(widget.controller.text, onError: (s) => 0);
|
double v = double.parse(widget.controller.text, (s) => 0);
|
||||||
int f = (v / 12).round();
|
int f = (v / 12).floor();
|
||||||
int ins = (v % 12).round();
|
int ins = (v % 12).round();
|
||||||
|
|
||||||
_controller.text = "$f' $ins\"";
|
_controller.text = "$f' $ins\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,8 +82,8 @@ class LengthPickerDialog extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
||||||
double _valueFeet;
|
int _valueFeet;
|
||||||
double _valueInc;
|
int _valueInc;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -90,8 +91,8 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
_valueInc = 0;
|
_valueInc = 0;
|
||||||
if (widget.controller != null) {
|
if (widget.controller != null) {
|
||||||
double v = double.parse(widget.controller.text, (s) => 0);
|
double v = double.parse(widget.controller.text, (s) => 0);
|
||||||
_valueFeet = v / 12;
|
_valueFeet = (v / 12).floor();
|
||||||
_valueInc = v % 12;
|
_valueInc = (v % 12).toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
)),
|
)),
|
||||||
children: [
|
children: [
|
||||||
Center(child: Text(_getText(_valueFeet))),
|
Center(child: Text(_getText())),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -121,7 +122,7 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
),
|
),
|
||||||
Slider(
|
Slider(
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
value: _valueFeet,
|
value: _valueFeet.toDouble(),
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 15,
|
max: 15,
|
||||||
divisions: 100,
|
divisions: 100,
|
||||||
@@ -146,7 +147,7 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
),
|
),
|
||||||
Slider(
|
Slider(
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
value: _valueInc,
|
value: _valueInc.toDouble(),
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 11,
|
max: 11,
|
||||||
divisions: 100,
|
divisions: 100,
|
||||||
@@ -163,7 +164,7 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
|
|
||||||
_updateFeet(double v) {
|
_updateFeet(double v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_valueFeet = v;
|
_valueFeet = v.toInt();
|
||||||
});
|
});
|
||||||
if (widget.controller != null) {
|
if (widget.controller != null) {
|
||||||
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
||||||
@@ -173,7 +174,7 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
|
|
||||||
_updateInc(double v) {
|
_updateInc(double v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_valueInc = v;
|
_valueInc = v.toInt();
|
||||||
});
|
});
|
||||||
if (widget.controller != null) {
|
if (widget.controller != null) {
|
||||||
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
||||||
@@ -181,7 +182,7 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getText(double v) {
|
String _getText() {
|
||||||
int ft = _valueFeet.round();
|
int ft = _valueFeet.round();
|
||||||
int ins = _valueInc.round();
|
int ins = _valueInc.round();
|
||||||
return "$ft\' $ins\"";
|
return "$ft\' $ins\"";
|
||||||
|
|||||||
Reference in New Issue
Block a user