fix profile
This commit is contained in:
@@ -109,7 +109,6 @@
|
|||||||
"user.fcs_id":"MY FCS_ID",
|
"user.fcs_id":"MY FCS_ID",
|
||||||
"user.shipping_address":"USA SHIPPING ADDRESS",
|
"user.shipping_address":"USA SHIPPING ADDRESS",
|
||||||
"user.deliveryAddress":"My delivery address",
|
"user.deliveryAddress":"My delivery address",
|
||||||
"user.form.shipping_address":"ADDRESS",
|
|
||||||
"User End ================================================================":"",
|
"User End ================================================================":"",
|
||||||
|
|
||||||
"Customer Start ================================================================":"",
|
"Customer Start ================================================================":"",
|
||||||
@@ -142,15 +141,17 @@
|
|||||||
"Profile Start ================================================================":"",
|
"Profile Start ================================================================":"",
|
||||||
"profile.title": "My Profile",
|
"profile.title": "My Profile",
|
||||||
"profile.edit_title": "Edit My Profile",
|
"profile.edit_title": "Edit My Profile",
|
||||||
|
"profile.edit.currency.title":"Preferred Currency",
|
||||||
"profile.name": "Name",
|
"profile.name": "Name",
|
||||||
"profile.phone": "Phone",
|
"profile.phone": "Phone",
|
||||||
"profile.language": "Languages",
|
"profile.language": "Languages",
|
||||||
"profile.logout": "logout",
|
"profile.logout": "logout",
|
||||||
|
"profile.currency":"Preferred Currency",
|
||||||
"profile.usa.shipping.address": "USA Shipping Address",
|
"profile.usa.shipping.address": "USA Shipping Address",
|
||||||
"profile.logout.confirm":"Are you sure want to logout?",
|
"profile.logout.confirm":"Are you sure want to logout?",
|
||||||
"profile.devices":"Devices",
|
"profile.devices":"Devices",
|
||||||
"profile.email":"Email",
|
"profile.email":"Email",
|
||||||
"profile.privilege":"Privilege",
|
"profile.privileges":"Privileges",
|
||||||
"Profile End ================================================================":"",
|
"Profile End ================================================================":"",
|
||||||
|
|
||||||
"Package Start ================================================================":"",
|
"Package Start ================================================================":"",
|
||||||
@@ -375,6 +376,7 @@
|
|||||||
"delivery_address.update": "Update Delivery Address",
|
"delivery_address.update": "Update Delivery Address",
|
||||||
"delivery_address.new_address":"Add New\nAddress",
|
"delivery_address.new_address":"Add New\nAddress",
|
||||||
"delivery_address.change_address": "Change Address",
|
"delivery_address.change_address": "Change Address",
|
||||||
|
"delivery_address.delete.confirm":"Delete this Delivery Address?",
|
||||||
"delivery_addresses End ================================================================":"",
|
"delivery_addresses End ================================================================":"",
|
||||||
|
|
||||||
"Receiving Start ================================================================":"",
|
"Receiving Start ================================================================":"",
|
||||||
@@ -386,6 +388,7 @@
|
|||||||
"receiving.name":"Customer Name",
|
"receiving.name":"Customer Name",
|
||||||
"receiving.phone":"Phone Number",
|
"receiving.phone":"Phone Number",
|
||||||
"receiving.create_btn":"Complete receiving",
|
"receiving.create_btn":"Complete receiving",
|
||||||
|
"receiving.delete.confirm":"Delete this receiving?",
|
||||||
"Receiving End ================================================================":"",
|
"Receiving End ================================================================":"",
|
||||||
|
|
||||||
"Processing Start ================================================================":"",
|
"Processing Start ================================================================":"",
|
||||||
|
|||||||
@@ -109,7 +109,6 @@
|
|||||||
"user.fcs_id":"My FCS_ID",
|
"user.fcs_id":"My FCS_ID",
|
||||||
"user.shipping_address":"My USA shipping address",
|
"user.shipping_address":"My USA shipping address",
|
||||||
"user.deliveryAddress":"My delivery address",
|
"user.deliveryAddress":"My delivery address",
|
||||||
"user.form.shipping_address":"ကုန်ပစ္စည်းပို့ဆောင်ရမည့်လိပ်စာ",
|
|
||||||
"User End ================================================================":"",
|
"User End ================================================================":"",
|
||||||
|
|
||||||
"Customer Start ================================================================":"",
|
"Customer Start ================================================================":"",
|
||||||
@@ -142,15 +141,17 @@
|
|||||||
"Profile Start ================================================================":"",
|
"Profile Start ================================================================":"",
|
||||||
"profile.title":"ကျွန်ုပ် ပရိုဖိုင်",
|
"profile.title":"ကျွန်ုပ် ပရိုဖိုင်",
|
||||||
"profile.edit_title":"ကျွန်ုပ် ပရိုဖိုင်ကိုပြုပြင်ရန်",
|
"profile.edit_title":"ကျွန်ုပ် ပရိုဖိုင်ကိုပြုပြင်ရန်",
|
||||||
|
"profile.edit.currency.title":"နှစ်သက်သော ငွေအမျိုးအစား",
|
||||||
"profile.name":"နာမည်",
|
"profile.name":"နာမည်",
|
||||||
"profile.phone": "ဖုန်းနံပါတ်",
|
"profile.phone": "ဖုန်းနံပါတ်",
|
||||||
"profile.language": "ဘာသာစကားများ",
|
"profile.language": "ဘာသာစကားများ",
|
||||||
"profile.logout": "အကောင့်ထွက်ရန်",
|
"profile.logout": "အကောင့်ထွက်ရန်",
|
||||||
"profile.usa.shipping.address": "အမေရိကား ပစည်းပို့ရန်လိပ်စာ",
|
"profile.currency":"နှစ်သက်သော ငွေအမျိုးအစား",
|
||||||
|
"profile.usa.shipping.address": "အမေရိကား ပစ္စည်းပို့ရန်လိပ်စာ",
|
||||||
"profile.logout.confirm":"အကောင့်ထွက်ရန်သေချာပြီလား?",
|
"profile.logout.confirm":"အကောင့်ထွက်ရန်သေချာပြီလား?",
|
||||||
"profile.devices":"ဖုန်းမော်ဒယ်အမျိုးအစားများ",
|
"profile.devices":"ဖုန်းမော်ဒယ်အမျိုးအစားများ",
|
||||||
"profile.email":"အီးမေးလ်",
|
"profile.email":"အီးမေးလ်",
|
||||||
"profile.privilege":"လုပ်ပိုင်ခွင့်",
|
"profile.privileges":"လုပ်ပိုင်ခွင့်များ",
|
||||||
"Profile End ================================================================":"",
|
"Profile End ================================================================":"",
|
||||||
|
|
||||||
"Package Start ================================================================":"",
|
"Package Start ================================================================":"",
|
||||||
@@ -375,6 +376,7 @@
|
|||||||
"delivery_address.update": "ပြုပြင်ရန်",
|
"delivery_address.update": "ပြုပြင်ရန်",
|
||||||
"delivery_address.new_address":"လိပ်စာအသစ်",
|
"delivery_address.new_address":"လိပ်စာအသစ်",
|
||||||
"delivery_address.change_address": "လိပ်စာပြောင်းပါ",
|
"delivery_address.change_address": "လိပ်စာပြောင်းပါ",
|
||||||
|
"delivery_address.delete.confirm":"ပို့ဆောင်ရမည့်လိပ်စာကို ဖျက်မလား?",
|
||||||
"delivery_addresses End ================================================================":"",
|
"delivery_addresses End ================================================================":"",
|
||||||
|
|
||||||
"Receiving Start ================================================================":"",
|
"Receiving Start ================================================================":"",
|
||||||
@@ -386,6 +388,7 @@
|
|||||||
"receiving.name":"နာမည်",
|
"receiving.name":"နာမည်",
|
||||||
"receiving.phone":"ဖုန်းနံပါတ်",
|
"receiving.phone":"ဖုန်းနံပါတ်",
|
||||||
"receiving.create_btn":"လက်ခံမည်",
|
"receiving.create_btn":"လက်ခံမည်",
|
||||||
|
"receiving.delete.confirm":"လက်ခံခြင်းကို ဖျက်မလား?",
|
||||||
"Receiving End ================================================================":"",
|
"Receiving End ================================================================":"",
|
||||||
|
|
||||||
"Processing Start ================================================================":"",
|
"Processing Start ================================================================":"",
|
||||||
|
|||||||
@@ -182,11 +182,16 @@ class AuthFb {
|
|||||||
return invited["invited"];
|
return invited["invited"];
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateProfile(String newUserName) async {
|
Future<void> updateProfileName(String newUserName) async {
|
||||||
return await requestAPI("/profile", "PUT",
|
return await requestAPI("/profile", "PUT",
|
||||||
payload: {"user_name": newUserName}, token: await getToken());
|
payload: {"user_name": newUserName}, token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> updatePreferredCurrency(String currency) async {
|
||||||
|
return await requestAPI("/currency", "PUT",
|
||||||
|
payload: {"preferred_currency": currency}, token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
Future<String> getToken() async {
|
Future<String> getToken() async {
|
||||||
FirebaseUser firebaseUser = await _fb.currentUser();
|
FirebaseUser firebaseUser = await _fb.currentUser();
|
||||||
IdTokenResult token = await firebaseUser.getIdToken();
|
IdTokenResult token = await firebaseUser.getIdToken();
|
||||||
|
|||||||
@@ -21,4 +21,10 @@ class DeliveryAddressDataProvider {
|
|||||||
return await requestAPI("/delivery_address", "DELETE",
|
return await requestAPI("/delivery_address", "DELETE",
|
||||||
payload: deliveryAddress.toMap(), token: await getToken());
|
payload: deliveryAddress.toMap(), token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> selectDefalutDeliveryAddress(
|
||||||
|
DeliveryAddress deliveryAddress) async {
|
||||||
|
return await requestAPI("/delivery_address/defalut", "PUT",
|
||||||
|
payload: deliveryAddress.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,13 @@ class PackageDataProvider {
|
|||||||
payload: {"packages": json, "fcs_id": fcsID}, token: await getToken());
|
payload: {"packages": json, "fcs_id": fcsID}, token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> createPackage(Package package) async {
|
||||||
|
return await requestAPI("/package", "POST",
|
||||||
|
payload: package.toJson(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> deletePackage(Package package) async {
|
Future<void> deletePackage(Package package) async {
|
||||||
return await requestAPI("/packages", "DELETE",
|
return await requestAPI("/package", "DELETE",
|
||||||
payload: {"id": package.id}, token: await getToken());
|
payload: {"id": package.id}, token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,12 @@ class AuthServiceImp implements AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> updateProfile(String newUserName) {
|
Future<void> updateProfileName(String newUserName) {
|
||||||
return authFb.updateProfile(newUserName);
|
return authFb.updateProfileName(newUserName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updatePreferredCurrency(String currency) {
|
||||||
|
return authFb.updatePreferredCurrency(currency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ abstract class AuthService {
|
|||||||
Future<void> signout();
|
Future<void> signout();
|
||||||
Future<void> signup(String userName);
|
Future<void> signup(String userName);
|
||||||
Future<User> joinInvite(String userName);
|
Future<User> joinInvite(String userName);
|
||||||
Future<void> updateProfile(String newUserName);
|
Future<void> updateProfileName(String newUserName);
|
||||||
|
Future<void> updatePreferredCurrency(String currency);
|
||||||
Future<bool> hasInvite();
|
Future<bool> hasInvite();
|
||||||
Stream<User> getUserStream();
|
Stream<User> getUserStream();
|
||||||
Stream<Setting> getSetting();
|
Stream<Setting> getSetting();
|
||||||
|
|||||||
@@ -28,4 +28,10 @@ class DeliveryAddressImp implements DeliveryAddressService {
|
|||||||
Future<void> deleteDeliveryAddress(DeliveryAddress deliveryAddress) {
|
Future<void> deleteDeliveryAddress(DeliveryAddress deliveryAddress) {
|
||||||
return deliveryAddressDataProvider.deleteDeliveryAddress(deliveryAddress);
|
return deliveryAddressDataProvider.deleteDeliveryAddress(deliveryAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> selectDefalutDeliveryAddress(DeliveryAddress deliveryAddress) {
|
||||||
|
return deliveryAddressDataProvider
|
||||||
|
.selectDefalutDeliveryAddress(deliveryAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ abstract class DeliveryAddressService {
|
|||||||
Future<void> createDeliveryAddress(DeliveryAddress deliveryAddress);
|
Future<void> createDeliveryAddress(DeliveryAddress deliveryAddress);
|
||||||
Future<void> updateDeliveryAddress(DeliveryAddress deliveryAddress);
|
Future<void> updateDeliveryAddress(DeliveryAddress deliveryAddress);
|
||||||
Future<void> deleteDeliveryAddress(DeliveryAddress deliveryAddress);
|
Future<void> deleteDeliveryAddress(DeliveryAddress deliveryAddress);
|
||||||
|
Future<void> selectDefalutDeliveryAddress(DeliveryAddress deliveryAddress);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ class PackageServiceImp implements PackageService {
|
|||||||
return packageDataProvider.createPackages(packages, fcsID);
|
return packageDataProvider.createPackages(packages, fcsID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> createPackage(Package package) {
|
||||||
|
return packageDataProvider.createPackage(package);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<Package>> searchPackage(String term) {
|
Future<List<Package>> searchPackage(String term) {
|
||||||
return packageDataProvider.searchPackage(term);
|
return packageDataProvider.searchPackage(term);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:fcs/domain/entities/package.dart';
|
|||||||
|
|
||||||
abstract class PackageService {
|
abstract class PackageService {
|
||||||
Future<void> createPackages(List<Package> packages, String fcsID);
|
Future<void> createPackages(List<Package> packages, String fcsID);
|
||||||
|
Future<void> createPackage(Package package);
|
||||||
Future<void> deletePackage(Package package);
|
Future<void> deletePackage(Package package);
|
||||||
Future<List<Package>> searchPackage(String term);
|
Future<List<Package>> searchPackage(String term);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,3 +26,24 @@ const message_type_profile = "t_profile";
|
|||||||
const fcs_shipment_confirmed_status = "confirmed";
|
const fcs_shipment_confirmed_status = "confirmed";
|
||||||
const fcs_shipment_shipped_status = "shipped";
|
const fcs_shipment_shipped_status = "shipped";
|
||||||
const fcs_shipment_delivered_status = "delivered";
|
const fcs_shipment_delivered_status = "delivered";
|
||||||
|
|
||||||
|
// Package status
|
||||||
|
const package_received_status = "received";
|
||||||
|
const package_processed_status = "processed";
|
||||||
|
const package_packed_status = "packed";
|
||||||
|
const package_shipped_status = "shipped";
|
||||||
|
const package_delivered_status = "delivered";
|
||||||
|
|
||||||
|
// Privileges
|
||||||
|
const privilege_admin = "admin";
|
||||||
|
const privilege_support = "sp";
|
||||||
|
const privilege_package = "pkg";
|
||||||
|
const privilege_shipment = "sh";
|
||||||
|
const privilege_fcs_shipment = "fsh";
|
||||||
|
const privilege_staff = "st";
|
||||||
|
const privilege_carton = "ca";
|
||||||
|
const privilege_customer = "cu";
|
||||||
|
const privilege_delivery = "deli";
|
||||||
|
const privilege_invoice = "inv";
|
||||||
|
const privilege_processing = "pr";
|
||||||
|
const privilege_receiving = "rc";
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
class Role {
|
|
||||||
String roleID;
|
|
||||||
String roleName;
|
|
||||||
String privileges;
|
|
||||||
Role({this.roleName, this.roleID, this.privileges});
|
|
||||||
|
|
||||||
Role.fromJson(Map<String, dynamic> json) {
|
|
||||||
roleName = json['role_name'];
|
|
||||||
roleID = json['role_id'];
|
|
||||||
privileges = json['privileges'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Parser {
|
|
||||||
String status;
|
|
||||||
String message;
|
|
||||||
Role data;
|
|
||||||
Parser({this.status, this.message, this.data});
|
|
||||||
|
|
||||||
Parser.fromJson(Map<String, dynamic> json) {
|
|
||||||
status = json['status'];
|
|
||||||
message = json['message'];
|
|
||||||
if (json['status'] == 'Ok') {
|
|
||||||
data = Role.fromJson(json['data']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class StatusParser {
|
|
||||||
String status;
|
|
||||||
String message;
|
|
||||||
StatusParser(this.status, this.message);
|
|
||||||
|
|
||||||
StatusParser.fromJson(Map<String, dynamic> json) {
|
|
||||||
status = json['status'];
|
|
||||||
message = json['message'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Privilege {
|
|
||||||
String id;
|
|
||||||
String name;
|
|
||||||
String desc;
|
|
||||||
bool sysAdminOnly = true;
|
|
||||||
bool isChecked = false;
|
|
||||||
|
|
||||||
Privilege({this.id, this.name, this.desc, this.isChecked, this.sysAdminOnly});
|
|
||||||
|
|
||||||
factory Privilege.fromMap(Map<String, dynamic> map, String docID) {
|
|
||||||
return Privilege(
|
|
||||||
id: docID,
|
|
||||||
name: map['name'],
|
|
||||||
desc: map['desc'],
|
|
||||||
sysAdminOnly: map['sys_admin_only']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class UserLevel {
|
|
||||||
String id;
|
|
||||||
String name;
|
|
||||||
int level;
|
|
||||||
UserLevel({this.id, this.name, this.level});
|
|
||||||
|
|
||||||
factory UserLevel.fromMap(Map<String, dynamic> map, String docID) {
|
|
||||||
return UserLevel(id: docID, name: map['name'], level: map['level']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,6 +17,7 @@ class User {
|
|||||||
String lastMessage;
|
String lastMessage;
|
||||||
int userUnseenCount;
|
int userUnseenCount;
|
||||||
int fcsUnseenCount;
|
int fcsUnseenCount;
|
||||||
|
String preferCurrency;
|
||||||
|
|
||||||
String get initial => name != null && name != "" ? name.substring(0, 1) : "?";
|
String get initial => name != null && name != "" ? name.substring(0, 1) : "?";
|
||||||
|
|
||||||
@@ -64,7 +65,8 @@ class User {
|
|||||||
this.lastMessage,
|
this.lastMessage,
|
||||||
this.lastMessageTime,
|
this.lastMessageTime,
|
||||||
this.userUnseenCount,
|
this.userUnseenCount,
|
||||||
this.fcsUnseenCount});
|
this.fcsUnseenCount,
|
||||||
|
this.preferCurrency});
|
||||||
|
|
||||||
factory User.fromJson(Map<String, dynamic> json) {
|
factory User.fromJson(Map<String, dynamic> json) {
|
||||||
return User(
|
return User(
|
||||||
@@ -106,6 +108,7 @@ class User {
|
|||||||
lastMessage: map['last_message'],
|
lastMessage: map['last_message'],
|
||||||
userUnseenCount: map['user_unseen_count'],
|
userUnseenCount: map['user_unseen_count'],
|
||||||
fcsUnseenCount: map['fcs_unseen_count'],
|
fcsUnseenCount: map['fcs_unseen_count'],
|
||||||
|
preferCurrency: map['preferred_currency'],
|
||||||
lastMessageTime: _date == null ? null : _date.toDate());
|
lastMessageTime: _date == null ? null : _date.toDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ class DeliveryAddress {
|
|||||||
String addressLine2;
|
String addressLine2;
|
||||||
String city;
|
String city;
|
||||||
String state;
|
String state;
|
||||||
String country;
|
|
||||||
String phoneNumber;
|
String phoneNumber;
|
||||||
|
bool isDefault;
|
||||||
DeliveryAddress(
|
DeliveryAddress(
|
||||||
{this.id,
|
{this.id,
|
||||||
this.fullName,
|
this.fullName,
|
||||||
@@ -14,8 +14,8 @@ class DeliveryAddress {
|
|||||||
this.addressLine2,
|
this.addressLine2,
|
||||||
this.city,
|
this.city,
|
||||||
this.state,
|
this.state,
|
||||||
this.country,
|
this.phoneNumber,
|
||||||
this.phoneNumber});
|
this.isDefault = false});
|
||||||
|
|
||||||
factory DeliveryAddress.fromMap(Map<String, dynamic> map, String docID) {
|
factory DeliveryAddress.fromMap(Map<String, dynamic> map, String docID) {
|
||||||
return DeliveryAddress(
|
return DeliveryAddress(
|
||||||
@@ -25,8 +25,8 @@ class DeliveryAddress {
|
|||||||
addressLine2: map['address_line2'],
|
addressLine2: map['address_line2'],
|
||||||
city: map['city'],
|
city: map['city'],
|
||||||
state: map['state'],
|
state: map['state'],
|
||||||
country: map['country'],
|
|
||||||
phoneNumber: map['phone_number'],
|
phoneNumber: map['phone_number'],
|
||||||
|
isDefault: map['is_defalut'] ?? false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,6 @@ class DeliveryAddress {
|
|||||||
'city': city,
|
'city': city,
|
||||||
'state': state,
|
'state': state,
|
||||||
'phone_number': phoneNumber,
|
'phone_number': phoneNumber,
|
||||||
'country': country,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
54
lib/domain/vo/privilege.dart
Normal file
54
lib/domain/vo/privilege.dart
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import 'package:fcs/domain/constants.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
|
class Privilege {
|
||||||
|
String id;
|
||||||
|
String name;
|
||||||
|
String desc;
|
||||||
|
bool sysAdminOnly = true;
|
||||||
|
bool isChecked = false;
|
||||||
|
|
||||||
|
IconData iconData;
|
||||||
|
|
||||||
|
Privilege(
|
||||||
|
{this.id, this.name, this.desc, this.isChecked, this.sysAdminOnly}) {
|
||||||
|
if (this.id == privilege_admin) {
|
||||||
|
iconData = MaterialCommunityIcons.account_tie;
|
||||||
|
} else if (this.id == privilege_support) {
|
||||||
|
iconData = SimpleLineIcons.support;
|
||||||
|
} else if (this.id == privilege_package) {
|
||||||
|
iconData = Octicons.package;
|
||||||
|
} else if (this.id == privilege_shipment) {
|
||||||
|
iconData = SimpleLineIcons.direction;
|
||||||
|
} else if (this.id == privilege_fcs_shipment) {
|
||||||
|
iconData = Ionicons.ios_airplane;
|
||||||
|
} else if (this.id == privilege_staff) {
|
||||||
|
iconData = MaterialCommunityIcons.worker;
|
||||||
|
} else if (this.id == privilege_carton) {
|
||||||
|
iconData = MaterialCommunityIcons.package;
|
||||||
|
} else if (this.id == privilege_customer) {
|
||||||
|
iconData = Feather.users;
|
||||||
|
} else if (this.id == privilege_delivery) {
|
||||||
|
iconData = MaterialCommunityIcons.truck_fast;
|
||||||
|
} else if (this.id == privilege_invoice) {
|
||||||
|
iconData = FontAwesomeIcons.fileInvoice;
|
||||||
|
} else if (this.id == privilege_processing) {
|
||||||
|
iconData = FontAwesome.dropbox;
|
||||||
|
} else if (this.id == privilege_receiving) {
|
||||||
|
iconData = MaterialCommunityIcons.inbox_arrow_down;
|
||||||
|
} else {
|
||||||
|
iconData = MaterialCommunityIcons.account_question;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
factory Privilege.fromMap(Map<String, dynamic> map, String docID) {
|
||||||
|
return Privilege(
|
||||||
|
id: docID,
|
||||||
|
name: map['name'],
|
||||||
|
desc: map['desc'],
|
||||||
|
sysAdminOnly: map['sys_admin_only']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -570,7 +570,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
DeliveryAddressRow(shippingAddress: _deliveryAddress),
|
DeliveryAddressRow(deliveryAddress: _deliveryAddress),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||||
child: Align(
|
child: Align(
|
||||||
@@ -659,7 +659,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
return addresses.asMap().entries.map((s) {
|
return addresses.asMap().entries.map((s) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
child: DeliveryAddressRow(shippingAddress: s.value, index: s.key),
|
child: DeliveryAddressRow(deliveryAddress: s.value),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,25 +23,28 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
|||||||
TextEditingController _address2Controller = new TextEditingController();
|
TextEditingController _address2Controller = new TextEditingController();
|
||||||
TextEditingController _cityController = new TextEditingController();
|
TextEditingController _cityController = new TextEditingController();
|
||||||
TextEditingController _stateController = new TextEditingController();
|
TextEditingController _stateController = new TextEditingController();
|
||||||
TextEditingController _countryController = new TextEditingController();
|
|
||||||
TextEditingController _phoneController = new TextEditingController();
|
TextEditingController _phoneController = new TextEditingController();
|
||||||
|
|
||||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
bool _isNew = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (widget.deliveryAddress != null) {
|
if (widget.deliveryAddress != null) {
|
||||||
|
_isNew = false;
|
||||||
_deliveryAddress = widget.deliveryAddress;
|
_deliveryAddress = widget.deliveryAddress;
|
||||||
_nameController.text = _deliveryAddress.fullName;
|
_nameController.text = _deliveryAddress.fullName;
|
||||||
_address1Controller.text = _deliveryAddress.addressLine1;
|
_address1Controller.text = _deliveryAddress.addressLine1;
|
||||||
_address2Controller.text = _deliveryAddress.addressLine2;
|
_address2Controller.text = _deliveryAddress.addressLine2;
|
||||||
_cityController.text = _deliveryAddress.city;
|
_cityController.text = _deliveryAddress.city;
|
||||||
_stateController.text = _deliveryAddress.state;
|
_stateController.text = _deliveryAddress.state;
|
||||||
_countryController.text = _deliveryAddress.country;
|
|
||||||
_phoneController.text = _deliveryAddress.phoneNumber;
|
_phoneController.text = _deliveryAddress.phoneNumber;
|
||||||
|
} else {
|
||||||
|
_cityController.text = "Yangon";
|
||||||
|
_stateController.text = "Yangon";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,9 +55,9 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final usaAddress = InputText(
|
final fullName = InputText(
|
||||||
labelTextKey: 'delivery_address.full_name',
|
labelTextKey: 'delivery_address.full_name',
|
||||||
iconData: Icons.text_format,
|
iconData: MaterialCommunityIcons.account_arrow_left,
|
||||||
controller: _nameController);
|
controller: _nameController);
|
||||||
|
|
||||||
final addressLine1 = InputText(
|
final addressLine1 = InputText(
|
||||||
@@ -77,14 +80,10 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
|||||||
iconData: Entypo.location,
|
iconData: Entypo.location,
|
||||||
controller: _stateController);
|
controller: _stateController);
|
||||||
|
|
||||||
final countryBox = InputText(
|
|
||||||
labelTextKey: 'delivery_address.country',
|
|
||||||
iconData: Entypo.flag,
|
|
||||||
controller: _countryController);
|
|
||||||
|
|
||||||
final phoneNumberBox = InputText(
|
final phoneNumberBox = InputText(
|
||||||
labelTextKey: 'delivery_address.phonenumber',
|
labelTextKey: 'delivery_address.phonenumber',
|
||||||
iconData: Icons.phone,
|
iconData: Icons.phone,
|
||||||
|
textInputType: TextInputType.phone,
|
||||||
controller: _phoneController);
|
controller: _phoneController);
|
||||||
|
|
||||||
final createBtn = fcsButton(
|
final createBtn = fcsButton(
|
||||||
@@ -100,52 +99,43 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(Icons.close),
|
icon: new Icon(Icons.close),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
backgroundColor: primaryColor,
|
||||||
|
title: LocalText(
|
||||||
|
context,
|
||||||
|
'delivery_address',
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 20,
|
||||||
|
),
|
||||||
|
actions: [IconButton(icon: Icon(Icons.delete), onPressed: _delete)],
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
body: Padding(
|
||||||
title: LocalText(
|
padding: const EdgeInsets.only(left: 10.0, right: 10),
|
||||||
context,
|
child: ListView(children: <Widget>[
|
||||||
'user.form.shipping_address',
|
fullName,
|
||||||
color: Colors.white,
|
SizedBox(height: 5),
|
||||||
fontSize: 20,
|
phoneNumberBox,
|
||||||
),
|
SizedBox(height: 10),
|
||||||
),
|
addressLine1,
|
||||||
body: Card(
|
SizedBox(height: 5),
|
||||||
child: Column(
|
addressLine2,
|
||||||
children: <Widget>[
|
SizedBox(height: 5),
|
||||||
Expanded(
|
cityBox,
|
||||||
child: Padding(
|
SizedBox(height: 5),
|
||||||
padding: const EdgeInsets.only(left: 10.0, right: 10),
|
regionBox,
|
||||||
child: ListView(children: <Widget>[
|
SizedBox(height: 5),
|
||||||
usaAddress,
|
_isNew ? createBtn : updateBtn,
|
||||||
SizedBox(height: 5),
|
|
||||||
addressLine1,
|
|
||||||
SizedBox(height: 5),
|
|
||||||
addressLine2,
|
|
||||||
SizedBox(height: 5),
|
|
||||||
cityBox,
|
|
||||||
SizedBox(height: 5),
|
|
||||||
regionBox,
|
|
||||||
SizedBox(height: 5),
|
|
||||||
countryBox,
|
|
||||||
SizedBox(height: 5),
|
|
||||||
phoneNumberBox,
|
|
||||||
SizedBox(height: 10),
|
|
||||||
]),
|
|
||||||
)),
|
|
||||||
widget.deliveryAddress == null ? createBtn : updateBtn,
|
|
||||||
SizedBox(height: 10)
|
SizedBox(height: 10)
|
||||||
],
|
]),
|
||||||
),
|
),
|
||||||
),
|
));
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeliveryAddress _getPayload() {
|
DeliveryAddress _getPayload() {
|
||||||
@@ -158,7 +148,6 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
|||||||
deliveryAddress.addressLine2 = _address2Controller.text;
|
deliveryAddress.addressLine2 = _address2Controller.text;
|
||||||
deliveryAddress.city = _cityController.text;
|
deliveryAddress.city = _cityController.text;
|
||||||
deliveryAddress.state = _stateController.text;
|
deliveryAddress.state = _stateController.text;
|
||||||
deliveryAddress.country = _countryController.text;
|
|
||||||
deliveryAddress.phoneNumber = _phoneController.text;
|
deliveryAddress.phoneNumber = _phoneController.text;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString()); // shold never happen
|
showMsgDialog(context, "Error", e.toString()); // shold never happen
|
||||||
@@ -180,10 +169,6 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
|||||||
await showMsgDialog(context, "Error", "Invalid state!");
|
await showMsgDialog(context, "Error", "Invalid state!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (deliveryAddress.country == null) {
|
|
||||||
await showMsgDialog(context, "Error", "Invalid country!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (deliveryAddress.phoneNumber == null) {
|
if (deliveryAddress.phoneNumber == null) {
|
||||||
await showMsgDialog(context, "Error", "Invalid phone number!");
|
await showMsgDialog(context, "Error", "Invalid phone number!");
|
||||||
return false;
|
return false;
|
||||||
@@ -216,7 +201,6 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
|||||||
|
|
||||||
Future<void> _update() async {
|
Future<void> _update() async {
|
||||||
DeliveryAddress deliveryAddress = _getPayload();
|
DeliveryAddress deliveryAddress = _getPayload();
|
||||||
print('deliveryAddress => ${deliveryAddress.country}');
|
|
||||||
bool valid = await _validate(deliveryAddress);
|
bool valid = await _validate(deliveryAddress);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
@@ -237,4 +221,26 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_delete() {
|
||||||
|
showConfirmDialog(context, "delivery_address.delete.confirm", _deleteDA);
|
||||||
|
}
|
||||||
|
|
||||||
|
_deleteDA() async {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
DeliveryAddressModel deliveryAddressModel =
|
||||||
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
|
await deliveryAddressModel.deleteDeliveryAddress(_deliveryAddress);
|
||||||
|
Navigator.pop(context);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,53 +53,79 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Column(
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
children: <Widget>[
|
onPressed: () {
|
||||||
Expanded(
|
Navigator.of(context)
|
||||||
child: Column(
|
.push(BottomUpPageRoute(DeliveryAddressEditor()));
|
||||||
children:
|
},
|
||||||
getAddressList(context, shipmentModel.deliveryAddresses),
|
icon: Icon(Icons.add),
|
||||||
),
|
label: LocalText(context, "delivery_address.new_address",
|
||||||
),
|
color: Colors.white),
|
||||||
Container(
|
backgroundColor: primaryColor,
|
||||||
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
),
|
||||||
child: Align(
|
body: Padding(
|
||||||
alignment: Alignment.bottomRight,
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Container(
|
child: ListView.separated(
|
||||||
width: 130,
|
separatorBuilder: (c, i) => Divider(
|
||||||
height: 40,
|
color: primaryColor,
|
||||||
child: FloatingActionButton.extended(
|
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
BottomUpPageRoute(DeliveryAddressEditor()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.add),
|
|
||||||
label: Text(
|
|
||||||
getLocalString(context, 'delivery_address.new_address'),
|
|
||||||
style: TextStyle(fontSize: 12),
|
|
||||||
),
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
),
|
),
|
||||||
),
|
itemCount: shipmentModel.deliveryAddresses.length,
|
||||||
),
|
itemBuilder: (context, index) {
|
||||||
),
|
return _row(context, shipmentModel.deliveryAddresses[index]);
|
||||||
],
|
}),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getAddressList(
|
_row(BuildContext context, DeliveryAddress deliveryAddress) {
|
||||||
BuildContext context, List<DeliveryAddress> addresses) {
|
return Row(
|
||||||
return addresses.asMap().entries.map((s) {
|
children: [
|
||||||
return InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () => _select(deliveryAddress),
|
||||||
// Navigator.pop(context, s.value);
|
child: Padding(
|
||||||
},
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: DeliveryAddressRow(shippingAddress: s.value, index: s.key),
|
child: Icon(Icons.check,
|
||||||
);
|
color:
|
||||||
}).toList();
|
deliveryAddress.isDefault ? primaryColor : Colors.black26),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: DeliveryAddressRow(
|
||||||
|
key: ValueKey(deliveryAddress.id),
|
||||||
|
deliveryAddress: deliveryAddress,
|
||||||
|
selectionCallback: (d) => _edit(context, deliveryAddress)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_edit(BuildContext context, DeliveryAddress deliveryAddress) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
BottomUpPageRoute(
|
||||||
|
DeliveryAddressEditor(deliveryAddress: deliveryAddress)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _select(DeliveryAddress deliveryAddress) async {
|
||||||
|
if (deliveryAddress.isDefault) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
var deliveryAddressModel =
|
||||||
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
|
try {
|
||||||
|
await deliveryAddressModel.selectDefalutDeliveryAddress(deliveryAddress);
|
||||||
|
Navigator.pop(context);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,146 +1,78 @@
|
|||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
|
|
||||||
import 'delivery_address_editor.dart';
|
typedef SelectionCallback(DeliveryAddress deliveryAddress);
|
||||||
|
|
||||||
class DeliveryAddressRow extends StatelessWidget {
|
class DeliveryAddressRow extends StatelessWidget {
|
||||||
final DeliveryAddress shippingAddress;
|
final DeliveryAddress deliveryAddress;
|
||||||
final int index;
|
final SelectionCallback selectionCallback;
|
||||||
|
const DeliveryAddressRow(
|
||||||
const DeliveryAddressRow({Key key, this.shippingAddress, this.index})
|
{Key key, this.deliveryAddress, this.selectionCallback})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
return InkWell(
|
||||||
return Container(
|
onTap: selectionCallback == null
|
||||||
padding: EdgeInsets.only(left: 10, right: 10),
|
? null
|
||||||
child: Column(
|
: () => this.selectionCallback(deliveryAddress),
|
||||||
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Row(
|
Expanded(
|
||||||
children: <Widget>[
|
child: Column(
|
||||||
Expanded(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: new Padding(
|
children: <Widget>[
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
line(context, deliveryAddress.fullName,
|
||||||
child: Row(
|
iconData: MaterialCommunityIcons.account_arrow_left,
|
||||||
children: <Widget>[
|
color: primaryColor,
|
||||||
InkWell(
|
fontSize: 16),
|
||||||
onTap: () {
|
line(context, deliveryAddress.phoneNumber,
|
||||||
Navigator.pop(context, shippingAddress);
|
iconData: Icons.phone, color: primaryColor, fontSize: 16),
|
||||||
},
|
SizedBox(
|
||||||
child: new Column(
|
height: 5,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.fullName == null
|
|
||||||
? ''
|
|
||||||
: shippingAddress.fullName,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 15.0,
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.addressLine1 == null
|
|
||||||
? ''
|
|
||||||
: shippingAddress.addressLine1,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.addressLine2 == null
|
|
||||||
? ''
|
|
||||||
: shippingAddress.addressLine2,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.city == null
|
|
||||||
? ''
|
|
||||||
: shippingAddress.city,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.state == null
|
|
||||||
? ''
|
|
||||||
: shippingAddress.state,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.country == null
|
|
||||||
? ''
|
|
||||||
: shippingAddress.country,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.phoneNumber == null
|
|
||||||
? ''
|
|
||||||
: "Phone:${shippingAddress.phoneNumber}",
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
line(context, deliveryAddress.addressLine1,
|
||||||
IconButton(
|
iconData: Icons.location_on),
|
||||||
padding: EdgeInsets.only(right: 30),
|
line(
|
||||||
icon: Icon(Icons.edit, color: Colors.black45),
|
context,
|
||||||
onPressed: () {
|
deliveryAddress.addressLine2,
|
||||||
Navigator.push(
|
),
|
||||||
context,
|
line(
|
||||||
BottomUpPageRoute(DeliveryAddressEditor(
|
context,
|
||||||
deliveryAddress: shippingAddress)),
|
deliveryAddress.city,
|
||||||
);
|
),
|
||||||
}),
|
line(context, deliveryAddress.state),
|
||||||
IconButton(
|
],
|
||||||
padding: EdgeInsets.only(right: 30),
|
),
|
||||||
icon: Icon(Icons.delete, color: Colors.black45),
|
|
||||||
onPressed: () async {
|
|
||||||
await deliveryAddressModel
|
|
||||||
.deleteDeliveryAddress(shippingAddress);
|
|
||||||
})
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
index == null
|
|
||||||
? Container()
|
|
||||||
: index == deliveryAddressModel.deliveryAddresses.length - 1
|
|
||||||
? Container()
|
|
||||||
: Divider(color: Colors.black)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget line(BuildContext context, String text,
|
||||||
|
{IconData iconData, Color color, double fontSize}) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
iconData == null
|
||||||
|
? SizedBox(width: 40)
|
||||||
|
: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0, right: 8),
|
||||||
|
child: Icon(iconData, color: Colors.black38),
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: TextLocalStyle(
|
||||||
|
context,
|
||||||
|
text ?? "",
|
||||||
|
fontSize: fontSize ?? 14,
|
||||||
|
color: color,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ class DeliveryAddressModel extends BaseModel {
|
|||||||
|
|
||||||
StreamSubscription<QuerySnapshot> listener;
|
StreamSubscription<QuerySnapshot> listener;
|
||||||
|
|
||||||
|
DeliveryAddress get defalutAddress =>
|
||||||
|
deliveryAddresses.firstWhere((e) => e.isDefault, orElse: () => null);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void privilegeChanged() {
|
void privilegeChanged() {
|
||||||
super.privilegeChanged();
|
super.privilegeChanged();
|
||||||
@@ -61,4 +64,9 @@ class DeliveryAddressModel extends BaseModel {
|
|||||||
return Services.instance.deliveryAddressService
|
return Services.instance.deliveryAddressService
|
||||||
.deleteDeliveryAddress(deliveryAddress);
|
.deleteDeliveryAddress(deliveryAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> selectDefalutDeliveryAddress(DeliveryAddress deliveryAddress) {
|
||||||
|
return Services.instance.deliveryAddressService
|
||||||
|
.selectDefalutDeliveryAddress(deliveryAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,12 +206,12 @@ class _HomePageState extends State<HomePage> {
|
|||||||
CupertinoPageRoute(builder: (context) => PackageList())));
|
CupertinoPageRoute(builder: (context) => PackageList())));
|
||||||
|
|
||||||
final receivingBtn = TaskButton("receiving.title",
|
final receivingBtn = TaskButton("receiving.title",
|
||||||
icon: Octicons.package,
|
icon: MaterialCommunityIcons.inbox_arrow_down,
|
||||||
btnCallback: () => Navigator.of(context).push<void>(
|
btnCallback: () => Navigator.of(context).push<void>(
|
||||||
CupertinoPageRoute(builder: (context) => ReceivingList())));
|
CupertinoPageRoute(builder: (context) => ReceivingList())));
|
||||||
|
|
||||||
final processingBtn = TaskButton("processing.title",
|
final processingBtn = TaskButton("processing.title",
|
||||||
icon: Octicons.package,
|
icon: FontAwesome.dropbox,
|
||||||
btnCallback: () => Navigator.of(context).push<void>(
|
btnCallback: () => Navigator.of(context).push<void>(
|
||||||
CupertinoPageRoute(builder: (context) => ProcessingList())));
|
CupertinoPageRoute(builder: (context) => ProcessingList())));
|
||||||
final boxesBtn = TaskButton("boxes.name",
|
final boxesBtn = TaskButton("boxes.name",
|
||||||
@@ -287,7 +287,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
|
|
||||||
List<Widget> widgets = [];
|
List<Widget> widgets = [];
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
// true ? widgets.add(pickUpBtn) : "";
|
true ? widgets.add(pickUpBtn) : "";
|
||||||
!customer ? widgets.add(fcsShipmentBtn) : "";
|
!customer ? widgets.add(fcsShipmentBtn) : "";
|
||||||
customer ? widgets.add(notiBtn) : "";
|
customer ? widgets.add(notiBtn) : "";
|
||||||
user.hasStaffs() ? widgets.add(staffBtn) : "";
|
user.hasStaffs() ? widgets.add(staffBtn) : "";
|
||||||
|
|||||||
@@ -162,8 +162,13 @@ class MainModel extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateProfile(String newUserName) async {
|
Future<void> updateProfileName(String newUserName) async {
|
||||||
await Services.instance.authService.updateProfile(newUserName);
|
await Services.instance.authService.updateProfileName(newUserName);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updatePreferredCurrency(String currency) async {
|
||||||
|
await Services.instance.authService.updatePreferredCurrency(currency);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,24 @@ class PackageModel extends BaseModel {
|
|||||||
.createPackages(packages, user.fcsID);
|
.createPackages(packages, user.fcsID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> createPackage(User user, Package package, List<File> files,
|
||||||
|
List<String> deletedUrls) async {
|
||||||
|
if (user != null) {
|
||||||
|
package.fcsID = user.fcsID;
|
||||||
|
}
|
||||||
|
if (files != null) {
|
||||||
|
if (files.length > 5) throw Exception("Exceed number of file upload");
|
||||||
|
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
|
||||||
|
for (File f in files) {
|
||||||
|
String path = Path.join(pkg_files_path);
|
||||||
|
String url = await uploadStorage(path, f);
|
||||||
|
package.photoUrls.add(url);
|
||||||
|
}
|
||||||
|
package.photoUrls.removeWhere((e) => deletedUrls.contains(e));
|
||||||
|
}
|
||||||
|
return Services.instance.packageService.createPackage(package);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> completeProcessing(
|
Future<void> completeProcessing(
|
||||||
Package package, List<File> files, List<String> deletedUrls) async {
|
Package package, List<File> files, List<String> deletedUrls) async {
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
@@ -105,7 +123,7 @@ class PackageModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
package.photoUrls.removeWhere((e) => deletedUrls.contains(e));
|
package.photoUrls.removeWhere((e) => deletedUrls.contains(e));
|
||||||
}
|
}
|
||||||
await request("/packages", "PUT",
|
await request("/package", "PUT",
|
||||||
payload: package.toJson(), token: await getToken());
|
payload: package.toJson(), token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,9 +185,11 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
? Ionicons.ios_airplane
|
? Ionicons.ios_airplane
|
||||||
: e.status == "delivered"
|
: e.status == "delivered"
|
||||||
? MaterialCommunityIcons.truck_fast
|
? MaterialCommunityIcons.truck_fast
|
||||||
: e.status == "processed"
|
: e.status == "packed"
|
||||||
? MaterialIcons.check
|
? MaterialCommunityIcons.package
|
||||||
: Octicons.package,
|
: e.status == "processed"
|
||||||
|
? FontAwesome.dropbox
|
||||||
|
: MaterialCommunityIcons.inbox_arrow_down,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
)))
|
)))
|
||||||
.toList();
|
.toList();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/pages/market/market_editor.dart';
|
import 'package:fcs/pages/market/market_editor.dart';
|
||||||
import 'package:fcs/pages/market/model/market_model.dart';
|
import 'package:fcs/pages/market/model/market_model.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/widgets/barcode_scanner.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/input_text.dart';
|
import 'package:fcs/pages/widgets/input_text.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
@@ -163,13 +164,8 @@ class _TrackingIDPageState extends State<TrackingIDPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String barcode = await BarcodeScanner.scan();
|
String barcode = await scanBarcode();
|
||||||
if (barcode != null) {
|
if (barcode != null) {
|
||||||
String gs = String.fromCharCode(29);
|
|
||||||
if (barcode.contains(gs)) {
|
|
||||||
var codes = barcode.split(gs);
|
|
||||||
barcode = codes.length >= 2 ? codes[1] : barcode;
|
|
||||||
}
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_transcationIDCtl.text = barcode;
|
_transcationIDCtl.text = barcode;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/package/model/package_model.dart';
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
import 'package:fcs/pages/package/package_list_row.dart';
|
import 'package:fcs/pages/package/package_list_row.dart';
|
||||||
|
import 'package:fcs/pages/widgets/barcode_scanner.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
@@ -147,13 +148,8 @@ class PackageSearchDelegate extends SearchDelegate<Package> {
|
|||||||
// Barcode bc = barcodes.firstWhere((element) => true);
|
// Barcode bc = barcodes.firstWhere((element) => true);
|
||||||
// String barcode;
|
// String barcode;
|
||||||
// if (bc != null) barcode = bc.rawValue;
|
// if (bc != null) barcode = bc.rawValue;
|
||||||
String barcode = await BarcodeScanner.scan();
|
String barcode = await scanBarcode();
|
||||||
if (barcode != null) {
|
if (barcode != null) {
|
||||||
String gs = String.fromCharCode(29);
|
|
||||||
if (barcode.contains(gs)) {
|
|
||||||
var codes = barcode.split(gs);
|
|
||||||
barcode = codes.length >= 2 ? codes[1] : barcode;
|
|
||||||
}
|
|
||||||
query = barcode;
|
query = barcode;
|
||||||
showResults(context);
|
showResults(context);
|
||||||
}
|
}
|
||||||
|
|||||||
129
lib/pages/profile/profile_currency_edit.dart
Normal file
129
lib/pages/profile/profile_currency_edit.dart
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
|
import 'package:fcs/pages/main/model/language_model.dart';
|
||||||
|
import 'package:fcs/pages/main/model/main_model.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 'package:fcs/pages/main/util.dart';
|
||||||
|
|
||||||
|
typedef void ProfileCallback();
|
||||||
|
|
||||||
|
enum Currency { USD, MMK }
|
||||||
|
|
||||||
|
class ProfileCurrencyEdit extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_ProfileCurrencyEditState createState() => _ProfileCurrencyEditState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProfileCurrencyEditState extends State<ProfileCurrencyEdit> {
|
||||||
|
final TextEditingController nameController = new TextEditingController();
|
||||||
|
bool _loading = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
||||||
|
if (mainModel.user.preferCurrency == "MMK") {
|
||||||
|
_currency = Currency.MMK;
|
||||||
|
} else {
|
||||||
|
_currency = Currency.USD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Currency _currency = Currency.USD;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final saveBtn =
|
||||||
|
fcsButton(context, getLocalString(context, "btn.save"), callack: _save);
|
||||||
|
|
||||||
|
return LocalProgress(
|
||||||
|
inAsyncCall: _loading,
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
title: LocalText(
|
||||||
|
context,
|
||||||
|
"profile.edit.currency.title",
|
||||||
|
fontSize: 20,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
leading: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
CupertinoIcons.back,
|
||||||
|
size: 35,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
InkWell(
|
||||||
|
onTap: () => setState(() {
|
||||||
|
_currency = Currency.USD;
|
||||||
|
}),
|
||||||
|
child: ListTile(
|
||||||
|
title: Text('USD'),
|
||||||
|
leading: Radio(
|
||||||
|
activeColor: primaryColor,
|
||||||
|
value: Currency.USD,
|
||||||
|
groupValue: _currency,
|
||||||
|
onChanged: (Currency value) {
|
||||||
|
setState(() {
|
||||||
|
_currency = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () => setState(() {
|
||||||
|
_currency = Currency.MMK;
|
||||||
|
}),
|
||||||
|
child: ListTile(
|
||||||
|
title: const Text('MMK'),
|
||||||
|
leading: Radio(
|
||||||
|
activeColor: primaryColor,
|
||||||
|
value: Currency.MMK,
|
||||||
|
groupValue: _currency,
|
||||||
|
onChanged: (Currency value) {
|
||||||
|
setState(() {
|
||||||
|
_currency = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(18.0),
|
||||||
|
child: saveBtn,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_save() async {
|
||||||
|
setState(() {
|
||||||
|
_loading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await Provider.of<MainModel>(context, listen: false)
|
||||||
|
.updatePreferredCurrency(_currency.toString().split(".").last);
|
||||||
|
Navigator.pop(context);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -96,7 +96,7 @@ class _ProfileEditState extends State<ProfileEdit> {
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await Provider.of<MainModel>(context, listen: false)
|
await Provider.of<MainModel>(context, listen: false)
|
||||||
.updateProfile(nameController.text);
|
.updateProfileName(nameController.text);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -1,21 +1,25 @@
|
|||||||
import 'package:fcs/domain/entities/role.dart';
|
import 'package:fcs/domain/entities/user.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/localization/app_translations.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';
|
||||||
|
import 'package:fcs/pages/main/util.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/widgets/bottom_up_page_route.dart';
|
import 'package:fcs/pages/widgets/bottom_up_page_route.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_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../helpers/theme.dart';
|
import '../../helpers/theme.dart';
|
||||||
@@ -33,8 +37,6 @@ class _ProfileState extends State<Profile> {
|
|||||||
String selectedLanguage;
|
String selectedLanguage;
|
||||||
TextEditingController bizNameController = new TextEditingController();
|
TextEditingController bizNameController = new TextEditingController();
|
||||||
|
|
||||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
|
||||||
|
|
||||||
static final List<String> languagesList = Translation().supportedLanguages;
|
static final List<String> languagesList = Translation().supportedLanguages;
|
||||||
static final List<String> languageCodesList =
|
static final List<String> languageCodesList =
|
||||||
Translation().supportedLanguagesCodes;
|
Translation().supportedLanguagesCodes;
|
||||||
@@ -56,12 +58,6 @@ class _ProfileState extends State<Profile> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
var shipmentModel =
|
|
||||||
Provider.of<DeliveryAddressModel>(context, listen: false);
|
|
||||||
|
|
||||||
if (shipmentModel.deliveryAddresses.length != 0) {
|
|
||||||
_deliveryAddress = shipmentModel.deliveryAddresses[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -70,11 +66,19 @@ class _ProfileState extends State<Profile> {
|
|||||||
if (mainModel.user == null) {
|
if (mainModel.user == null) {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
|
DeliveryAddressModel deliveryAddressModel =
|
||||||
|
Provider.of<DeliveryAddressModel>(context);
|
||||||
|
|
||||||
final namebox = DisplayText(
|
final namebox = DisplayText(
|
||||||
text: mainModel.user.name,
|
text: mainModel.user.name + " (${mainModel.user.status})",
|
||||||
labelTextKey: "profile.name",
|
labelTextKey: "profile.name",
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
);
|
);
|
||||||
|
final currencyBox = DisplayText(
|
||||||
|
text: mainModel.user.preferCurrency,
|
||||||
|
labelTextKey: "profile.currency",
|
||||||
|
iconData: FontAwesome5.money_bill_alt,
|
||||||
|
);
|
||||||
|
|
||||||
final phonenumberbox = DisplayText(
|
final phonenumberbox = DisplayText(
|
||||||
text: mainModel.user.phone,
|
text: mainModel.user.phone,
|
||||||
@@ -142,42 +146,40 @@ class _ProfileState extends State<Profile> {
|
|||||||
),
|
),
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
actions: <Widget>[],
|
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Column(
|
child: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Row(
|
||||||
child: ListView(
|
children: <Widget>[
|
||||||
shrinkWrap: true,
|
Expanded(child: namebox),
|
||||||
children: <Widget>[
|
Padding(
|
||||||
Row(
|
padding: const EdgeInsets.only(right: 0),
|
||||||
children: <Widget>[
|
child: IconButton(
|
||||||
Expanded(child: namebox),
|
icon: Icon(Icons.edit, color: Colors.grey),
|
||||||
Padding(
|
onPressed: _editName),
|
||||||
padding: const EdgeInsets.only(right: 0),
|
)
|
||||||
child: IconButton(
|
],
|
||||||
icon: Icon(Icons.edit, color: Colors.grey),
|
|
||||||
onPressed: _editName),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
mainModel.isCustomer()
|
|
||||||
? Container()
|
|
||||||
: getPrivilegeBox(context),
|
|
||||||
getShippingAddressList(context),
|
|
||||||
phonenumberbox,
|
|
||||||
fcsIDBox,
|
|
||||||
usaShippingAddressBox,
|
|
||||||
DisplayText(
|
|
||||||
text: mainModel.user.status,
|
|
||||||
labelTextKey: "customer.status",
|
|
||||||
iconData: Icons.add_alarm,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
phonenumberbox,
|
||||||
|
fcsIDBox,
|
||||||
|
usaShippingAddressBox,
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(child: currencyBox),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 0),
|
||||||
|
child: IconButton(
|
||||||
|
icon: Icon(Icons.edit, color: Colors.grey),
|
||||||
|
onPressed: _editCurrency),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
defalutDeliveryAddress(
|
||||||
|
context, deliveryAddressModel.defalutAddress),
|
||||||
|
getPrivilegeBox(context),
|
||||||
|
SizedBox(height: 15),
|
||||||
logoutbutton,
|
logoutbutton,
|
||||||
SizedBox(height: 25)
|
SizedBox(height: 25)
|
||||||
],
|
],
|
||||||
@@ -187,221 +189,104 @@ class _ProfileState extends State<Profile> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getShippingAddressList(BuildContext context) {
|
Widget defalutDeliveryAddress(
|
||||||
var languageModel = Provider.of<LanguageModel>(context);
|
BuildContext context, DeliveryAddress deliveryAddress) {
|
||||||
return ListTileTheme(
|
return Column(
|
||||||
contentPadding: EdgeInsets.all(10),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: ExpansionTile(
|
children: [
|
||||||
title: Text(
|
Row(
|
||||||
getLocalString(context, 'delivery_addresses'),
|
children: [
|
||||||
style: languageModel.isEng
|
Expanded(
|
||||||
? TextStyle(
|
child: DisplayText(
|
||||||
fontSize: 16.0,
|
labelTextKey: "delivery_address",
|
||||||
fontWeight: FontWeight.bold,
|
iconData: MaterialCommunityIcons.truck_fast,
|
||||||
fontStyle: FontStyle.normal,
|
|
||||||
)
|
|
||||||
: TextStyle(
|
|
||||||
fontSize: 15.0,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontStyle: FontStyle.normal,
|
|
||||||
fontFamily: "Myanmar3"),
|
|
||||||
),
|
|
||||||
children: <Widget>[
|
|
||||||
showDeliveryAddress(_deliveryAddress),
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
child: Container(
|
|
||||||
width: 130,
|
|
||||||
height: 40,
|
|
||||||
child: FloatingActionButton.extended(
|
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
||||||
onPressed: () async {
|
|
||||||
DeliveryAddress deliveryAddress = await Navigator.push(
|
|
||||||
context,
|
|
||||||
BottomUpPageRoute(DeliveryAddressList(
|
|
||||||
deliveryAddress: _deliveryAddress)),
|
|
||||||
);
|
|
||||||
setState(() {
|
|
||||||
_deliveryAddress = deliveryAddress;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
label: LocalText(context,
|
|
||||||
'delivery_address.change_address',
|
|
||||||
fontSize: 12,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
Chip(
|
||||||
],
|
label: InkWell(
|
||||||
),
|
onTap: () => Navigator.push(
|
||||||
);
|
context,
|
||||||
}
|
BottomUpPageRoute(DeliveryAddressList()),
|
||||||
|
|
||||||
Widget showDeliveryAddress(DeliveryAddress deliveryAddress) {
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.only(left: 10, right: 10),
|
|
||||||
child: Column(
|
|
||||||
children: <Widget>[
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: new Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
new Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
deliveryAddress.fullName == null
|
|
||||||
? ''
|
|
||||||
: deliveryAddress.fullName,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 15.0,
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
deliveryAddress.addressLine1 == null
|
|
||||||
? ''
|
|
||||||
: deliveryAddress.addressLine1,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
deliveryAddress.addressLine2 == null
|
|
||||||
? ''
|
|
||||||
: deliveryAddress.addressLine2,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
deliveryAddress.city == null
|
|
||||||
? ''
|
|
||||||
: deliveryAddress.city,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
deliveryAddress.state == null
|
|
||||||
? ''
|
|
||||||
: deliveryAddress.state,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
deliveryAddress.country == null
|
|
||||||
? ''
|
|
||||||
: deliveryAddress.country,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
deliveryAddress.phoneNumber == null
|
|
||||||
? ''
|
|
||||||
: "Phone:${deliveryAddress.phoneNumber}",
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
child: LocalText(context, "delivery_address.change_address",
|
||||||
),
|
color: primaryColor),
|
||||||
],
|
))
|
||||||
),
|
],
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 28.0),
|
||||||
|
child: deliveryAddress == null
|
||||||
|
? Container()
|
||||||
|
: DeliveryAddressRow(
|
||||||
|
key: ValueKey(deliveryAddress.id),
|
||||||
|
deliveryAddress: deliveryAddress),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Privilege> privileges = [
|
|
||||||
Privilege(name: 'Manage shipment'),
|
|
||||||
Privilege(name: 'Manage pickups'),
|
|
||||||
Privilege(name: 'Manage packages'),
|
|
||||||
Privilege(name: 'Manage deliveries'),
|
|
||||||
Privilege(name: 'Admin')
|
|
||||||
];
|
|
||||||
|
|
||||||
Widget getPrivilegeBox(BuildContext context) {
|
Widget getPrivilegeBox(BuildContext context) {
|
||||||
var languageModel = Provider.of<LanguageModel>(context);
|
User user = Provider.of<MainModel>(context, listen: false).user;
|
||||||
|
List<Privilege> _privileges =
|
||||||
|
Provider.of<StaffModel>(context, listen: false).privileges;
|
||||||
|
|
||||||
return ListTileTheme(
|
if (user == null || user.isCustomer()) return Container();
|
||||||
contentPadding: EdgeInsets.all(10),
|
List<Privilege> privileges = [];
|
||||||
child: ExpansionTile(
|
user.privileges.forEach((e) {
|
||||||
title: Text(
|
var p = _privileges.firstWhere((p) => p.id == e, orElse: () => null);
|
||||||
AppTranslations.of(context).text("profile.privilege"),
|
if (p != null) {
|
||||||
style: languageModel.isEng
|
privileges.add(p);
|
||||||
? TextStyle(
|
}
|
||||||
fontSize: 16.0,
|
});
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontStyle: FontStyle.normal,
|
return Column(
|
||||||
)
|
children: <Widget>[
|
||||||
: TextStyle(
|
DisplayText(
|
||||||
fontSize: 15.0,
|
labelTextKey: "profile.privileges",
|
||||||
fontWeight: FontWeight.bold,
|
iconData: MaterialCommunityIcons.clipboard_check_outline,
|
||||||
fontStyle: FontStyle.normal,
|
|
||||||
fontFamily: "Myanmar3"),
|
|
||||||
),
|
),
|
||||||
children: <Widget>[
|
Padding(
|
||||||
Align(
|
padding: const EdgeInsets.only(left: 30.0),
|
||||||
alignment: Alignment.topLeft,
|
child: Column(
|
||||||
child: SingleChildScrollView(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
scrollDirection: Axis.horizontal,
|
children: getRowPrivilegeWidget(privileges)),
|
||||||
child: Column(
|
)
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
],
|
||||||
children: getRowPrivilegeWidget(privileges)),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getRowPrivilegeWidget(List<Privilege> privileges) {
|
List<Widget> getRowPrivilegeWidget(List<Privilege> privileges) {
|
||||||
return privileges.map((p) {
|
return privileges.map((p) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.all(8.0),
|
padding: EdgeInsets.all(3.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(p.name,
|
Icon(
|
||||||
style: TextStyle(fontSize: 16.0, fontStyle: FontStyle.normal)),
|
p.iconData,
|
||||||
SizedBox(
|
color: Colors.black38,
|
||||||
width: 30,
|
|
||||||
),
|
),
|
||||||
Container(
|
SizedBox(
|
||||||
child: Text(
|
width: 10,
|
||||||
"- ${p.desc}",
|
),
|
||||||
style: TextStyle(fontSize: 16.0, fontStyle: FontStyle.normal),
|
Flexible(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text("${p.name}",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.0,
|
||||||
|
fontStyle: FontStyle.normal,
|
||||||
|
color: primaryColor,
|
||||||
|
)),
|
||||||
|
Text(
|
||||||
|
"${p.desc}",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.0,
|
||||||
|
fontStyle: FontStyle.normal,
|
||||||
|
color: Colors.black38),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@@ -415,7 +300,7 @@ class _ProfileState extends State<Profile> {
|
|||||||
_showToast(title);
|
_showToast(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showToast(String title) {
|
_showToast(String title) {
|
||||||
final ScaffoldState scaffold = key.currentState;
|
final ScaffoldState scaffold = key.currentState;
|
||||||
scaffold.showSnackBar(
|
scaffold.showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
@@ -431,6 +316,11 @@ class _ProfileState extends State<Profile> {
|
|||||||
.push<void>(CupertinoPageRoute(builder: (context) => ProfileEdit()));
|
.push<void>(CupertinoPageRoute(builder: (context) => ProfileEdit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_editCurrency() {
|
||||||
|
Navigator.of(context).push<void>(
|
||||||
|
CupertinoPageRoute(builder: (context) => ProfileCurrencyEdit()));
|
||||||
|
}
|
||||||
|
|
||||||
_logout() {
|
_logout() {
|
||||||
showConfirmDialog(context, "profile.logout.confirm", () async {
|
showConfirmDialog(context, "profile.logout.confirm", () async {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
162
lib/pages/receiving/receiving_info.dart
Normal file
162
lib/pages/receiving/receiving_info.dart
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
|
import 'package:fcs/pages/package/package_editor.dart';
|
||||||
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||||
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
||||||
|
import 'package:fcs/pages/widgets/multi_img_file.dart';
|
||||||
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
|
import 'package:fcs/pages/widgets/status_tree.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:timeline_list/timeline.dart';
|
||||||
|
import 'package:timeline_list/timeline_model.dart';
|
||||||
|
|
||||||
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
|
|
||||||
|
class ReceivingInfo extends StatefulWidget {
|
||||||
|
final Package package;
|
||||||
|
ReceivingInfo({this.package});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ReceivingInfoState createState() => _ReceivingInfoState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReceivingInfoState extends State<ReceivingInfo> {
|
||||||
|
Package _package;
|
||||||
|
bool _isLoading = false;
|
||||||
|
MultiImgController multiImgController = MultiImgController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
initPackage(widget.package);
|
||||||
|
}
|
||||||
|
|
||||||
|
initPackage(Package package) {
|
||||||
|
setState(() {
|
||||||
|
_package = package;
|
||||||
|
multiImgController.setImageUrls = package.photoUrls;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
bool isCustomer = Provider.of<MainModel>(context).isCustomer();
|
||||||
|
|
||||||
|
final trackingIdBox = DisplayText(
|
||||||
|
text: _package.trackingID,
|
||||||
|
labelTextKey: "package.tracking.id",
|
||||||
|
iconData: MaterialCommunityIcons.barcode_scan,
|
||||||
|
);
|
||||||
|
final customerNameBox = DisplayText(
|
||||||
|
text: _package.userName,
|
||||||
|
labelTextKey: "package.create.name",
|
||||||
|
iconData: Icons.perm_identity,
|
||||||
|
);
|
||||||
|
final remarkBox = DisplayText(
|
||||||
|
text: _package.remark ?? "-",
|
||||||
|
labelTextKey: "package.edit.remark",
|
||||||
|
iconData: Entypo.new_message,
|
||||||
|
);
|
||||||
|
final img = MultiImageFile(
|
||||||
|
enabled: false,
|
||||||
|
controller: multiImgController,
|
||||||
|
title: "Receipt File",
|
||||||
|
);
|
||||||
|
|
||||||
|
return LocalProgress(
|
||||||
|
inAsyncCall: _isLoading,
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
leading: new IconButton(
|
||||||
|
icon: new Icon(Icons.close, color: primaryColor, size: 30),
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
title: LocalText(
|
||||||
|
context,
|
||||||
|
"package.info.title",
|
||||||
|
fontSize: 20,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
isCustomer
|
||||||
|
? Container()
|
||||||
|
: IconButton(
|
||||||
|
icon: Icon(Icons.delete, color: primaryColor),
|
||||||
|
onPressed: _delete,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: Card(
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
child: ListView(children: <Widget>[
|
||||||
|
trackingIdBox,
|
||||||
|
_package.userID != null ? customerNameBox : Container(),
|
||||||
|
_package.photoUrls.length == 0 ? Container() : img,
|
||||||
|
remarkBox,
|
||||||
|
ExpansionTile(
|
||||||
|
initiallyExpanded: true,
|
||||||
|
title: Text(
|
||||||
|
'Status',
|
||||||
|
style: TextStyle(
|
||||||
|
color: primaryColor, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
children: <Widget>[
|
||||||
|
StatusTree(
|
||||||
|
shipmentHistory: _package.shipmentHistory,
|
||||||
|
currentStatus: _package.currentStatus),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_delete() {
|
||||||
|
showConfirmDialog(context, "receiving.delete.confirm", _deleteReceiving);
|
||||||
|
}
|
||||||
|
|
||||||
|
_deleteReceiving() async {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
PackageModel packageModel =
|
||||||
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
|
await packageModel.deletePackage(_package);
|
||||||
|
Navigator.pop(context);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
import 'package:fcs/pages/package/model/package_model.dart';
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
import 'package:fcs/pages/package/package_info.dart';
|
|
||||||
import 'package:fcs/pages/package/package_new.dart';
|
|
||||||
import 'package:fcs/pages/package_search/package_serach.dart';
|
import 'package:fcs/pages/package_search/package_serach.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
@@ -13,6 +10,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import 'receiving_info.dart';
|
||||||
import 'receiving_list_row.dart';
|
import 'receiving_list_row.dart';
|
||||||
import 'receiving_new.dart';
|
import 'receiving_new.dart';
|
||||||
|
|
||||||
@@ -76,8 +74,8 @@ class _ReceivingListState extends State<ReceivingList> {
|
|||||||
_newReceiving();
|
_newReceiving();
|
||||||
},
|
},
|
||||||
icon: Icon(Icons.add),
|
icon: Icon(Icons.add),
|
||||||
label: Text(
|
label:
|
||||||
AppTranslations.of(context).text("receiving.new")),
|
LocalText(context, "receiving.new", color: Colors.white),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
),
|
),
|
||||||
body: new ListView.separated(
|
body: new ListView.separated(
|
||||||
@@ -110,7 +108,7 @@ class _ReceivingListState extends State<ReceivingList> {
|
|||||||
if (_package == null) return;
|
if (_package == null) return;
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
BottomUpPageRoute(PackageInfo(package: _package)),
|
BottomUpPageRoute(ReceivingInfo(package: _package)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
import 'package:fcs/pages/package/package_info.dart';
|
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
import 'receiving_info.dart';
|
||||||
|
|
||||||
typedef CallbackPackageSelect(Package package);
|
typedef CallbackPackageSelect(Package package);
|
||||||
|
|
||||||
class ReceivingListRow extends StatelessWidget {
|
class ReceivingListRow extends StatelessWidget {
|
||||||
@@ -28,7 +29,7 @@ class ReceivingListRow extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
BottomUpPageRoute(PackageInfo(package: package)),
|
BottomUpPageRoute(ReceivingInfo(package: package)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import 'package:barcode_scan/barcode_scan.dart';
|
|||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
import 'package:fcs/domain/entities/user.dart';
|
import 'package:fcs/domain/entities/user.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
|
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||||
|
import 'package:fcs/pages/widgets/barcode_scanner.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/input_text.dart';
|
import 'package:fcs/pages/widgets/input_text.dart';
|
||||||
@@ -29,7 +31,7 @@ class _ReceivingNewState extends State<ReceivingNew> {
|
|||||||
User user;
|
User user;
|
||||||
TextEditingController _transcationIDCtl = new TextEditingController();
|
TextEditingController _transcationIDCtl = new TextEditingController();
|
||||||
TextEditingController _remarkCtl = new TextEditingController();
|
TextEditingController _remarkCtl = new TextEditingController();
|
||||||
MultiImgController multiImgController = MultiImgController();
|
MultiImgController _multiImgController = MultiImgController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -80,8 +82,8 @@ class _ReceivingNewState extends State<ReceivingNew> {
|
|||||||
controller: _remarkCtl);
|
controller: _remarkCtl);
|
||||||
final img = MultiImageFile(
|
final img = MultiImageFile(
|
||||||
enabled: true,
|
enabled: true,
|
||||||
controller: multiImgController,
|
controller: _multiImgController,
|
||||||
title: "Receipt File",
|
title: "Receiving",
|
||||||
);
|
);
|
||||||
final namebox = DisplayText(
|
final namebox = DisplayText(
|
||||||
text: user != null ? user.name : "",
|
text: user != null ? user.name : "",
|
||||||
@@ -161,14 +163,8 @@ class _ReceivingNewState extends State<ReceivingNew> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String barcode = await BarcodeScanner.scan();
|
String barcode = await scanBarcode();
|
||||||
if (barcode != null) {
|
if (barcode != null) {
|
||||||
String gs = String.fromCharCode(29);
|
|
||||||
if (barcode.contains(gs)) {
|
|
||||||
var codes = barcode.split(gs);
|
|
||||||
barcode = codes.length >= 2 ? codes[1] : barcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_transcationIDCtl.text = barcode;
|
_transcationIDCtl.text = barcode;
|
||||||
});
|
});
|
||||||
@@ -179,17 +175,22 @@ class _ReceivingNewState extends State<ReceivingNew> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_create() async {
|
_create() async {
|
||||||
if (user == null) {
|
Package package = Package();
|
||||||
showMsgDialog(context, "Error", "Invalid user!");
|
package.trackingID = _transcationIDCtl.text;
|
||||||
|
package.remark = _remarkCtl.text;
|
||||||
|
|
||||||
|
if (package.trackingID == null || package.trackingID == "") {
|
||||||
|
showMsgDialog(context, "Error", "Invalid tracking ID!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
// PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
// Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
// await packageModel.createPackages(user, packages);
|
await packageModel.createPackage(user, package,
|
||||||
|
_multiImgController.getAddedFile, _multiImgController.getDeletedUrl);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
|
|||||||
color: primaryColor, fontWeight: FontWeight.bold),
|
color: primaryColor, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
DeliveryAddressRow(shippingAddress: _shippingAddress),
|
DeliveryAddressRow(deliveryAddress: _shippingAddress),
|
||||||
Container(
|
Container(
|
||||||
padding:
|
padding:
|
||||||
EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
_currVal == 3
|
_currVal == 3
|
||||||
? Container(
|
? Container(
|
||||||
child: DeliveryAddressRow(
|
child: DeliveryAddressRow(
|
||||||
shippingAddress: DeliveryAddress(
|
deliveryAddress: DeliveryAddress(
|
||||||
fullName: 'FCS Office',
|
fullName: 'FCS Office',
|
||||||
addressLine1: '154-19 64th Ave.',
|
addressLine1: '154-19 64th Ave.',
|
||||||
addressLine2: 'Flushing',
|
addressLine2: 'Flushing',
|
||||||
@@ -412,7 +412,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 10.0),
|
padding: const EdgeInsets.only(left: 10.0),
|
||||||
child: DeliveryAddressRow(
|
child: DeliveryAddressRow(
|
||||||
shippingAddress: _shippingAddress),
|
deliveryAddress: _shippingAddress),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import 'dart:async';
|
|||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:fcs/data/services/services.dart';
|
import 'package:fcs/data/services/services.dart';
|
||||||
import 'package:fcs/domain/constants.dart';
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/role.dart';
|
|
||||||
import 'package:fcs/domain/entities/user.dart';
|
import 'package:fcs/domain/entities/user.dart';
|
||||||
|
import 'package:fcs/domain/vo/privilege.dart';
|
||||||
import 'package:fcs/helpers/firebase_helper.dart';
|
import 'package:fcs/helpers/firebase_helper.dart';
|
||||||
import 'package:fcs/pages/main/model/base_model.dart';
|
import 'package:fcs/pages/main/model/base_model.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
@@ -58,8 +58,6 @@ class StaffModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadPrivileges() async {
|
Future<void> _loadPrivileges() async {
|
||||||
if (user == null || !user.hasStaffs()) return;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
privilegeListener = Firestore.instance
|
privilegeListener = Firestore.instance
|
||||||
.collection("/$privilege_collection")
|
.collection("/$privilege_collection")
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import 'package:fcs/domain/entities/role.dart';
|
|
||||||
import 'package:fcs/domain/entities/user.dart';
|
import 'package:fcs/domain/entities/user.dart';
|
||||||
|
import 'package:fcs/domain/vo/privilege.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
import 'package:fcs/pages/main/model/language_model.dart';
|
import 'package:fcs/pages/main/model/language_model.dart';
|
||||||
import 'package:fcs/pages/staff/model/staff_model.dart';
|
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/staff/model/staff_model.dart';
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
@@ -68,16 +68,22 @@ class _StaffEditorState extends State<StaffEditor> {
|
|||||||
p.isChecked = value;
|
p.isChecked = value;
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
Column(
|
Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: const EdgeInsets.only(right: 8.0),
|
||||||
children: <Widget>[
|
child: Icon(p.iconData, size: 50, color: Colors.black38),
|
||||||
new Text(
|
),
|
||||||
p.name,
|
Expanded(
|
||||||
style: TextStyle(fontSize: 15.0, color: primaryColor),
|
child: Column(
|
||||||
),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Text(p.desc,
|
children: <Widget>[
|
||||||
style: TextStyle(fontSize: 13, color: Colors.grey[600]))
|
new Text(
|
||||||
],
|
p.name,
|
||||||
|
style: TextStyle(fontSize: 15.0, color: primaryColor),
|
||||||
|
),
|
||||||
|
Text(p.desc,
|
||||||
|
style: TextStyle(fontSize: 13, color: Colors.grey[600]))
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -192,6 +198,9 @@ class _StaffEditorState extends State<StaffEditor> {
|
|||||||
Column(
|
Column(
|
||||||
children: showprivilegeList(context),
|
children: showprivilegeList(context),
|
||||||
),
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
Container(
|
Container(
|
||||||
child: isNew ? addButton : updateButton,
|
child: isNew ? addButton : updateButton,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
import 'package:fcs/domain/entities/user.dart';
|
import 'package:fcs/domain/entities/user.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/staff/model/staff_model.dart';
|
import 'package:fcs/pages/staff/model/staff_model.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'staff_editor.dart';
|
import 'staff_editor.dart';
|
||||||
|
|
||||||
class StaffList extends StatefulWidget {
|
class StaffList extends StatefulWidget {
|
||||||
|
|||||||
18
lib/pages/widgets/barcode_scanner.dart
Normal file
18
lib/pages/widgets/barcode_scanner.dart
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import 'package:barcode_scan/barcode_scan.dart';
|
||||||
|
|
||||||
|
Future<String> scanBarcode() async {
|
||||||
|
try {
|
||||||
|
String barcode = await BarcodeScanner.scan();
|
||||||
|
if (barcode == null) return null;
|
||||||
|
|
||||||
|
String gs = String.fromCharCode(29);
|
||||||
|
if (barcode.contains(gs)) {
|
||||||
|
var codes = barcode.split(gs);
|
||||||
|
barcode = codes.length >= 2 ? codes[1] : barcode;
|
||||||
|
}
|
||||||
|
return barcode;
|
||||||
|
} catch (e) {
|
||||||
|
print('error: $e');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,10 +63,12 @@ class DisplayText extends StatelessWidget {
|
|||||||
AppTranslations.of(context).text(labelTextKey),
|
AppTranslations.of(context).text(labelTextKey),
|
||||||
style: labelStyle,
|
style: labelStyle,
|
||||||
),
|
),
|
||||||
Text(
|
text == null
|
||||||
text,
|
? Container()
|
||||||
style: textStyle,
|
: Text(
|
||||||
),
|
text,
|
||||||
|
style: textStyle,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
66
lib/pages/widgets/status_tree.dart
Normal file
66
lib/pages/widgets/status_tree.dart
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import 'package:fcs/domain/constants.dart';
|
||||||
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
|
import 'package:fcs/domain/vo/shipment_status.dart';
|
||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:timeline_list/timeline.dart';
|
||||||
|
import 'package:timeline_list/timeline_model.dart';
|
||||||
|
|
||||||
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||||
|
|
||||||
|
class StatusTree extends StatelessWidget {
|
||||||
|
final List<ShipmentStatus> shipmentHistory;
|
||||||
|
final String currentStatus;
|
||||||
|
|
||||||
|
const StatusTree({Key key, this.shipmentHistory, this.currentStatus})
|
||||||
|
: super(key: key);
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.only(left: 20),
|
||||||
|
height: 400,
|
||||||
|
child: Timeline(children: _models(), position: TimelinePosition.Left),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TimelineModel> _models() {
|
||||||
|
if (shipmentHistory == null || currentStatus == null) return [];
|
||||||
|
bool isPacked = currentStatus != package_received_status &&
|
||||||
|
currentStatus != package_processed_status;
|
||||||
|
return shipmentHistory
|
||||||
|
.map((e) => TimelineModel(
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(18.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Text(e.status,
|
||||||
|
style: TextStyle(
|
||||||
|
color: e.done ? primaryColor : Colors.grey,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold)),
|
||||||
|
e.done || isPacked
|
||||||
|
? Text(dateFormatter.format(e.date))
|
||||||
|
: Container(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
iconBackground: e.done ? primaryColor : Colors.grey,
|
||||||
|
icon: Icon(
|
||||||
|
e.status == "shipped"
|
||||||
|
? Ionicons.ios_airplane
|
||||||
|
: e.status == "delivered"
|
||||||
|
? MaterialCommunityIcons.truck_fast
|
||||||
|
: e.status == "packed"
|
||||||
|
? MaterialCommunityIcons.package
|
||||||
|
: e.status == "processed"
|
||||||
|
? FontAwesome.dropbox
|
||||||
|
: MaterialCommunityIcons.inbox_arrow_down,
|
||||||
|
color: Colors.white,
|
||||||
|
)))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user