Merge branch 'master' of tzw/fcs into master
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
"btn.filter":"Filter",
|
"btn.filter":"Filter",
|
||||||
"btn.exit_confirm":"Are you sure you want to exit?",
|
"btn.exit_confirm":"Are you sure you want to exit?",
|
||||||
"btn.confirm":"Confirm",
|
"btn.confirm":"Confirm",
|
||||||
|
"btn.add":"Add",
|
||||||
"Buttons End ================================================================":"",
|
"Buttons End ================================================================":"",
|
||||||
|
|
||||||
"Offline Start ================================================================":"",
|
"Offline Start ================================================================":"",
|
||||||
@@ -143,6 +144,7 @@
|
|||||||
"customer.disable.btn":"Disable",
|
"customer.disable.btn":"Disable",
|
||||||
"customer.enable.btn":"Enable",
|
"customer.enable.btn":"Enable",
|
||||||
"customer.chat.btn":"Chat",
|
"customer.chat.btn":"Chat",
|
||||||
|
"customer.detail.title":"Account",
|
||||||
"Customer End ================================================================":"",
|
"Customer End ================================================================":"",
|
||||||
|
|
||||||
"Invitation Start ================================================================":"",
|
"Invitation Start ================================================================":"",
|
||||||
@@ -188,21 +190,25 @@
|
|||||||
"profile.email":"Email",
|
"profile.email":"Email",
|
||||||
"profile.privileges":"Privileges",
|
"profile.privileges":"Privileges",
|
||||||
"profile.default.delivery.address":"Default delivery address",
|
"profile.default.delivery.address":"Default delivery address",
|
||||||
"profile.recovery.email":"Recovery Email",
|
"profile.recovery.email":"Recovery email",
|
||||||
"profile.change_phone.title":"Change Phone Number",
|
"profile.change.phone":"Change my phone number",
|
||||||
"profile.current_phone":"Current Phone Number",
|
"profile.change_phone.title":"Change My Phone Number",
|
||||||
"profile.new_phone":"New Phone Number",
|
"profile.current_phone":"Current phone number",
|
||||||
|
"profile.new_phone":"New phone number",
|
||||||
"profile.new_phone_empty":"Enter new phone number",
|
"profile.new_phone_empty":"Enter new phone number",
|
||||||
"profile.send_sms":"Send SMS Code",
|
"profile.send_sms":"Send SMS Code",
|
||||||
"profile.confirm_new_phone.title":"Confirm New Phone Number",
|
"profile.confirm_new_phone.title":"Confirm New Phone Number",
|
||||||
|
"profile.confirm.instruction":"Enter SMS code sent to your phone number",
|
||||||
"profile.change_phone.btn":"Change",
|
"profile.change_phone.btn":"Change",
|
||||||
"profile.recovery_email.title":"Recovery Email",
|
"profile.recovery_email.title":"Recovery Email",
|
||||||
"profile.email.empty":"Enter recovery email",
|
"profile.email.empty":"Enter recovery email",
|
||||||
"profile.email.mismatch_message":"Email format is incorrect",
|
"profile.email.mismatch_message":"Email format is incorrect",
|
||||||
"profile.email_instruction":"Your recovery email is used to help you get back into your account when you can’t sign in.",
|
"profile.email_instruction":"Your recovery email is used to help you get back into your account when you can’t sign in.",
|
||||||
"profile.comfirm_email.title":"Confirm Your Email",
|
"profile.comfirm_email.title":"Confirm Your Email",
|
||||||
"profile.confirm_email.send_to":"Sent email to",
|
"profile.confirm_email.send_to":"Verification code sent email to your email",
|
||||||
"profile.confirm_email.insruction":"Please open the email to confirm recovery email",
|
"profile.confirm_email.insruction":"Please open your email to get verification code and confirm recovery email",
|
||||||
|
"profile.confirm_email_code":"Verification code",
|
||||||
|
|
||||||
"Profile End ================================================================":"",
|
"Profile End ================================================================":"",
|
||||||
|
|
||||||
"Package Start ================================================================":"",
|
"Package Start ================================================================":"",
|
||||||
@@ -395,6 +401,7 @@
|
|||||||
"box.delivery":"Delivery",
|
"box.delivery":"Delivery",
|
||||||
"box.pickup":"Pick-up",
|
"box.pickup":"Pick-up",
|
||||||
"box.add.cargo_type":"Add cargo type",
|
"box.add.cargo_type":"Add cargo type",
|
||||||
|
"box.mix_cargo.title":"Mix cargo",
|
||||||
"Boxes End ================================================================":"",
|
"Boxes End ================================================================":"",
|
||||||
|
|
||||||
"Delivery Start ================================================================":"",
|
"Delivery Start ================================================================":"",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"btn.filter":"Filter",
|
"btn.filter":"Filter",
|
||||||
"btn.exit_confirm":"Are you sure you want to exit?",
|
"btn.exit_confirm":"Are you sure you want to exit?",
|
||||||
"btn.confirm":"အတည်ပြုမည်",
|
"btn.confirm":"အတည်ပြုမည်",
|
||||||
|
"btn.add":"ထည့်မည်",
|
||||||
"Buttons End ================================================================":"",
|
"Buttons End ================================================================":"",
|
||||||
|
|
||||||
"Offline Start ================================================================":"",
|
"Offline Start ================================================================":"",
|
||||||
@@ -143,7 +144,7 @@
|
|||||||
"customer.disable.btn":"ပိတ်ပါ",
|
"customer.disable.btn":"ပိတ်ပါ",
|
||||||
"customer.enable.btn":"ဖွင့်ပါ",
|
"customer.enable.btn":"ဖွင့်ပါ",
|
||||||
"customer.chat.btn":"Chat",
|
"customer.chat.btn":"Chat",
|
||||||
|
"customer.detail.title":"အကောင့်",
|
||||||
"Customer End ================================================================":"",
|
"Customer End ================================================================":"",
|
||||||
|
|
||||||
"Invitation Start ================================================================":"",
|
"Invitation Start ================================================================":"",
|
||||||
@@ -190,20 +191,23 @@
|
|||||||
"profile.privileges":"လုပ်ပိုင်ခွင့်များ",
|
"profile.privileges":"လုပ်ပိုင်ခွင့်များ",
|
||||||
"profile.default.delivery.address":"အမြဲတမ်း ပို့ဆောင်ရမည့်လိပ်စာ",
|
"profile.default.delivery.address":"အမြဲတမ်း ပို့ဆောင်ရမည့်လိပ်စာ",
|
||||||
"profile.recovery.email":"အီးမေးလ်",
|
"profile.recovery.email":"အီးမေးလ်",
|
||||||
|
"profile.change.phone":"ဖုန်းနံပါတ်ပြောင်းခြင်း",
|
||||||
"profile.change_phone.title":"ဖုန်းနံပါတ်ပြောင်းခြင်း",
|
"profile.change_phone.title":"ဖုန်းနံပါတ်ပြောင်းခြင်း",
|
||||||
"profile.current_phone":"လက်ရှိဖုန်းနံပါတ်",
|
"profile.current_phone":"လက်ရှိဖုန်းနံပါတ်",
|
||||||
"profile.new_phone":"ဖုန်းနံပါတ်အသစ်",
|
"profile.new_phone":"ဖုန်းနံပါတ်အသစ်",
|
||||||
"profile.new_phone_empty":"ဖုန်းနံပါတ်အသစ်ထည့်ပါ",
|
"profile.new_phone_empty":"ဖုန်းနံပါတ်အသစ်ထည့်ပါ",
|
||||||
"profile.send_sms":"SMS ကုဒ်ပို့မည်",
|
"profile.send_sms":"SMS ကုဒ်ပို့မည်",
|
||||||
"profile.confirm_new_phone.title":"ဖုန်းနံပါတ်အသစ်ကို အတည်ပြုခြင်း",
|
"profile.confirm_new_phone.title":"ဖုန်းနံပါတ်အသစ်ကို အတည်ပြုခြင်း",
|
||||||
|
"profile.confirm.instruction":"သင့်ဖုန်းနံပါတ်သို့ ပေးပို့ထားသော SMS ကုဒ်ကိုရိုက်ထည့်ပါ",
|
||||||
"profile.change_phone.btn":"ပြောင်းမည်",
|
"profile.change_phone.btn":"ပြောင်းမည်",
|
||||||
"profile.recovery_email.title":"အီးမေးလ်ထည့်ခြင်း",
|
"profile.recovery_email.title":"အီးမေးလ်ထည့်ခြင်း",
|
||||||
"profile.email.empty":"အီးမေးလ်ထည့်ပါ",
|
"profile.email.empty":"အီးမေးလ်ထည့်ပါ",
|
||||||
"profile.email.mismatch_message":"အီးမေးလ်မမှန်ပါ",
|
"profile.email.mismatch_message":"အီးမေးလ်မမှန်ပါ",
|
||||||
"profile.email_instruction":"အကောင့်ဝင်လို့မရသောအခါတွင် သင့်အကောင့်ထဲသို့ ပြန်လည်ရောက်ရှိစေရန်အတွက် သင်၏အီးမေးလ်ကို အသုံးပြုပါသည်။",
|
"profile.email_instruction":"အကောင့်ဝင်လို့မရသောအခါတွင် သင့်အကောင့်ထဲသို့ ပြန်လည်ရောက်ရှိစေရန်အတွက် သင်၏အီးမေးလ်ကို အသုံးပြုပါသည်။",
|
||||||
"profile.comfirm_email.title":"သင့်အီးမေးလ်ကိုအတည်ပြုခြင်း",
|
"profile.comfirm_email.title":"သင့်အီးမေးလ်ကိုအတည်ပြုခြင်း",
|
||||||
"profile.confirm_email.send_to":"သင့်အီးမေးလ်သို့ ပေးပို့ခဲ့သည်",
|
"profile.confirm_email.send_to":"အတည်ပြုကုဒ်ကို သင့်အီးမေးလ်သို့ ပေးပို့ခဲ့သည်",
|
||||||
"profile.confirm_email.insruction":"အီးမေးလ်ကို အတည်ပြုရန် သင့်အီးမေးလ်ကိုဖွင့်ပါ",
|
"profile.confirm_email.insruction":"အတည်ပြုကုဒ်ရယူရန်နှင့် အီးမေးလ်ကို အတည်ပြုရန် သင့်အီးမေးလ်ကိုဖွင့်ပါ",
|
||||||
|
"profile.confirm_email_code":"အတည်ပြုကုဒ်",
|
||||||
"Profile End ================================================================":"",
|
"Profile End ================================================================":"",
|
||||||
|
|
||||||
"Package Start ================================================================":"",
|
"Package Start ================================================================":"",
|
||||||
@@ -395,6 +399,7 @@
|
|||||||
"box.delivery":"Delivery",
|
"box.delivery":"Delivery",
|
||||||
"box.pickup":"Pick-up",
|
"box.pickup":"Pick-up",
|
||||||
"box.add.cargo_type":"Add cargo type",
|
"box.add.cargo_type":"Add cargo type",
|
||||||
|
"box.mix_cargo.title":"Mix cargo",
|
||||||
"Boxes End ================================================================":"",
|
"Boxes End ================================================================":"",
|
||||||
|
|
||||||
"Delivery Start ================================================================":"",
|
"Delivery Start ================================================================":"",
|
||||||
|
|||||||
@@ -11,20 +11,14 @@ import '../services/services.dart';
|
|||||||
class PackageDataProvider {
|
class PackageDataProvider {
|
||||||
final log = Logger('PackageDataProvider');
|
final log = Logger('PackageDataProvider');
|
||||||
|
|
||||||
Future<void> createPackages(List<Package> packages, String fcsID) async {
|
|
||||||
List<Map<String, dynamic>> json = packages.map((e) => e.toJson()).toList();
|
|
||||||
return await requestAPI("/packages", "POST",
|
|
||||||
payload: {"packages": json, "fcs_id": fcsID}, token: await getToken());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> createReceiving(Package package) async {
|
Future<void> createReceiving(Package package) async {
|
||||||
return await requestAPI("/receiving", "POST",
|
return await requestAPI("/receiving", "POST",
|
||||||
payload: package.toJson(), token: await getToken());
|
payload: package.toJsonForReceiving(), token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateReceiving(Package package) async {
|
Future<void> updateReceiving(Package package) async {
|
||||||
return await requestAPI("/receiving", "PUT",
|
return await requestAPI("/receiving", "PUT",
|
||||||
payload: package.toJson(), token: await getToken());
|
payload: package.toJsonForReceiving(), token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> deleteReceiving(Package package) async {
|
Future<void> deleteReceiving(Package package) async {
|
||||||
@@ -34,7 +28,7 @@ class PackageDataProvider {
|
|||||||
|
|
||||||
Future<void> updateProcessing(Package package) async {
|
Future<void> updateProcessing(Package package) async {
|
||||||
return await requestAPI("/processing", "PUT",
|
return await requestAPI("/processing", "PUT",
|
||||||
payload: package.toJson(), token: await getToken());
|
payload: package.toJsonForProcessing(), token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> deleteProcessing(Package package) async {
|
Future<void> deleteProcessing(Package package) async {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class UserDataProvider {
|
|||||||
.limit(1)
|
.limit(1)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (querySnap.docs.length > 0) {
|
if (querySnap.docs.isNotEmpty) {
|
||||||
var snap = querySnap.docs.first;
|
var snap = querySnap.docs.first;
|
||||||
User user = User.fromMap(snap.data() as Map<String, dynamic>, snap.id);
|
User user = User.fromMap(snap.data() as Map<String, dynamic>, snap.id);
|
||||||
return user;
|
return user;
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ class PackageServiceImp implements PackageService {
|
|||||||
final Connectivity? connectivity;
|
final Connectivity? connectivity;
|
||||||
final PackageDataProvider packageDataProvider;
|
final PackageDataProvider packageDataProvider;
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> createPackages(List<Package> packages, String fcsID) {
|
|
||||||
return packageDataProvider.createPackages(packages, fcsID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> createReceiving(Package package) {
|
Future<void> createReceiving(Package package) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
|
|
||||||
abstract class PackageService {
|
abstract class PackageService {
|
||||||
Future<void> createPackages(List<Package> packages, String fcsID);
|
|
||||||
Future<void> createReceiving(Package package);
|
Future<void> createReceiving(Package package);
|
||||||
Future<void> updateReceiving(Package package);
|
Future<void> updateReceiving(Package package);
|
||||||
Future<void> deleteReceiving(Package package);
|
Future<void> deleteReceiving(Package package);
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ class CargoType {
|
|||||||
bool isDefault;
|
bool isDefault;
|
||||||
bool isMixCargo;
|
bool isMixCargo;
|
||||||
|
|
||||||
|
List<String> mixCargoIds;
|
||||||
|
List<CargoType> mixCargoes;
|
||||||
|
|
||||||
double get calAmount => calRate * calWeight;
|
double get calAmount => calRate * calWeight;
|
||||||
|
|
||||||
CargoType(
|
CargoType(
|
||||||
@@ -28,7 +31,9 @@ class CargoType {
|
|||||||
this.customDutyFee = 0,
|
this.customDutyFee = 0,
|
||||||
this.displayIndex = 0,
|
this.displayIndex = 0,
|
||||||
this.isDefault = false,
|
this.isDefault = false,
|
||||||
this.isMixCargo = false});
|
this.isMixCargo = false,
|
||||||
|
this.mixCargoes = const [],
|
||||||
|
this.mixCargoIds = const []});
|
||||||
|
|
||||||
factory CargoType.fromMap(Map<String, dynamic> map, String id) {
|
factory CargoType.fromMap(Map<String, dynamic> map, String id) {
|
||||||
return CargoType(
|
return CargoType(
|
||||||
@@ -45,12 +50,23 @@ class CargoType {
|
|||||||
isMixCargo: map['is_mix_cargo'] ?? false);
|
isMixCargo: map['is_mix_cargo'] ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
factory CargoType.fromMapForCargo(Map<String, dynamic> map, String id) {
|
factory CargoType.fromMapForCarton(Map<String, dynamic> map, String id) {
|
||||||
|
var cargoTypesMaps =
|
||||||
|
List<Map<String, dynamic>>.from(map['mix_cargo_types'] ?? []);
|
||||||
|
var mixCargoTypes =
|
||||||
|
cargoTypesMaps.map((e) => CargoType.fromMapForMix(e, e["id"])).toList();
|
||||||
|
|
||||||
return CargoType(
|
return CargoType(
|
||||||
id: id,
|
id: id,
|
||||||
name: map['name'],
|
name: map['name'],
|
||||||
weight: map['weight']?.toDouble() ?? 0,
|
weight: map['weight']?.toDouble() ?? 0,
|
||||||
displayIndex: map['display_index'] ?? 0);
|
displayIndex: map['display_index'] ?? 0,
|
||||||
|
isMixCargo: map['is_mix_cargo'] ?? false,
|
||||||
|
mixCargoes: mixCargoTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory CargoType.fromMapForMix(Map<String, dynamic> map, String id) {
|
||||||
|
return CargoType(id: id, name: map['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
factory CargoType.fromMapForsurcharge(Map<String, dynamic> map, String id) {
|
factory CargoType.fromMapForsurcharge(Map<String, dynamic> map, String id) {
|
||||||
@@ -78,7 +94,11 @@ class CargoType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toMapForCarton() {
|
Map<String, dynamic> toMapForCarton() {
|
||||||
return {"id": id, 'weight': weight};
|
return {
|
||||||
|
"id": id,
|
||||||
|
'weight': weight,
|
||||||
|
"mix_cargo_type_ids": mixCargoes.map((e) => e.id).toList()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toMapForSurcharge() {
|
Map<String, dynamic> toMapForSurcharge() {
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ class Carton {
|
|||||||
var cargoTypesMaps =
|
var cargoTypesMaps =
|
||||||
List<Map<String, dynamic>>.from(map['cargo_types'] ?? []);
|
List<Map<String, dynamic>>.from(map['cargo_types'] ?? []);
|
||||||
var cargoTypes = cargoTypesMaps
|
var cargoTypes = cargoTypesMaps
|
||||||
.map((e) => CargoType.fromMapForCargo(e, e["id"]))
|
.map((e) => CargoType.fromMapForCarton(e, e["id"]))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
var surchargeItemMaps =
|
var surchargeItemMaps =
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ class Package {
|
|||||||
String? desc;
|
String? desc;
|
||||||
String? status;
|
String? status;
|
||||||
|
|
||||||
String? shipmentId;
|
String? fcsShipmentId;
|
||||||
String? shipmentNumber;
|
String? fcsShipmentNumber;
|
||||||
|
|
||||||
String? userID;
|
String? userID;
|
||||||
String? fcsID;
|
String? fcsID;
|
||||||
@@ -54,8 +54,8 @@ class Package {
|
|||||||
this.userName,
|
this.userName,
|
||||||
this.fcsID,
|
this.fcsID,
|
||||||
this.phoneNumber,
|
this.phoneNumber,
|
||||||
this.shipmentId,
|
this.fcsShipmentId,
|
||||||
this.shipmentNumber,
|
this.fcsShipmentNumber,
|
||||||
this.senderFCSID,
|
this.senderFCSID,
|
||||||
this.senderName,
|
this.senderName,
|
||||||
this.boxNumber,
|
this.boxNumber,
|
||||||
@@ -111,8 +111,8 @@ class Package {
|
|||||||
senderFCSID: map['sender_fcs_id'],
|
senderFCSID: map['sender_fcs_id'],
|
||||||
senderName: map['sender_name'] ?? "",
|
senderName: map['sender_name'] ?? "",
|
||||||
senderPhoneNumber: map['sender_phone_number'] ?? "",
|
senderPhoneNumber: map['sender_phone_number'] ?? "",
|
||||||
shipmentId: map['shipment_id'],
|
fcsShipmentId: map['fcs_shipment_id'],
|
||||||
shipmentNumber: map['shipment_number'],
|
fcsShipmentNumber: map['fcs_shipment_number'],
|
||||||
deliveryAddress: da,
|
deliveryAddress: da,
|
||||||
currentStatusDate: currentStatusDate?.toDate().toLocal(),
|
currentStatusDate: currentStatusDate?.toDate().toLocal(),
|
||||||
photoUrls: photoUrls,
|
photoUrls: photoUrls,
|
||||||
@@ -120,12 +120,21 @@ class Package {
|
|||||||
cartonIds: cartonIds);
|
cartonIds: cartonIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJsonForReceiving() => {
|
||||||
'id': id,
|
'id': id,
|
||||||
'tracking_id': trackingID,
|
'tracking_id': trackingID,
|
||||||
'market': market,
|
'fcs_id': fcsID,
|
||||||
|
"remark": remark,
|
||||||
|
"photo_urls": photoUrls
|
||||||
|
};
|
||||||
|
|
||||||
|
Map<String, dynamic> toJsonForProcessing() => {
|
||||||
|
'id': id,
|
||||||
'fcs_id': fcsID,
|
'fcs_id': fcsID,
|
||||||
'sender_fcs_id': senderFCSID,
|
'sender_fcs_id': senderFCSID,
|
||||||
|
'fcs_shipment_id' : fcsShipmentId,
|
||||||
|
'tracking_id': trackingID,
|
||||||
|
'market': market,
|
||||||
"desc": desc,
|
"desc": desc,
|
||||||
"remark": remark,
|
"remark": remark,
|
||||||
"photo_urls": photoUrls
|
"photo_urls": photoUrls
|
||||||
@@ -158,7 +167,7 @@ class Package {
|
|||||||
package.desc != desc ||
|
package.desc != desc ||
|
||||||
package.remark != remark ||
|
package.remark != remark ||
|
||||||
package.photoUrls != photoUrls ||
|
package.photoUrls != photoUrls ||
|
||||||
package.shipmentId != shipmentId;
|
package.fcsShipmentId != fcsShipmentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -121,9 +121,10 @@ class User {
|
|||||||
userUnseenCount: map['user_unseen_count'] ?? 0,
|
userUnseenCount: map['user_unseen_count'] ?? 0,
|
||||||
fcsUnseenCount: map['fcs_unseen_count'] ?? 0,
|
fcsUnseenCount: map['fcs_unseen_count'] ?? 0,
|
||||||
preferCurrency: map['preferred_currency'],
|
preferCurrency: map['preferred_currency'],
|
||||||
lastMessageTime: _date == null ? null : _date.toDate(),
|
lastMessageTime: _date?.toDate(),
|
||||||
enablePinLogin: map['enable_pin_login'] ?? false,
|
enablePinLogin: map['enable_pin_login'] ?? false,
|
||||||
pinDigit: map['pin'] ?? '');
|
pinDigit: map['pin'] ?? '',
|
||||||
|
recoveryEmail: map['email'] ?? "");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool diffPrivileges(User another) {
|
bool diffPrivileges(User another) {
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ Future<void> main() async {
|
|||||||
Config(
|
Config(
|
||||||
flavor: Flavor.DEV,
|
flavor: Flavor.DEV,
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
// apiURL: "http://192.168.100.150:9090",
|
apiURL: "http://192.168.100.150:9090",
|
||||||
apiURL: "https://asia-northeast1-fcs-dev1.cloudfunctions.net/API13",
|
// apiURL: "https://asia-northeast1-fcs-dev1.cloudfunctions.net/API13",
|
||||||
level: Level.ALL);
|
level: Level.ALL);
|
||||||
runApp(App(title: "FCS - Dev"));
|
runApp(App(title: "FCS - Dev"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,11 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
p.isChecked = false;
|
p.isChecked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.cargoTypes.forEach((vp) {
|
for (var vp in widget.cargoTypes) {
|
||||||
if (p.id == vp.id) {
|
if (p.id == vp.id) {
|
||||||
p.qty = vp.qty;
|
p.qty = vp.qty;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
|
|||||||
131
lib/pages/carton/cargo_type_addition_dialog.dart
Normal file
131
lib/pages/carton/cargo_type_addition_dialog.dart
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../domain/entities/cargo_type.dart';
|
||||||
|
import '../../helpers/theme.dart';
|
||||||
|
import '../main/util.dart';
|
||||||
|
import '../rates/model/shipment_rate_model.dart';
|
||||||
|
import '../widgets/local_text.dart';
|
||||||
|
|
||||||
|
class CargoTypeAdditionDialog extends StatefulWidget {
|
||||||
|
const CargoTypeAdditionDialog({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CargoTypeAdditionDialog> createState() =>
|
||||||
|
_CargoTypeAdditionDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CargoTypeAdditionDialogState extends State<CargoTypeAdditionDialog> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
List<CargoType> cargoTypes = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_init();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
_init() {
|
||||||
|
var shipmentRateModel =
|
||||||
|
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||||
|
cargoTypes =
|
||||||
|
shipmentRateModel.rate.cargoTypes.map((e) => e.clone()).toList();
|
||||||
|
var defaultCargoes = cargoTypes.where((e) => e.isDefault).toList();
|
||||||
|
for (var p in cargoTypes) {
|
||||||
|
if (defaultCargoes.any((e) => e.id == p.id)) {
|
||||||
|
p.isChecked = true;
|
||||||
|
} else {
|
||||||
|
p.isChecked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
title: Center(
|
||||||
|
child: LocalText(context, 'box.add.cargo_type',
|
||||||
|
fontSize: 18, color: primaryColor, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
content: SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: EdgeInsets.only(top: 10),
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Column(
|
||||||
|
children: cargoTypes.map((p) {
|
||||||
|
return ListTile(
|
||||||
|
minTileHeight: 50,
|
||||||
|
minVerticalPadding: 0,
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
p.isChecked = !p.isChecked;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
title: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Checkbox(
|
||||||
|
value: p.isChecked,
|
||||||
|
activeColor: primaryColor,
|
||||||
|
side: BorderSide(color: Colors.black38, width: 2),
|
||||||
|
onChanged: (bool? value) {
|
||||||
|
if (value != null) {
|
||||||
|
setState(() {
|
||||||
|
p.isChecked = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
p.name ?? "",
|
||||||
|
style:
|
||||||
|
TextStyle(fontSize: 15.0, color: Colors.black),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: LocalText(context, 'btn.cancel',
|
||||||
|
color: labelColor, fontSize: 14),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
const SizedBox(width: 5),
|
||||||
|
TextButton(
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
minimumSize: Size(80, 35),
|
||||||
|
backgroundColor: primaryColor,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: LocalText(context, 'btn.add',
|
||||||
|
color: Colors.white, fontSize: 14),
|
||||||
|
onPressed: () async {
|
||||||
|
if (!_formKey.currentState!.validate()) return;
|
||||||
|
_save();
|
||||||
|
})
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_save() {
|
||||||
|
try {
|
||||||
|
var selectedCargos = cargoTypes.where((e) => e.isChecked).toList();
|
||||||
|
Navigator.pop<List<CargoType>>(context, selectedCargos);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,19 @@
|
|||||||
|
// ignore_for_file: unused_local_variable
|
||||||
|
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons_null_safety/flutter_icons_null_safety.dart';
|
import 'package:flutter_icons_null_safety/flutter_icons_null_safety.dart';
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import '../../domain/entities/cargo_type.dart';
|
import '../../domain/entities/cargo_type.dart';
|
||||||
import '../../domain/entities/user.dart';
|
import '../../domain/entities/user.dart';
|
||||||
import '../main/util.dart';
|
import '../main/util.dart';
|
||||||
import '../rates/model/shipment_rate_model.dart';
|
|
||||||
import '../widgets/continue_button.dart';
|
import '../widgets/continue_button.dart';
|
||||||
import '../widgets/local_title.dart';
|
import '../widgets/local_title.dart';
|
||||||
import '../widgets/previous_button.dart';
|
import '../widgets/previous_button.dart';
|
||||||
import 'cargo_type_addition.dart';
|
import 'cargo_type_addition.dart';
|
||||||
|
import 'cargo_type_addition_dialog.dart';
|
||||||
|
import 'mix_cargo_type_addition_dialog.dart';
|
||||||
import 'surcharge_item_addition.dart';
|
import 'surcharge_item_addition.dart';
|
||||||
|
|
||||||
typedef OnPrevious = Function(
|
typedef OnPrevious = Function(
|
||||||
@@ -48,6 +50,12 @@ class _CargoWidgetState extends State<CargoWidget> {
|
|||||||
List<TextEditingController> cargoTypeControllers = [];
|
List<TextEditingController> cargoTypeControllers = [];
|
||||||
List<TextEditingController> surchargeControllers = [];
|
List<TextEditingController> surchargeControllers = [];
|
||||||
|
|
||||||
|
List<CargoType> _mixCargoTypes = [];
|
||||||
|
List<TextEditingController> mixCargoTypeControllers = [];
|
||||||
|
|
||||||
|
bool get isKnownTotalWeight =>
|
||||||
|
totalCtl.text.isNotEmpty && totalCtl.text != '0';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_init();
|
_init();
|
||||||
@@ -55,38 +63,38 @@ class _CargoWidgetState extends State<CargoWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_init() {
|
_init() {
|
||||||
|
totalCtl.addListener(totalInputChangeListener);
|
||||||
// for cargo types
|
// for cargo types
|
||||||
if (widget.cargoTypes.isNotEmpty) {
|
if (widget.cargoTypes.isNotEmpty) {
|
||||||
_cargoTypes = List.from(widget.cargoTypes);
|
List<CargoType> allCargoes = List.from(widget.cargoTypes);
|
||||||
|
_cargoTypes = allCargoes.where((e) => !e.isMixCargo).toList();
|
||||||
for (var e in _cargoTypes) {
|
for (var e in _cargoTypes) {
|
||||||
var editor = TextEditingController();
|
var editor = TextEditingController();
|
||||||
editor.text = removeTrailingZeros(e.weight);
|
editor.text = removeTrailingZeros(e.weight);
|
||||||
editor.addListener(inputChangeListener);
|
editor.addListener(inputChangeListener);
|
||||||
cargoTypeControllers.add(editor);
|
cargoTypeControllers.add(editor);
|
||||||
}
|
}
|
||||||
|
_mixCargoTypes = allCargoes.where((e) => e.isMixCargo).toList();
|
||||||
|
for (var e in _mixCargoTypes) {
|
||||||
|
var editor = TextEditingController();
|
||||||
|
editor.text = removeTrailingZeros(e.weight);
|
||||||
|
editor.addListener(inputChangeListener);
|
||||||
|
mixCargoTypeControllers.add(editor);
|
||||||
|
}
|
||||||
_calculateTotalWeght();
|
_calculateTotalWeght();
|
||||||
} else {
|
} else {
|
||||||
var model = context.read<ShipmentRateModel>();
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
var cargoes = model.rate.cargoTypes.map((e) => e.clone()).toList();
|
_openCargoTypeSelection();
|
||||||
|
});
|
||||||
_cargoTypes = cargoes.where((e) => e.isDefault).toList();
|
|
||||||
// ignore: unused_local_variable
|
|
||||||
for (var e in _cargoTypes) {
|
|
||||||
var editor = TextEditingController();
|
|
||||||
editor.text = '';
|
|
||||||
editor.addListener(inputChangeListener);
|
|
||||||
cargoTypeControllers.add(editor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//for surcharge items
|
//for surcharge items
|
||||||
|
|
||||||
if (widget.surchargeItems.isNotEmpty) {
|
if (widget.surchargeItems.isNotEmpty) {
|
||||||
_surchareItems = List.from(widget.surchargeItems);
|
_surchareItems = List.from(widget.surchargeItems);
|
||||||
for (var e in _surchareItems) {
|
for (var e in _surchareItems) {
|
||||||
var editor = TextEditingController();
|
var editor = TextEditingController();
|
||||||
editor.text = e.qty.toString();
|
editor.text = e.qty.toString();
|
||||||
editor.addListener(inputChangeListener);
|
editor.addListener(inputChangeListenerForSurchage);
|
||||||
surchargeControllers.add(editor);
|
surchargeControllers.add(editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,38 +104,85 @@ class _CargoWidgetState extends State<CargoWidget> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_calculateTotalWeght() {
|
totalInputChangeListener() {
|
||||||
double total = _cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
print("Listen isKnownTotalWeight:$isKnownTotalWeight");
|
||||||
totalCtl.text = removeTrailingZeros(total);
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFieldEmpty(int index) {
|
inputChangeListenerForSurchage() {
|
||||||
return cargoTypeControllers[index].text.isEmpty;
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> getEmptyFields() {
|
_openCargoTypeSelection() async {
|
||||||
List<int> emptyFields = [];
|
List<CargoType>? cargoes = await showDialog(
|
||||||
for (int i = 0; i < cargoTypeControllers.length; i++) {
|
context: context, builder: (_) => const CargoTypeAdditionDialog());
|
||||||
if (isFieldEmpty(i)) {
|
if (cargoes == null) return;
|
||||||
emptyFields.add(i);
|
_cargoTypes = cargoes.where((e) => !e.isMixCargo).toList();
|
||||||
}
|
_mixCargoTypes = cargoes.where((e) => e.isMixCargo).toList();
|
||||||
|
|
||||||
|
for (var e in _cargoTypes) {
|
||||||
|
var editor = TextEditingController();
|
||||||
|
editor.text = '0';
|
||||||
|
editor.addListener(inputChangeListener);
|
||||||
|
cargoTypeControllers.add(editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var e in _mixCargoTypes) {
|
||||||
|
var editor = TextEditingController();
|
||||||
|
editor.text = '0';
|
||||||
|
editor.addListener(inputChangeListener);
|
||||||
|
mixCargoTypeControllers.add(editor);
|
||||||
|
}
|
||||||
|
_calculateTotalWeght();
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
}
|
}
|
||||||
return emptyFields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_calculateTotalWeght() {
|
||||||
|
print("_calculateTotalWeght isKnownTotalWeight:$isKnownTotalWeight");
|
||||||
|
double notMixTotal =
|
||||||
|
_cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
||||||
|
double mixTotal =
|
||||||
|
_mixCargoTypes.fold(0, (sum, value) => sum + value.weight);
|
||||||
|
double total = notMixTotal + mixTotal;
|
||||||
|
if (isKnownTotalWeight) {
|
||||||
|
} else {
|
||||||
|
totalCtl.text = removeTrailingZeros(total);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bool isFieldEmpty(int index) {
|
||||||
|
// return cargoTypeControllers[index].text.isEmpty;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// List<int> getEmptyFields() {
|
||||||
|
// List<int> emptyFields = [];
|
||||||
|
// for (int i = 0; i < cargoTypeControllers.length; i++) {
|
||||||
|
// if (isFieldEmpty(i)) {
|
||||||
|
// emptyFields.add(i);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return emptyFields;
|
||||||
|
// }
|
||||||
|
|
||||||
inputChangeListener() {
|
inputChangeListener() {
|
||||||
List<int> emptyFields = getEmptyFields();
|
_cargoTypes.asMap().entries.forEach((e) {
|
||||||
|
_cargoTypes[e.key].weight =
|
||||||
if (emptyFields.isEmpty) {
|
double.tryParse(cargoTypeControllers[e.key].text) ?? 0;
|
||||||
_cargoTypes.asMap().entries.forEach((e) {
|
});
|
||||||
_cargoTypes[e.key].weight =
|
_mixCargoTypes.asMap().entries.forEach((e) {
|
||||||
double.tryParse(cargoTypeControllers[e.key].text) ?? 0;
|
_mixCargoTypes[e.key].weight =
|
||||||
});
|
double.tryParse(mixCargoTypeControllers[e.key].text) ?? 0;
|
||||||
double total = _cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
});
|
||||||
setState(() {
|
double notMixTotal =
|
||||||
totalCtl.text = removeTrailingZeros(total);
|
_cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
||||||
});
|
double mixTotal =
|
||||||
}
|
_mixCargoTypes.fold(0, (sum, value) => sum + value.weight);
|
||||||
|
double total = notMixTotal + mixTotal;
|
||||||
|
setState(() {
|
||||||
|
totalCtl.text = removeTrailingZeros(total);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -163,23 +218,34 @@ class _CargoWidgetState extends State<CargoWidget> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
List<CargoType> allCargoTypes = _cargoTypes + _mixCargoTypes;
|
||||||
CargoType? cargoType = await Navigator.push(
|
CargoType? cargoType = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
CargoTypeAddition(cargoTypes: _cargoTypes)));
|
CargoTypeAddition(cargoTypes: allCargoTypes)));
|
||||||
if (cargoType == null) return;
|
if (cargoType == null) return;
|
||||||
_cargoTypes.add(cargoType);
|
if (cargoType.isMixCargo) {
|
||||||
|
_mixCargoTypes.add(cargoType);
|
||||||
|
mixCargoTypeControllers.clear();
|
||||||
|
|
||||||
cargoTypeControllers.clear();
|
for (var e in _mixCargoTypes) {
|
||||||
|
var editor = TextEditingController();
|
||||||
|
editor.text = removeTrailingZeros(e.weight);
|
||||||
|
editor.addListener(inputChangeListener);
|
||||||
|
mixCargoTypeControllers.add(editor);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_cargoTypes.add(cargoType);
|
||||||
|
cargoTypeControllers.clear();
|
||||||
|
|
||||||
for (var e in _cargoTypes) {
|
for (var e in _cargoTypes) {
|
||||||
var editor = TextEditingController();
|
var editor = TextEditingController();
|
||||||
editor.text = removeTrailingZeros(e.weight);
|
editor.text = removeTrailingZeros(e.weight);
|
||||||
editor.addListener(inputChangeListener);
|
editor.addListener(inputChangeListener);
|
||||||
cargoTypeControllers.add(editor);
|
cargoTypeControllers.add(editor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_calculateTotalWeght();
|
_calculateTotalWeght();
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@@ -187,44 +253,150 @@ class _CargoWidgetState extends State<CargoWidget> {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
final cargosBox = Wrap(
|
final cargosBox = Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 10),
|
||||||
|
child: Wrap(
|
||||||
|
alignment: WrapAlignment.spaceBetween,
|
||||||
|
runSpacing: 15,
|
||||||
|
children: _cargoTypes.asMap().entries.map((e) {
|
||||||
|
var key = e.key;
|
||||||
|
var c = e.value;
|
||||||
|
return SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width / 2.3,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
InkResponse(
|
||||||
|
radius: 23,
|
||||||
|
onTap: () {
|
||||||
|
_cargoTypes.removeAt(key);
|
||||||
|
|
||||||
|
double totalWeight =
|
||||||
|
double.tryParse(totalCtl.text) ?? 0;
|
||||||
|
double removeWeight =
|
||||||
|
(double.tryParse(cargoTypeControllers[key].text) ??
|
||||||
|
0);
|
||||||
|
|
||||||
|
if (totalWeight >= removeWeight) {
|
||||||
|
double result = totalWeight - removeWeight;
|
||||||
|
totalCtl.text = removeTrailingZeros(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
cargoTypeControllers[key].clear();
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Icon(Feather.minus_circle, color: labelColor)),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Flexible(
|
||||||
|
child: inputTextFieldWidget(context,
|
||||||
|
lableText: c.name ?? "",
|
||||||
|
controller: cargoTypeControllers[key],
|
||||||
|
suffixIcon: InkResponse(
|
||||||
|
radius: 23,
|
||||||
|
onTap: () {},
|
||||||
|
child: Icon(Ionicons.md_refresh_circle,
|
||||||
|
color: labelColor))),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList()),
|
||||||
|
);
|
||||||
|
|
||||||
|
final mixCargosBox = Wrap(
|
||||||
alignment: WrapAlignment.spaceBetween,
|
alignment: WrapAlignment.spaceBetween,
|
||||||
runSpacing: 15,
|
runSpacing: 15,
|
||||||
children: _cargoTypes.asMap().entries.map((e) {
|
children: _mixCargoTypes.asMap().entries.map((e) {
|
||||||
var key = e.key;
|
var key = e.key;
|
||||||
var c = e.value;
|
var c = e.value;
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: MediaQuery.of(context).size.width / 2.3,
|
width: MediaQuery.of(context).size.width / 2.3,
|
||||||
child: Row(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
InkResponse(
|
Row(
|
||||||
radius: 25,
|
children: [
|
||||||
onTap: () {
|
InkResponse(
|
||||||
_cargoTypes.removeAt(key);
|
radius: 23,
|
||||||
|
onTap: () {
|
||||||
|
_mixCargoTypes.removeAt(key);
|
||||||
|
|
||||||
double totalWeight = double.tryParse(totalCtl.text) ?? 0;
|
double totalWeight =
|
||||||
double removeWeight =
|
double.tryParse(totalCtl.text) ?? 0;
|
||||||
(double.tryParse(cargoTypeControllers[key].text) ??
|
double removeWeight = (double.tryParse(
|
||||||
|
mixCargoTypeControllers[key].text) ??
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (totalWeight >= removeWeight) {
|
if (totalWeight >= removeWeight) {
|
||||||
double result = totalWeight - removeWeight;
|
double result = totalWeight - removeWeight;
|
||||||
totalCtl.text = removeTrailingZeros(result);
|
totalCtl.text = removeTrailingZeros(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
cargoTypeControllers[key].clear();
|
mixCargoTypeControllers[key].clear();
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Icon(Feather.minus_circle, color: labelColor)),
|
child: Icon(Feather.minus_circle,
|
||||||
const SizedBox(width: 10),
|
color: labelColor, size: 20)),
|
||||||
Flexible(
|
const SizedBox(width: 10),
|
||||||
child: inputTextFieldWidget(context,
|
Flexible(
|
||||||
lableText: c.name ?? "",
|
child: inputTextFieldWidget(context,
|
||||||
controller: cargoTypeControllers[key]),
|
lableText: c.name ?? "",
|
||||||
|
controller: mixCargoTypeControllers[key],
|
||||||
|
suffixIcon: InkResponse(
|
||||||
|
radius: 23,
|
||||||
|
onTap: () {},
|
||||||
|
child: Icon(Ionicons.md_refresh_circle,
|
||||||
|
color: labelColor, size: 22))),
|
||||||
|
),
|
||||||
|
InkResponse(
|
||||||
|
radius: 23,
|
||||||
|
onTap: () async {
|
||||||
|
List<CargoType>? cargoes = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => MixCargoTypeAdditionDialog(
|
||||||
|
cargoTypes: c.mixCargoes));
|
||||||
|
if (cargoes == null) return;
|
||||||
|
setState(() {
|
||||||
|
c.mixCargoes = List.from(cargoes);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child:
|
||||||
|
Icon(Icons.add_circle, color: labelColor, size: 22))
|
||||||
|
],
|
||||||
),
|
),
|
||||||
|
c.mixCargoes.isEmpty
|
||||||
|
? const SizedBox()
|
||||||
|
: Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 5),
|
||||||
|
child: Column(
|
||||||
|
children: c.mixCargoes.map((e) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 12),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const SizedBox(width: 25),
|
||||||
|
InkResponse(
|
||||||
|
radius: 23,
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
c.mixCargoes.remove(e);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Icon(Feather.minus_circle,
|
||||||
|
color: labelColor, size: 20)),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 10),
|
||||||
|
child: Text(e.name ?? ""),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList()),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -250,28 +422,32 @@ class _CargoWidgetState extends State<CargoWidget> {
|
|||||||
child: inputTextFieldWidget(context,
|
child: inputTextFieldWidget(context,
|
||||||
lableText: "Total",
|
lableText: "Total",
|
||||||
controller: totalCtl,
|
controller: totalCtl,
|
||||||
readOnly: getEmptyFields().isEmpty, onChanged: (neValue) {
|
// onChanged: (neValue) {
|
||||||
List<int> emptyFields = getEmptyFields();
|
// List<int> emptyFields = getEmptyFields();
|
||||||
if (emptyFields.length == 1) {
|
// if (emptyFields.length == 1) {
|
||||||
double totalWeight = double.tryParse(neValue) ?? 0;
|
// double totalWeight = double.tryParse(neValue) ?? 0;
|
||||||
|
|
||||||
_cargoTypes.asMap().entries.forEach((e) {
|
// _cargoTypes.asMap().entries.forEach((e) {
|
||||||
_cargoTypes[e.key].weight =
|
// _cargoTypes[e.key].weight =
|
||||||
double.tryParse(cargoTypeControllers[e.key].text) ??
|
// double.tryParse(cargoTypeControllers[e.key].text) ??
|
||||||
0;
|
// 0;
|
||||||
});
|
// });
|
||||||
double result = _cargoTypes.fold(
|
// double result = _cargoTypes.fold(
|
||||||
0, (sum, value) => sum + value.weight);
|
// 0, (sum, value) => sum + value.weight);
|
||||||
|
|
||||||
if (totalWeight >= result) {
|
// if (totalWeight >= result) {
|
||||||
double remaining = totalWeight - result;
|
// double remaining = totalWeight - result;
|
||||||
setState(() {
|
// setState(() {
|
||||||
cargoTypeControllers[emptyFields.first].text =
|
// cargoTypeControllers[emptyFields.first].text =
|
||||||
removeTrailingZeros(remaining);
|
// removeTrailingZeros(remaining);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}),
|
// },
|
||||||
|
suffixIcon: InkResponse(
|
||||||
|
radius: 23,
|
||||||
|
child: Icon(Ionicons.md_refresh_circle,
|
||||||
|
color: labelColor))),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
@@ -308,41 +484,44 @@ class _CargoWidgetState extends State<CargoWidget> {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
final subChargeItemsBox = Wrap(
|
final subChargeItemsBox = Padding(
|
||||||
alignment: WrapAlignment.spaceBetween,
|
padding: const EdgeInsets.only(top: 10),
|
||||||
runSpacing: 15,
|
child: Wrap(
|
||||||
children: _surchareItems.asMap().entries.map((e) {
|
alignment: WrapAlignment.spaceBetween,
|
||||||
var key = e.key;
|
runSpacing: 15,
|
||||||
var c = e.value;
|
children: _surchareItems.asMap().entries.map((e) {
|
||||||
return SizedBox(
|
var key = e.key;
|
||||||
width: MediaQuery.of(context).size.width / 2.3,
|
var c = e.value;
|
||||||
child: Row(
|
return SizedBox(
|
||||||
children: [
|
width: MediaQuery.of(context).size.width / 2.3,
|
||||||
InkResponse(
|
child: Row(
|
||||||
radius: 25,
|
children: [
|
||||||
onTap: () {
|
InkResponse(
|
||||||
setState(() {
|
radius: 25,
|
||||||
_surchareItems.removeAt(key);
|
onTap: () {
|
||||||
});
|
setState(() {
|
||||||
},
|
_surchareItems.removeAt(key);
|
||||||
child: Icon(Feather.minus_circle, color: labelColor)),
|
});
|
||||||
const SizedBox(width: 10),
|
},
|
||||||
Flexible(
|
child: Icon(Feather.minus_circle, color: labelColor)),
|
||||||
child: inputTextFieldWidget(
|
const SizedBox(width: 10),
|
||||||
context,
|
Flexible(
|
||||||
lableText: c.name ?? "",
|
child: inputTextFieldWidget(
|
||||||
controller: surchargeControllers[key],
|
context,
|
||||||
onChanged: (newValue) {
|
lableText: c.name ?? "",
|
||||||
setState(() {
|
controller: surchargeControllers[key],
|
||||||
_surchareItems[key].qty = int.tryParse(newValue) ?? 0;
|
onChanged: (newValue) {
|
||||||
});
|
setState(() {
|
||||||
},
|
_surchareItems[key].qty = int.tryParse(newValue) ?? 0;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
}).toList()),
|
||||||
}).toList());
|
);
|
||||||
|
|
||||||
final continueBtn = ContinueButton(
|
final continueBtn = ContinueButton(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -354,14 +533,17 @@ class _CargoWidgetState extends State<CargoWidget> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.onContinue!(_cargoTypes, _surchareItems);
|
var allCargoes = _cargoTypes + _mixCargoTypes;
|
||||||
|
|
||||||
|
widget.onContinue!(allCargoes, _surchareItems);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
final previousBtn = PreviousButton(onTap: () {
|
final previousBtn = PreviousButton(onTap: () {
|
||||||
if (widget.onPrevious != null) {
|
if (widget.onPrevious != null) {
|
||||||
widget.onPrevious!(_cargoTypes, _surchareItems);
|
var allCargoes = _cargoTypes + _mixCargoTypes;
|
||||||
|
widget.onPrevious!(allCargoes, _surchareItems);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -376,9 +558,18 @@ class _CargoWidgetState extends State<CargoWidget> {
|
|||||||
userRow,
|
userRow,
|
||||||
cargoTitle,
|
cargoTitle,
|
||||||
cargosBox,
|
cargosBox,
|
||||||
const SizedBox(height: 15),
|
_mixCargoTypes.isNotEmpty && _cargoTypes.isNotEmpty
|
||||||
Divider(),
|
? Padding(
|
||||||
const SizedBox(height: 5),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 100, vertical: 25),
|
||||||
|
child: Divider(color: Colors.grey.shade300),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
mixCargosBox,
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 25),
|
||||||
|
child: Divider(color: Colors.grey.shade300),
|
||||||
|
),
|
||||||
totalWeightBox,
|
totalWeightBox,
|
||||||
subchargeItemTitleBox,
|
subchargeItemTitleBox,
|
||||||
subChargeItemsBox,
|
subChargeItemsBox,
|
||||||
@@ -408,7 +599,8 @@ class _CargoWidgetState extends State<CargoWidget> {
|
|||||||
{required String lableText,
|
{required String lableText,
|
||||||
TextEditingController? controller,
|
TextEditingController? controller,
|
||||||
Function(String)? onChanged,
|
Function(String)? onChanged,
|
||||||
bool readOnly = false}) {
|
bool readOnly = false,
|
||||||
|
Widget? suffixIcon}) {
|
||||||
return TextFormField(
|
return TextFormField(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
@@ -417,6 +609,7 @@ class _CargoWidgetState extends State<CargoWidget> {
|
|||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
suffixIcon: suffixIcon,
|
||||||
contentPadding: EdgeInsets.all(0),
|
contentPadding: EdgeInsets.all(0),
|
||||||
labelText: lableText,
|
labelText: lableText,
|
||||||
labelStyle: newLabelStyle(color: Colors.black54, fontSize: 17),
|
labelStyle: newLabelStyle(color: Colors.black54, fontSize: 17),
|
||||||
|
|||||||
@@ -295,18 +295,42 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||||
child: Container(
|
child: Container(
|
||||||
color: e.key.isEven ? Colors.grey.shade300 : oddColor,
|
color: e.key.isEven ? Colors.grey.shade300 : oddColor,
|
||||||
child: Row(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Row(
|
||||||
e.value.name ?? "",
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
style:
|
children: [
|
||||||
TextStyle(color: Colors.black, fontSize: 15),
|
Text(
|
||||||
|
e.value.name ?? "",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.black, fontSize: 15),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"${removeTrailingZeros(e.value.weight)} lb",
|
||||||
|
textAlign: TextAlign.end,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.black, fontSize: 15))
|
||||||
|
],
|
||||||
),
|
),
|
||||||
Text("${removeTrailingZeros(e.value.weight)} lb",
|
e.value.isMixCargo
|
||||||
textAlign: TextAlign.end,
|
? Padding(
|
||||||
style: TextStyle(
|
padding: const EdgeInsets.only(left: 20),
|
||||||
color: Colors.black, fontSize: 15))
|
child: Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: e.value.mixCargoes.map((c) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 2),
|
||||||
|
child: Text(
|
||||||
|
"- ${c.name}",
|
||||||
|
style: TextStyle(fontSize: 14),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList()),
|
||||||
|
)
|
||||||
|
: const SizedBox()
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ class _CartonPackageFormState extends State<CartonPackageForm> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_create() async {
|
_create() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
|
|||||||
134
lib/pages/carton/mix_cargo_type_addition_dialog.dart
Normal file
134
lib/pages/carton/mix_cargo_type_addition_dialog.dart
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../domain/entities/cargo_type.dart';
|
||||||
|
import '../../helpers/theme.dart';
|
||||||
|
import '../main/util.dart';
|
||||||
|
import '../rates/model/shipment_rate_model.dart';
|
||||||
|
import '../widgets/local_text.dart';
|
||||||
|
|
||||||
|
class MixCargoTypeAdditionDialog extends StatefulWidget {
|
||||||
|
final List<CargoType> cargoTypes;
|
||||||
|
const MixCargoTypeAdditionDialog({super.key, required this.cargoTypes});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MixCargoTypeAdditionDialog> createState() =>
|
||||||
|
_MixCargoTypeAdditionDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MixCargoTypeAdditionDialogState
|
||||||
|
extends State<MixCargoTypeAdditionDialog> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
List<CargoType> cargoTypes = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_init();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
_init() {
|
||||||
|
var shipmentRateModel =
|
||||||
|
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||||
|
var cargoes =
|
||||||
|
shipmentRateModel.rate.cargoTypes.map((e) => e.clone()).toList();
|
||||||
|
cargoTypes = cargoes.where((e) => !e.isMixCargo).toList();
|
||||||
|
|
||||||
|
for (var p in cargoTypes) {
|
||||||
|
if (widget.cargoTypes.any((e) => e.id == p.id)) {
|
||||||
|
p.isChecked = true;
|
||||||
|
} else {
|
||||||
|
p.isChecked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
title: Center(
|
||||||
|
child: LocalText(context, 'box.mix_cargo.title',
|
||||||
|
fontSize: 18, color: primaryColor, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
content: SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: EdgeInsets.only(top: 10),
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Column(
|
||||||
|
children: cargoTypes.map((p) {
|
||||||
|
return ListTile(
|
||||||
|
minTileHeight: 50,
|
||||||
|
minVerticalPadding: 0,
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
p.isChecked = !p.isChecked;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
title: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Checkbox(
|
||||||
|
value: p.isChecked,
|
||||||
|
activeColor: primaryColor,
|
||||||
|
side: BorderSide(color: Colors.black38, width: 2),
|
||||||
|
onChanged: (bool? value) {
|
||||||
|
if (value != null) {
|
||||||
|
setState(() {
|
||||||
|
p.isChecked = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
p.name ?? "",
|
||||||
|
style:
|
||||||
|
TextStyle(fontSize: 15.0, color: Colors.black),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: LocalText(context, 'btn.cancel',
|
||||||
|
color: labelColor, fontSize: 14),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
const SizedBox(width: 5),
|
||||||
|
TextButton(
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
minimumSize: Size(80, 35),
|
||||||
|
backgroundColor: primaryColor,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: LocalText(context, 'btn.add',
|
||||||
|
color: Colors.white, fontSize: 14),
|
||||||
|
onPressed: () async {
|
||||||
|
if (!_formKey.currentState!.validate()) return;
|
||||||
|
_save();
|
||||||
|
})
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_save() {
|
||||||
|
try {
|
||||||
|
var selectedCargos = cargoTypes.where((e) => e.isChecked).toList();
|
||||||
|
Navigator.pop<List<CargoType>>(context, selectedCargos);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -160,7 +160,7 @@ class PackageSelectionModel extends BaseModel {
|
|||||||
whereIn: [package_processed_status, package_packed_status])
|
whereIn: [package_processed_status, package_packed_status])
|
||||||
.where("sender_id", isEqualTo: senderId)
|
.where("sender_id", isEqualTo: senderId)
|
||||||
.where("user_id", isEqualTo: consigneeId)
|
.where("user_id", isEqualTo: consigneeId)
|
||||||
// .where("fcs_shipment_id", isEqualTo: shipmentId)
|
.where("fcs_shipment_id", isEqualTo: shipmentId)
|
||||||
.where("is_deleted", isEqualTo: false)
|
.where("is_deleted", isEqualTo: false)
|
||||||
.orderBy("created_date", descending: true)
|
.orderBy("created_date", descending: true)
|
||||||
.get(const GetOptions(source: Source.server));
|
.get(const GetOptions(source: Source.server));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import '../../domain/entities/package.dart';
|
|||||||
import '../../domain/entities/user.dart';
|
import '../../domain/entities/user.dart';
|
||||||
import '../main/util.dart';
|
import '../main/util.dart';
|
||||||
import '../widgets/continue_button.dart';
|
import '../widgets/continue_button.dart';
|
||||||
|
import '../widgets/local_text.dart';
|
||||||
import '../widgets/local_title.dart';
|
import '../widgets/local_title.dart';
|
||||||
import '../widgets/previous_button.dart';
|
import '../widgets/previous_button.dart';
|
||||||
import 'model/package_selection_model.dart';
|
import 'model/package_selection_model.dart';
|
||||||
@@ -41,6 +42,7 @@ class _PackagesWidgetState extends State<PackagesWidget> {
|
|||||||
final _scrollController = ScrollController();
|
final _scrollController = ScrollController();
|
||||||
bool _down = true;
|
bool _down = true;
|
||||||
List<Package> _packages = [];
|
List<Package> _packages = [];
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -56,12 +58,14 @@ class _PackagesWidgetState extends State<PackagesWidget> {
|
|||||||
|
|
||||||
_init() async {
|
_init() async {
|
||||||
_packages.clear();
|
_packages.clear();
|
||||||
|
_isLoading = true;
|
||||||
var packageModel = context.read<PackageSelectionModel>();
|
var packageModel = context.read<PackageSelectionModel>();
|
||||||
var list = await packageModel.getActivePackages(
|
var list = await packageModel.getActivePackages(
|
||||||
shipmentId: widget.shipment.id!,
|
shipmentId: widget.shipment.id!,
|
||||||
senderId: widget.sender.id!,
|
senderId: widget.sender.id!,
|
||||||
consigneeId: widget.consignee.id!);
|
consigneeId: widget.consignee.id!);
|
||||||
_packages = List.from(list);
|
_packages = List.from(list);
|
||||||
|
_isLoading = false;
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
@@ -93,6 +97,10 @@ class _PackagesWidgetState extends State<PackagesWidget> {
|
|||||||
|
|
||||||
final continueBtn = ContinueButton(
|
final continueBtn = ContinueButton(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
if (_packages.isEmpty) {
|
||||||
|
showMsgDialog(context, 'Error', "Please add the packages");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (widget.onContinue != null) {
|
if (widget.onContinue != null) {
|
||||||
widget.onContinue!(_packages);
|
widget.onContinue!(_packages);
|
||||||
}
|
}
|
||||||
@@ -135,21 +143,25 @@ class _PackagesWidgetState extends State<PackagesWidget> {
|
|||||||
: const SizedBox(),
|
: const SizedBox(),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: RefreshIndicator(
|
child: _packages.isEmpty && !_isLoading
|
||||||
color: primaryColor,
|
? Center(
|
||||||
onRefresh: () async {
|
child: LocalText(context, 'box.no_package',
|
||||||
_init();
|
color: Colors.black, fontSize: 15))
|
||||||
},
|
: RefreshIndicator(
|
||||||
child: ListView.builder(
|
color: primaryColor,
|
||||||
padding: const EdgeInsets.only(top: 10),
|
onRefresh: () async {
|
||||||
controller: _scrollController,
|
_init();
|
||||||
shrinkWrap: true,
|
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
Package package = _packages[index];
|
|
||||||
return packageRow(context, package);
|
|
||||||
},
|
},
|
||||||
itemCount: _packages.length)),
|
child: ListView.builder(
|
||||||
|
padding: const EdgeInsets.only(top: 10),
|
||||||
|
controller: _scrollController,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
Package package = _packages[index];
|
||||||
|
return packageRow(context, package);
|
||||||
|
},
|
||||||
|
itemCount: _packages.length)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class MessageDetail extends StatelessWidget {
|
|||||||
} else {
|
} else {
|
||||||
CustomerModel customerModel =
|
CustomerModel customerModel =
|
||||||
Provider.of<CustomerModel>(context, listen: false);
|
Provider.of<CustomerModel>(context, listen: false);
|
||||||
User user = await customerModel.getUser(message.messageID);
|
User? user = await customerModel.getUser(message.messageID);
|
||||||
Navigator.of(context).push(CupertinoPageRoute(
|
Navigator.of(context).push(CupertinoPageRoute(
|
||||||
builder: (context) => CustomerEditor(customer: user)));
|
builder: (context) => CustomerEditor(customer: user)));
|
||||||
}
|
}
|
||||||
|
|||||||
160
lib/pages/customer/customer_detail.dart
Normal file
160
lib/pages/customer/customer_detail.dart
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/customer/model/customer_model.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||||
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
import '../../domain/entities/user.dart';
|
||||||
|
import '../main/util.dart';
|
||||||
|
import '../widgets/display_text.dart';
|
||||||
|
import '../widgets/fcs_id_icon.dart';
|
||||||
|
|
||||||
|
class CustomerDetail extends StatefulWidget {
|
||||||
|
final String fcsId;
|
||||||
|
const CustomerDetail({super.key, required this.fcsId});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CustomerDetail> createState() => _CustomerDetailState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CustomerDetailState extends State<CustomerDetail> {
|
||||||
|
GlobalKey<ScaffoldMessengerState> key = GlobalKey<ScaffoldMessengerState>();
|
||||||
|
User? user;
|
||||||
|
bool _isLoading = false;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_loadUser();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
_loadUser() async {
|
||||||
|
try {
|
||||||
|
_isLoading = true;
|
||||||
|
user = await context.read<CustomerModel>().getUserByFCSId(widget.fcsId);
|
||||||
|
} finally {
|
||||||
|
_isLoading = false;
|
||||||
|
}
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final nameBox = DisplayText(
|
||||||
|
text: user?.name ?? '',
|
||||||
|
labelTextKey: "profile.name",
|
||||||
|
iconData: Icons.person,
|
||||||
|
);
|
||||||
|
|
||||||
|
final fcsIDBox = Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: DisplayText(
|
||||||
|
text: user?.fcsID ?? "",
|
||||||
|
labelTextKey: "customer.fcs.id",
|
||||||
|
icon: FcsIDIcon(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.content_copy, color: Colors.grey),
|
||||||
|
onPressed: () => _copy(
|
||||||
|
getLocalString(context, "customer.fcs.id"), user?.fcsID ?? ""),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
final phoneBox = Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: DisplayText(
|
||||||
|
text: user?.phoneNumber ?? "",
|
||||||
|
labelTextKey: "contact.phone",
|
||||||
|
iconData: FontAwesome.phone),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(MaterialIcons.open_in_new, color: Colors.grey),
|
||||||
|
onPressed: () {
|
||||||
|
if (user == null) return;
|
||||||
|
if (user!.phoneNumber != null && user!.phoneNumber != "") {
|
||||||
|
launch(
|
||||||
|
"tel:${user!.phoneNumber ?? "".trim().replaceAll(' ', '')}");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
final emailBox = Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 8),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: DisplayText(
|
||||||
|
text: user?.recoveryEmail ?? "",
|
||||||
|
labelTextKey: "profile.recovery.email",
|
||||||
|
iconData: Icons.email_outlined),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(MaterialIcons.open_in_new, color: Colors.grey),
|
||||||
|
onPressed: () {
|
||||||
|
if (user == null) return;
|
||||||
|
if (user!.recoveryEmail != null && user!.recoveryEmail != "") {
|
||||||
|
launch("mailto:${user?.recoveryEmail ?? ""}");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return LocalProgress(
|
||||||
|
inAsyncCall: _isLoading,
|
||||||
|
child: Scaffold(
|
||||||
|
key: key,
|
||||||
|
appBar: LocalAppBar(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
arrowColor: primaryColor,
|
||||||
|
labelColor: primaryColor,
|
||||||
|
labelKey: 'customer.detail.title'),
|
||||||
|
body: ListView(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10),
|
||||||
|
children: [
|
||||||
|
nameBox,
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
fcsIDBox,
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
phoneBox,
|
||||||
|
(user != null && user!.recoveryEmail != null && user!.recoveryEmail != "")
|
||||||
|
? emailBox
|
||||||
|
: const SizedBox()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_copy(String title, String data) {
|
||||||
|
Clipboard.setData(ClipboardData(text: data));
|
||||||
|
// showToast(key, 'copied "$title" data to clipboard');
|
||||||
|
_showToast(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
_showToast(String title) {
|
||||||
|
ScaffoldMessengerState? scaffold = key.currentState;
|
||||||
|
|
||||||
|
scaffold ??= ScaffoldMessenger.of(context);
|
||||||
|
|
||||||
|
scaffold.showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('copied "$title" data to clipboard'),
|
||||||
|
backgroundColor: secondaryColor,
|
||||||
|
duration: Duration(seconds: 1),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,7 +37,8 @@ class CustomerModel extends BaseModel {
|
|||||||
rowPerLoad: 30);
|
rowPerLoad: 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<User> getUser(String? id) async {
|
Future<User?> getUser(String? id) async {
|
||||||
|
if (id == null) return null;
|
||||||
String path = "/$user_collection";
|
String path = "/$user_collection";
|
||||||
var snap = await FirebaseFirestore.instance.collection(path).doc(id).get();
|
var snap = await FirebaseFirestore.instance.collection(path).doc(id).get();
|
||||||
return User.fromMap(snap.data() as Map<String, dynamic>, snap.id);
|
return User.fromMap(snap.data() as Map<String, dynamic>, snap.id);
|
||||||
@@ -76,4 +77,20 @@ class CustomerModel extends BaseModel {
|
|||||||
Future<void> acceptRequest(String userID) {
|
Future<void> acceptRequest(String userID) {
|
||||||
return Services.instance.userService.acceptRequest(userID);
|
return Services.instance.userService.acceptRequest(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<User?> getUserByFCSId(String? fcsID) async {
|
||||||
|
if (fcsID == null) return null;
|
||||||
|
String path = "/$user_collection";
|
||||||
|
var snap = await FirebaseFirestore.instance
|
||||||
|
.collection(path)
|
||||||
|
.where('fcs_id', isEqualTo: fcsID)
|
||||||
|
.limit(1)
|
||||||
|
.get();
|
||||||
|
|
||||||
|
if (snap.docs.isNotEmpty) {
|
||||||
|
return User.fromMap(snap.docs.first.data(), snap.docs.first.id);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,11 @@ class _HomePageState extends State<HomePage> {
|
|||||||
if (!isCustomer) {
|
if (!isCustomer) {
|
||||||
CustomerModel customerModel =
|
CustomerModel customerModel =
|
||||||
Provider.of<CustomerModel>(context, listen: false);
|
Provider.of<CustomerModel>(context, listen: false);
|
||||||
user = await customerModel.getUser(receiverID);
|
|
||||||
|
var u = await customerModel.getUser(receiverID);
|
||||||
|
if (u != null) {
|
||||||
|
user = u;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -5,11 +5,14 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
import 'package:fcs/pages/main/model/language_model.dart';
|
import 'package:fcs/pages/main/model/language_model.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
import '../customer/customer_detail.dart';
|
||||||
import '../widgets/label_widgets.dart';
|
import '../widgets/label_widgets.dart';
|
||||||
|
|
||||||
final log = Logger('Util');
|
final log = Logger('Util');
|
||||||
@@ -494,7 +497,15 @@ Widget userDisplayBox(BuildContext context,
|
|||||||
LocalText(context, lableKey,
|
LocalText(context, lableKey,
|
||||||
color: Colors.black54, fontSize: 15),
|
color: Colors.black54, fontSize: 15),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: null,
|
onTap: showLink
|
||||||
|
? () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
CustomerDetail(fcsId: fcsID)));
|
||||||
|
}
|
||||||
|
: null,
|
||||||
child: Text(name ?? '',
|
child: Text(name ?? '',
|
||||||
style: showLink
|
style: showLink
|
||||||
? TextStyle(
|
? TextStyle(
|
||||||
@@ -518,3 +529,36 @@ Widget userDisplayBox(BuildContext context,
|
|||||||
)
|
)
|
||||||
: const SizedBox();
|
: const SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget settingRow(BuildContext context,
|
||||||
|
{required String label,
|
||||||
|
IconData? iconData,
|
||||||
|
Widget? image,
|
||||||
|
Function()? onTap,
|
||||||
|
String? text}) {
|
||||||
|
return ListTile(
|
||||||
|
minTileHeight: 50,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
onTap: onTap,
|
||||||
|
leading: iconData != null
|
||||||
|
? Icon(iconData, color: primaryColor)
|
||||||
|
: image ?? const SizedBox(),
|
||||||
|
title: LocalText(context, label, fontSize: 15, color: Colors.black54),
|
||||||
|
subtitle: text != null
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 10),
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
trailing: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(SimpleLineIcons.arrow_right, color: labelColor, size: 16),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -276,11 +276,6 @@ class PackageModel extends BaseModel {
|
|||||||
return pkgs.where((e) => seen.add(e)).toList();
|
return pkgs.where((e) => seen.add(e)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> createPackages(User user, List<Package> packages) {
|
|
||||||
return Services.instance.packageService
|
|
||||||
.createPackages(packages, user.fcsID!);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> createReceiving(
|
Future<void> createReceiving(
|
||||||
User? user, Package package, List<File?>? files) async {
|
User? user, Package package, List<File?>? files) async {
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
@@ -364,14 +359,15 @@ class PackageModel extends BaseModel {
|
|||||||
var count =
|
var count =
|
||||||
(package.photoUrls.length) + files.length - (deletedUrls.length);
|
(package.photoUrls.length) + files.length - (deletedUrls.length);
|
||||||
|
|
||||||
if (count > uploadPhotoLimit)
|
if (count > uploadPhotoLimit) {
|
||||||
throw Exception("Exceed number of file upload");
|
throw Exception("Exceed number of file upload");
|
||||||
|
}
|
||||||
package.photoUrls = package.photoUrls;
|
package.photoUrls = package.photoUrls;
|
||||||
String path = Path.join(pkg_files_path);
|
String path = Path.join(pkg_files_path);
|
||||||
uploadedURL = await uploadFiles(path, files);
|
uploadedURL = await uploadFiles(path, files);
|
||||||
uploadedURL.forEach((url) {
|
for (var url in uploadedURL) {
|
||||||
package.photoUrls.add(url);
|
package.photoUrls.add(url);
|
||||||
});
|
}
|
||||||
package.photoUrls.removeWhere((e) => deletedUrls.contains(e));
|
package.photoUrls.removeWhere((e) => deletedUrls.contains(e));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -70,10 +70,10 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_loadShipment() async {
|
_loadShipment() async {
|
||||||
if (widget.package.shipmentId == null) return;
|
if (widget.package.fcsShipmentId == null) return;
|
||||||
var s = await context
|
var s = await context
|
||||||
.read<FcsShipmentModel>()
|
.read<FcsShipmentModel>()
|
||||||
.getFcsShipment(widget.package.shipmentId!);
|
.getFcsShipment(widget.package.fcsShipmentId!);
|
||||||
_shipment = s;
|
_shipment = s;
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@@ -178,17 +178,17 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
iconData: Ionicons.ios_airplane,
|
iconData: Ionicons.ios_airplane,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Flexible(
|
// Flexible(
|
||||||
child: DisplayText(
|
// child: DisplayText(
|
||||||
text: _shipment != null
|
// text: _shipment != null
|
||||||
? _shipment!.processingDate != null
|
// ? _shipment!.processingDate != null
|
||||||
? dateFormatter.format(_shipment!.processingDate!)
|
// ? dateFormatter.format(_shipment!.processingDate!)
|
||||||
: ""
|
// : ""
|
||||||
: "",
|
// : "",
|
||||||
labelTextKey: "package.processing.date",
|
// labelTextKey: "package.processing.date",
|
||||||
iconData: Icons.date_range,
|
// iconData: Icons.date_range,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
@@ -1,208 +0,0 @@
|
|||||||
import 'package:fcs/domain/entities/package.dart';
|
|
||||||
import 'package:fcs/domain/entities/user.dart';
|
|
||||||
import 'package:fcs/helpers/theme.dart';
|
|
||||||
import 'package:fcs/pages/package/tracking_id_page.dart';
|
|
||||||
import 'package:fcs/pages/user_search/user_search.dart';
|
|
||||||
import 'package:fcs/pages/main/util.dart';
|
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
|
||||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import 'model/package_model.dart';
|
|
||||||
|
|
||||||
typedef void FindCallBack();
|
|
||||||
|
|
||||||
class PackageNew extends StatefulWidget {
|
|
||||||
const PackageNew();
|
|
||||||
@override
|
|
||||||
_PackageNewState createState() => _PackageNewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _PackageNewState extends State<PackageNew> {
|
|
||||||
bool _isLoading = false;
|
|
||||||
User? user;
|
|
||||||
|
|
||||||
List<Package> packages = [];
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
var fcsIDBox = Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: DisplayText(
|
|
||||||
text: user != null ? user!.fcsID : "",
|
|
||||||
labelTextKey: "package.create.fcs.id",
|
|
||||||
icon: FcsIDIcon(),
|
|
||||||
)),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.search, color: primaryColor),
|
|
||||||
onPressed: () => searchUser(context, onUserSelect: (u) {
|
|
||||||
setState(() {
|
|
||||||
this.user = u;
|
|
||||||
});
|
|
||||||
})),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
final namebox = DisplayText(
|
|
||||||
text: user != null ? user!.name : "",
|
|
||||||
labelTextKey: "package.create.name",
|
|
||||||
iconData: Icons.person,
|
|
||||||
);
|
|
||||||
final phoneNumberBox = DisplayText(
|
|
||||||
text: user != null ? user!.phoneNumber : "",
|
|
||||||
labelTextKey: "package.create.phone",
|
|
||||||
iconData: Icons.phone,
|
|
||||||
);
|
|
||||||
final createButton = fcsButton(
|
|
||||||
context,
|
|
||||||
getLocalString(context, 'package.create.packages'),
|
|
||||||
callack: _create,
|
|
||||||
);
|
|
||||||
final packageList = Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: new List.generate(
|
|
||||||
this.packages.length, (index) => _packageItem(context, index))
|
|
||||||
.toList(),
|
|
||||||
);
|
|
||||||
|
|
||||||
return LocalProgress(
|
|
||||||
inAsyncCall: _isLoading,
|
|
||||||
child: Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
centerTitle: true,
|
|
||||||
leading: new IconButton(
|
|
||||||
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
),
|
|
||||||
shadowColor: Colors.transparent,
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
title: LocalText(
|
|
||||||
context,
|
|
||||||
"package.create.title",
|
|
||||||
fontSize: 20,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
body: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 12.0, right: 12),
|
|
||||||
child: ListView(
|
|
||||||
children: <Widget>[
|
|
||||||
fcsIDBox,
|
|
||||||
phoneNumberBox,
|
|
||||||
namebox,
|
|
||||||
Divider(),
|
|
||||||
Center(
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Text("Packages (${packages.length})"),
|
|
||||||
SizedBox(
|
|
||||||
width: 30,
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
onPressed: _addPackage,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
packageList,
|
|
||||||
Divider(),
|
|
||||||
SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
createButton,
|
|
||||||
SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _packageItem(BuildContext context, int index) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 8.0, left: 15),
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(packages[index].market!),
|
|
||||||
Text(packages[index].trackingID!),
|
|
||||||
// DisplayText(
|
|
||||||
// labelText: "Tracking ID",
|
|
||||||
// text: packages[index].trackingID,
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.remove,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
packages.removeAt(index);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_addPackage() async {
|
|
||||||
Package? package = await Navigator.push<Package>(
|
|
||||||
context,
|
|
||||||
CupertinoPageRoute(builder: (context) => TrackingIDPage()),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (package != null) {
|
|
||||||
if (packages.any((e) => e.trackingID == package.trackingID)) {
|
|
||||||
showMsgDialog(context, "Error", "Already scanned!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setState(() {
|
|
||||||
packages.add(package);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_create() async {
|
|
||||||
if (user == null || packages.length == 0) {
|
|
||||||
showMsgDialog(context, "Error", "Invalid user!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
PackageModel packageModel =
|
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
|
||||||
try {
|
|
||||||
await packageModel.createPackages(user!, packages);
|
|
||||||
Navigator.pop(context);
|
|
||||||
} catch (e) {
|
|
||||||
showMsgDialog(context, "Error", e.toString());
|
|
||||||
} finally {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -253,6 +253,7 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
_package!.photoFiles = multiImgController.getUpdatedFile;
|
_package!.photoFiles = multiImgController.getUpdatedFile;
|
||||||
_package!.fcsID = widget.consignee.fcsID;
|
_package!.fcsID = widget.consignee.fcsID;
|
||||||
_package!.senderFCSID = widget.sender.fcsID ?? "";
|
_package!.senderFCSID = widget.sender.fcsID ?? "";
|
||||||
|
_package!.fcsShipmentId = widget.shipment.id;
|
||||||
|
|
||||||
await packageModel.updateProcessing(_package!,
|
await packageModel.updateProcessing(_package!,
|
||||||
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
var fcsShipments =
|
var fcsShipments =
|
||||||
await context.read<FcsShipmentModel>().getActiveFcsShipments();
|
await context.read<FcsShipmentModel>().getActiveFcsShipments();
|
||||||
_shipments = fcsShipments;
|
_shipments = fcsShipments;
|
||||||
|
|
||||||
var s = FcsShipment(
|
var s = FcsShipment(
|
||||||
id: widget.package.id, shipmentNumber: widget.package.shipmentNumber);
|
id: widget.package.fcsShipmentId, shipmentNumber: widget.package.fcsShipmentNumber);
|
||||||
|
|
||||||
if (_shipments.contains(s)) {
|
if (_shipments.contains(s)) {
|
||||||
_shipment = s;
|
_shipment = s;
|
||||||
@@ -290,9 +290,10 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
_package!.desc = _descCtl.text;
|
_package!.desc = _descCtl.text;
|
||||||
_package!.remark = _remarkCtl.text;
|
_package!.remark = _remarkCtl.text;
|
||||||
_package!.market = selectedMarket ?? "";
|
_package!.market = selectedMarket ?? "";
|
||||||
|
_package!.fcsShipmentId = _shipment?.id;
|
||||||
await packageModel.updateProcessing(_package!,
|
await packageModel.updateProcessing(_package!,
|
||||||
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context,true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
@@ -310,7 +311,7 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
desc: _descCtl.text,
|
desc: _descCtl.text,
|
||||||
remark: _remarkCtl.text,
|
remark: _remarkCtl.text,
|
||||||
photoUrls: widget.package.photoUrls,
|
photoUrls: widget.package.photoUrls,
|
||||||
shipmentId: _shipment?.id);
|
fcsShipmentId: _shipment?.id);
|
||||||
return widget.package.isChangedForEditProcessing(package) ||
|
return widget.package.isChangedForEditProcessing(package) ||
|
||||||
multiImgController.getAddedFile.isNotEmpty ||
|
multiImgController.getAddedFile.isNotEmpty ||
|
||||||
multiImgController.getDeletedUrl.isNotEmpty;
|
multiImgController.getDeletedUrl.isNotEmpty;
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_initPackage(widget.package);
|
_initPackage(widget.package);
|
||||||
_loadShipment();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_initPackage(Package package) {
|
_initPackage(Package package) {
|
||||||
|
_loadShipment();
|
||||||
setState(() {
|
setState(() {
|
||||||
_package = package;
|
_package = package;
|
||||||
multiImgController.setImageUrls = package.photoUrls;
|
multiImgController.setImageUrls = package.photoUrls;
|
||||||
@@ -51,10 +51,10 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_loadShipment() async {
|
_loadShipment() async {
|
||||||
if (widget.package.shipmentId == null) return;
|
if (widget.package.fcsShipmentId == null) return;
|
||||||
var s = await context
|
var s = await context
|
||||||
.read<FcsShipmentModel>()
|
.read<FcsShipmentModel>()
|
||||||
.getFcsShipment(widget.package.shipmentId!);
|
.getFcsShipment(widget.package.fcsShipmentId!);
|
||||||
_shipment = s;
|
_shipment = s;
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@@ -123,17 +123,17 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
iconData: Ionicons.ios_airplane,
|
iconData: Ionicons.ios_airplane,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Flexible(
|
// Flexible(
|
||||||
child: DisplayText(
|
// child: DisplayText(
|
||||||
text: _shipment != null
|
// text: _shipment != null
|
||||||
? _shipment!.processingDate != null
|
// ? _shipment!.processingDate != null
|
||||||
? dateFormatter.format(_shipment!.processingDate!)
|
// ? dateFormatter.format(_shipment!.processingDate!)
|
||||||
: ""
|
// : ""
|
||||||
: "",
|
// : "",
|
||||||
labelTextKey: "package.processing.date",
|
// labelTextKey: "package.processing.date",
|
||||||
iconData: Icons.date_range,
|
// iconData: Icons.date_range,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
@@ -241,13 +241,11 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
|
|
||||||
_gotoEditor() async {
|
_gotoEditor() async {
|
||||||
if (_package == null) return;
|
if (_package == null) return;
|
||||||
bool? deleted = await Navigator.push<bool>(
|
bool? updated = await Navigator.push<bool>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => ProcessingEditEditor(package: _package!)));
|
builder: (context) => ProcessingEditEditor(package: _package!)));
|
||||||
if (deleted ?? false) {
|
if (updated ?? false) {
|
||||||
Navigator.pop(context);
|
|
||||||
} else {
|
|
||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
Package? p = await packageModel.getPackage(_package!.id!);
|
Package? p = await packageModel.getPackage(_package!.id!);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class _AddRecoveryEmailState extends State<AddRecoveryEmail> {
|
|||||||
padding: const EdgeInsets.only(left: 15, right: 15, top: 10),
|
padding: const EdgeInsets.only(left: 15, right: 15, top: 10),
|
||||||
children: [
|
children: [
|
||||||
LocalText(context, 'profile.email_instruction',
|
LocalText(context, 'profile.email_instruction',
|
||||||
fontSize: 16, color: Colors.black),
|
fontSize: 16, color: labelColor),
|
||||||
const SizedBox(height: 15),
|
const SizedBox(height: 15),
|
||||||
emailBox,
|
emailBox,
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class _ConfirmPhoneNumberState extends State<ConfirmPhoneNumber> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child: LocalText(context, "sms.six.digit",
|
child: LocalText(context, "profile.confirm.instruction",
|
||||||
fontSize: 16, color: labelColor),
|
fontSize: 16, color: labelColor),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class _ConfirmRecoveryEmailState extends State<ConfirmRecoveryEmail> {
|
|||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
LocalText(context, "sms.code",
|
LocalText(context, "profile.confirm_email_code",
|
||||||
color: labelColor, fontSize: 16),
|
color: labelColor, fontSize: 16),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.only(top: 10),
|
padding: const EdgeInsets.only(top: 10),
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:fcs/domain/entities/user.dart';
|
|||||||
import 'package:fcs/domain/vo/privilege.dart';
|
import 'package:fcs/domain/vo/privilege.dart';
|
||||||
import 'package:fcs/localization/transalation.dart';
|
import 'package:fcs/localization/transalation.dart';
|
||||||
import 'package:fcs/pages/delivery_address/delivery_address_list.dart';
|
import 'package:fcs/pages/delivery_address/delivery_address_list.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/delivery_address_row.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/language_model.dart';
|
import 'package:fcs/pages/main/model/language_model.dart';
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
@@ -9,7 +10,6 @@ import 'package:fcs/pages/main/util.dart';
|
|||||||
import 'package:fcs/pages/profile/profile_currency_edit.dart';
|
import 'package:fcs/pages/profile/profile_currency_edit.dart';
|
||||||
import 'package:fcs/pages/profile/profile_edit.dart';
|
import 'package:fcs/pages/profile/profile_edit.dart';
|
||||||
import 'package:fcs/pages/staff/model/staff_model.dart';
|
import 'package:fcs/pages/staff/model/staff_model.dart';
|
||||||
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||||
@@ -78,112 +78,110 @@ class _ProfileState extends State<Profile> {
|
|||||||
buildLanguage(languageModel);
|
buildLanguage(languageModel);
|
||||||
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
||||||
|
|
||||||
final currencyBox = Row(
|
final currencyBox = settingRow(
|
||||||
children: <Widget>[
|
context,
|
||||||
Expanded(
|
label: 'profile.currency',
|
||||||
|
iconData: FontAwesome5Solid.money_bill_wave,
|
||||||
|
text: user.preferCurrency ?? "",
|
||||||
|
onTap: () {
|
||||||
|
_editCurrency();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
final fcsIDBox = Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: user.preferCurrency ?? "",
|
text: user.fcsID ?? "",
|
||||||
labelTextKey: "profile.currency",
|
labelTextKey: "customer.fcs.id",
|
||||||
iconData: FontAwesome5Regular.money_bill_alt,
|
icon: FcsIDIcon(),
|
||||||
)),
|
),
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 0),
|
|
||||||
child: IconButton(
|
|
||||||
icon: Icon(Icons.edit, color: Colors.grey),
|
|
||||||
onPressed: _editCurrency),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
final deleteAccountBox = DisplayText(
|
|
||||||
labelTextKey: "profile.delete.title",
|
|
||||||
iconData: MaterialCommunityIcons.account_remove,
|
|
||||||
);
|
|
||||||
|
|
||||||
final fcsIDBox = Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: DisplayText(
|
|
||||||
text: user.fcsID ?? "",
|
|
||||||
labelTextKey: "customer.fcs.id",
|
|
||||||
icon: FcsIDIcon(),
|
|
||||||
),
|
),
|
||||||
),
|
IconButton(
|
||||||
IconButton(
|
icon: Icon(Icons.content_copy, color: Colors.grey),
|
||||||
icon: Icon(Icons.content_copy, color: Colors.grey),
|
onPressed: () => _copy(
|
||||||
onPressed: () => _copy(
|
getLocalString(context, "customer.fcs.id"), user.fcsID ?? ""),
|
||||||
getLocalString(context, "customer.fcs.id"), user.fcsID ?? ""),
|
)
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final usaShippingAddressBox = Row(
|
final usaShippingAddressBox = Padding(
|
||||||
children: [
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
Expanded(
|
child: Row(
|
||||||
child: DisplayText(
|
children: [
|
||||||
text: mainModel.setting!.usaAddress ?? "",
|
Expanded(
|
||||||
labelTextKey: "profile.usa.shipping.address",
|
child: DisplayText(
|
||||||
iconData: Icons.location_on,
|
text: mainModel.setting!.usaAddress ?? "",
|
||||||
|
labelTextKey: "profile.usa.shipping.address",
|
||||||
|
iconData: Icons.location_on,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
IconButton(
|
||||||
IconButton(
|
icon: Icon(Icons.content_copy, color: Colors.grey),
|
||||||
icon: Icon(Icons.content_copy, color: Colors.grey),
|
onPressed: () => _copy(
|
||||||
onPressed: () => _copy(
|
getLocalString(context, "profile.usa.shipping.address"),
|
||||||
getLocalString(context, "profile.usa.shipping.address"),
|
mainModel.setting!.usaAddress ?? ""),
|
||||||
mainModel.setting!.usaAddress ?? ""),
|
)
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final logoutbutton =
|
final logoutbutton = Padding(
|
||||||
fcsButton(context, getLocalString(context, "profile.logout"),
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
callack: mainModel.isPinLogin
|
child: fcsButton(context, getLocalString(context, "profile.logout"),
|
||||||
? null
|
callack: mainModel.isPinLogin
|
||||||
: () {
|
? null
|
||||||
showConfirmDialog(context, "profile.logout.confirm",
|
: () {
|
||||||
() async {
|
showConfirmDialog(context, "profile.logout.confirm",
|
||||||
await _logout();
|
() async {
|
||||||
});
|
await _logout();
|
||||||
},
|
});
|
||||||
iconData: Icons.exit_to_app);
|
},
|
||||||
|
iconData: Icons.exit_to_app),
|
||||||
|
);
|
||||||
|
|
||||||
final emailBox = Row(
|
final recoveryEmailBox = settingRow(
|
||||||
children: [
|
context,
|
||||||
Expanded(
|
label: 'profile.recovery.email',
|
||||||
child: DisplayText(
|
iconData: Icons.email_outlined,
|
||||||
text: user.recoveryEmail,
|
text: user.recoveryEmail,
|
||||||
labelTextKey: "profile.recovery.email",
|
onTap: () {
|
||||||
iconData: Icons.email_outlined,
|
Navigator.of(context, rootNavigator: true).push(CupertinoPageRoute(
|
||||||
),
|
builder: (context) => AddRecoveryEmail(user: user)));
|
||||||
),
|
},
|
||||||
IconButton(
|
);
|
||||||
icon: Icon(Icons.edit, color: Colors.grey),
|
|
||||||
onPressed: () {
|
final phoneNumberBox = settingRow(
|
||||||
Navigator.of(context, rootNavigator: true).push(
|
context,
|
||||||
CupertinoPageRoute(
|
label: 'profile.change.phone',
|
||||||
builder: (context) => AddRecoveryEmail(user: user)));
|
iconData: Icons.phone,
|
||||||
})
|
onTap: () {
|
||||||
],
|
Navigator.of(context, rootNavigator: true).push(CupertinoPageRoute(
|
||||||
|
builder: (context) => ChangePhoneNumber(user: user)));
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
final titleBox = Column(
|
final titleBox = Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
user.name ?? "",
|
user.name ?? "",
|
||||||
style: TextStyle(fontSize: 18, color: Colors.black),
|
style: TextStyle(fontSize: 18, color: Colors.black),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 5),
|
const SizedBox(width: 5),
|
||||||
InkResponse(
|
InkResponse(
|
||||||
radius: 20,
|
radius: 20,
|
||||||
onTap: _editName,
|
onTap: _editName,
|
||||||
child: Icon(Icons.edit, color: Colors.grey, size: 23))
|
child: Icon(Icons.edit, color: Colors.grey, size: 23))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 1),
|
const SizedBox(height: 1),
|
||||||
Text(
|
Text(
|
||||||
user.phone,
|
user.phone,
|
||||||
@@ -192,60 +190,79 @@ class _ProfileState extends State<Profile> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final deleteAccountBox = settingRow(
|
||||||
|
context,
|
||||||
|
label: 'profile.delete.title',
|
||||||
|
iconData: MaterialCommunityIcons.account_remove,
|
||||||
|
onTap: () {
|
||||||
|
_editDelete();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
final deliverAddressBox = Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 5),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
settingRow(
|
||||||
|
context,
|
||||||
|
label: 'profile.default.delivery.address',
|
||||||
|
iconData: MaterialCommunityIcons.truck_fast,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => DeliveryAddressList()));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 35),
|
||||||
|
child: DeliveryAddressRow(
|
||||||
|
key: ValueKey(deliveryAddressModel.defalutAddress.id),
|
||||||
|
deliveryAddress: deliveryAddressModel.defalutAddress),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
key: key,
|
key: key,
|
||||||
appBar: LocalAppBar(
|
appBar: LocalAppBar(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
labelColor: primaryColor,
|
labelColor: primaryColor,
|
||||||
arrowColor: primaryColor,
|
arrowColor: primaryColor,
|
||||||
titleWidget: titleBox
|
titleWidget: titleBox),
|
||||||
),
|
body: ListView(
|
||||||
body: Padding(
|
children: <Widget>[
|
||||||
padding: const EdgeInsets.all(8.0),
|
const SizedBox(height: 5),
|
||||||
child: ListView(
|
fcsIDBox,
|
||||||
children: <Widget>[
|
usaShippingAddressBox,
|
||||||
const SizedBox(height: 5),
|
currencyBox,
|
||||||
fcsIDBox,
|
deliverAddressBox,
|
||||||
usaShippingAddressBox,
|
// recoveryEmailBox,
|
||||||
currencyBox,
|
// Padding(
|
||||||
// emailBox,
|
// padding: const EdgeInsets.symmetric(horizontal: 100,),
|
||||||
DefaultDeliveryAddress(
|
// child: Divider(thickness: 2),
|
||||||
labelKey: "profile.default.delivery.address",
|
// ),
|
||||||
deliveryAddress: deliveryAddressModel.defalutAddress,
|
// phoneNumberBox,
|
||||||
onTap: () {
|
buildLanguageWidget(
|
||||||
Navigator.push(
|
context: context,
|
||||||
context,
|
text: "profile.language",
|
||||||
CupertinoPageRoute(
|
iconData: Icons.language,
|
||||||
builder: (context) => DeliveryAddressList()));
|
isEng: languageModel.isEng,
|
||||||
},
|
),
|
||||||
),
|
deleteAccountBox,
|
||||||
buildLanguageWidget(
|
// Padding(
|
||||||
context: context,
|
// padding: const EdgeInsets.symmetric(horizontal: 100,),
|
||||||
text: "profile.language",
|
// child: Divider(thickness: 2),
|
||||||
iconData: Icons.language,
|
// ),
|
||||||
isEng: languageModel.isEng,
|
getPrivilegeBox(context),
|
||||||
),
|
SizedBox(height: 15),
|
||||||
Row(
|
logoutbutton,
|
||||||
children: <Widget>[
|
SizedBox(height: 30)
|
||||||
Expanded(
|
],
|
||||||
child: deleteAccountBox,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 0),
|
|
||||||
child: IconButton(
|
|
||||||
icon: Icon(Icons.edit, color: Colors.grey),
|
|
||||||
onPressed: _editDelete),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
getPrivilegeBox(context),
|
|
||||||
SizedBox(height: 15),
|
|
||||||
logoutbutton,
|
|
||||||
SizedBox(height: 25)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -256,53 +273,56 @@ class _ProfileState extends State<Profile> {
|
|||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
IconData? iconData,
|
IconData? iconData,
|
||||||
required bool isEng}) {
|
required bool isEng}) {
|
||||||
return Row(
|
return Padding(
|
||||||
children: <Widget>[
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
Icon(iconData, color: primaryColor),
|
child: Row(
|
||||||
const SizedBox(width: 15),
|
children: <Widget>[
|
||||||
Expanded(
|
Icon(iconData, color: primaryColor),
|
||||||
child: LocalText(
|
const SizedBox(width: 15),
|
||||||
context,
|
Expanded(
|
||||||
text,
|
child: LocalText(
|
||||||
fontSize: 15.0,
|
context,
|
||||||
color: Colors.black54,
|
text,
|
||||||
|
fontSize: 15.0,
|
||||||
|
color: Colors.black54,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Row(
|
||||||
Row(
|
children: [
|
||||||
children: [
|
isEng
|
||||||
isEng
|
? Image.asset(
|
||||||
? Image.asset(
|
'icons/flags/png100px/us.png',
|
||||||
'icons/flags/png100px/us.png',
|
package: 'country_icons',
|
||||||
package: 'country_icons',
|
fit: BoxFit.fitWidth,
|
||||||
fit: BoxFit.fitWidth,
|
width: 25,
|
||||||
width: 25,
|
)
|
||||||
)
|
: Image.asset(
|
||||||
: Image.asset(
|
'icons/flags/png100px/mm.png',
|
||||||
'icons/flags/png100px/mm.png',
|
package: 'country_icons',
|
||||||
package: 'country_icons',
|
fit: BoxFit.fitWidth,
|
||||||
fit: BoxFit.fitWidth,
|
width: 25,
|
||||||
width: 25,
|
),
|
||||||
),
|
Container(
|
||||||
Container(
|
width: 100,
|
||||||
width: 100,
|
padding: const EdgeInsets.only(left: 15),
|
||||||
padding: const EdgeInsets.only(left: 15),
|
child: DropdownButton(
|
||||||
child: DropdownButton(
|
value: selectedLanguage,
|
||||||
value: selectedLanguage,
|
underline: const SizedBox(),
|
||||||
underline: const SizedBox(),
|
isExpanded: true,
|
||||||
isExpanded: true,
|
items: languagesList
|
||||||
items: languagesList
|
.map<DropdownMenuItem<String>>((String value) {
|
||||||
.map<DropdownMenuItem<String>>((String value) {
|
return DropdownMenuItem<String>(
|
||||||
return DropdownMenuItem<String>(
|
value: value,
|
||||||
value: value,
|
child: Text(
|
||||||
child: Text(
|
value,
|
||||||
value,
|
style: const TextStyle(fontSize: 14),
|
||||||
style: const TextStyle(fontSize: 14),
|
));
|
||||||
));
|
}).toList(),
|
||||||
}).toList(),
|
onChanged: _selectedDropdown)),
|
||||||
onChanged: _selectedDropdown)),
|
],
|
||||||
],
|
)
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,19 +352,22 @@ class _ProfileState extends State<Profile> {
|
|||||||
|
|
||||||
return privileges.isEmpty
|
return privileges.isEmpty
|
||||||
? const SizedBox()
|
? const SizedBox()
|
||||||
: Column(
|
: Padding(
|
||||||
children: <Widget>[
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
DisplayText(
|
child: Column(
|
||||||
labelTextKey: "profile.privileges",
|
children: <Widget>[
|
||||||
iconData: MaterialCommunityIcons.clipboard_check_outline,
|
DisplayText(
|
||||||
),
|
labelTextKey: "profile.privileges",
|
||||||
Padding(
|
iconData: MaterialCommunityIcons.clipboard_check_outline,
|
||||||
padding: const EdgeInsets.only(left: 30.0),
|
),
|
||||||
child: Column(
|
Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: const EdgeInsets.only(left: 30.0),
|
||||||
children: getRowPrivilegeWidget(privileges)),
|
child: Column(
|
||||||
)
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
],
|
children: getRowPrivilegeWidget(privileges)),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,9 +391,9 @@ class _ProfileState extends State<Profile> {
|
|||||||
children: [
|
children: [
|
||||||
Text("${p.name}",
|
Text("${p.name}",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16.0,
|
fontSize: 15.0,
|
||||||
fontStyle: FontStyle.normal,
|
fontStyle: FontStyle.normal,
|
||||||
color: primaryColor)),
|
color: Colors.black)),
|
||||||
Text(
|
Text(
|
||||||
"${p.desc}",
|
"${p.desc}",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|||||||
Reference in New Issue
Block a user