aamir_dev
Aamir 1 year ago
parent 803ade0b9d
commit aaa8f68e60

@ -750,7 +750,11 @@
"updateCity": "تحديث المدينة", "updateCity": "تحديث المدينة",
"userGender": "جنس", "userGender": "جنس",
"userMale": "ذكر", "userMale": "ذكر",
"userFemale": "أنثى" "userFemale": "أنثى",
"maxFileSelection" :"يمكنك تحديد الحد الأقصى لملفات 7",
"maxFileSize": "يجب أن يكون حجم كل ملف أقل من 2 ميغابايت",
"onlyJPGandPNG": "يُسمح فقط بملفات JPG وPNG",
"expiryDate": "تاريخ انتهاء الصلاحية"
} }

@ -748,5 +748,9 @@
"updateCity": "Update City", "updateCity": "Update City",
"userGender": "Gender", "userGender": "Gender",
"userMale": "Male", "userMale": "Male",
"userFemale": "Female" "userFemale": "Female",
"maxFileSelection" :"You can select a maximum of 7 files",
"maxFileSize": "Each file size must be less than 2 MB",
"onlyJPGandPNG": "Only JPG and PNG files are allowed",
"expiryDate": "Expiry Date"
} }

@ -253,6 +253,12 @@ class GlobalConsts {
} }
return appInvitationMessageEn; return appInvitationMessageEn;
} }
// Attachment Values
int maxFileCount = 7;
int maxFileSizeInBytes = 2 * 1024 * 1024;
} }
class MyAssets { class MyAssets {
@ -394,4 +400,6 @@ class SignalrConsts {
// General // General
static String sendMessageGeneral = "SendMessageGeneral"; static String sendMessageGeneral = "SendMessageGeneral";
static String receiveMessageGeneral = "ReceiveMessageGeneral"; static String receiveMessageGeneral = "ReceiveMessageGeneral";
} }

@ -766,7 +766,11 @@ class CodegenLoader extends AssetLoader{
"updateCity": "تحديث المدينة", "updateCity": "تحديث المدينة",
"userGender": "جنس", "userGender": "جنس",
"userMale": "ذكر", "userMale": "ذكر",
"userFemale": "أنثى" "userFemale": "أنثى",
"maxFileSelection": "يمكنك تحديد الحد الأقصى لملفات 7",
"maxFileSize": "يجب أن يكون حجم كل ملف أقل من 2 ميغابايت",
"onlyJPGandPNG": "يُسمح فقط بملفات JPG وPNG",
"expiryDate": "تاريخ انتهاء الصلاحية"
}; };
static const Map<String,dynamic> en_US = { static const Map<String,dynamic> en_US = {
"firstTimeLogIn": "First Time Log In", "firstTimeLogIn": "First Time Log In",
@ -1518,7 +1522,11 @@ static const Map<String,dynamic> en_US = {
"updateCity": "Update City", "updateCity": "Update City",
"userGender": "Gender", "userGender": "Gender",
"userMale": "Male", "userMale": "Male",
"userFemale": "Female" "userFemale": "Female",
"maxFileSelection": "You can select a maximum of 7 files",
"maxFileSize": "Each file size must be less than 2 MB",
"onlyJPGandPNG": "Only JPG and PNG files are allowed",
"expiryDate": "Expiry Date"
}; };
static const Map<String, Map<String,dynamic>> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; static const Map<String, Map<String,dynamic>> mapLocales = {"ar_SA": ar_SA, "en_US": en_US};
} }

@ -730,5 +730,9 @@ abstract class LocaleKeys {
static const userGender = 'userGender'; static const userGender = 'userGender';
static const userMale = 'userMale'; static const userMale = 'userMale';
static const userFemale = 'userFemale'; static const userFemale = 'userFemale';
static const maxFileSelection = 'maxFileSelection';
static const maxFileSize = 'maxFileSize';
static const onlyJPGandPNG = 'onlyJPGandPNG';
static const expiryDate = 'expiryDate';
} }

@ -4,6 +4,8 @@
import 'dart:convert'; import 'dart:convert';
import 'package:mc_common_app/utils/enums.dart';
Document documentFromJson(String str) => Document.fromJson(json.decode(str)); Document documentFromJson(String str) => Document.fromJson(json.decode(str));
String documentToJson(Document data) => json.encode(data.toJson()); String documentToJson(Document data) => json.encode(data.toJson());
@ -21,16 +23,14 @@ class Document {
int? messageStatus; int? messageStatus;
String? message; String? message;
factory Document.fromJson(Map<String, dynamic> json) => factory Document.fromJson(Map<String, dynamic> json) => Document(
Document(
totalItemsCount: json["totalItemsCount"], totalItemsCount: json["totalItemsCount"],
data: json["data"] == null ? null : List<DocumentData>.from(json["data"].map((x) => DocumentData.fromJson(x))), data: json["data"] == null ? null : List<DocumentData>.from(json["data"].map((x) => DocumentData.fromJson(x))),
messageStatus: json["messageStatus"], messageStatus: json["messageStatus"],
message: json["message"], message: json["message"],
); );
Map<String, dynamic> toJson() => Map<String, dynamic> toJson() => {
{
"totalItemsCount": totalItemsCount, "totalItemsCount": totalItemsCount,
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())), "data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
"messageStatus": messageStatus, "messageStatus": messageStatus,
@ -39,27 +39,29 @@ class Document {
} }
class DocumentData { class DocumentData {
DocumentData({ DocumentData(
this.id, {this.id,
this.serviceProviderId, this.serviceProviderId,
this.documentId, this.documentId,
this.documentUrl, this.documentUrl,
this.status, this.status,
this.statusText, this.statusText,
this.comment, this.comment,
this.isActive, this.isActive,
this.document, this.document,
this.fileExt, this.fileExt,
this.documentName, this.documentName,
this.isLocalFile, this.isLocalFile,
this.description, this.description,
}); this.dateExpire,
this.isAllowUpdate,
this.isExpired});
int? id; int? id;
int? serviceProviderId; int? serviceProviderId;
int? documentId; int? documentId;
String? documentUrl; String? documentUrl;
int? status; DocumentStatusEnum? status;
String? comment; String? comment;
bool? isActive; bool? isActive;
String? document; String? document;
@ -68,25 +70,29 @@ class DocumentData {
String? documentName; String? documentName;
bool? isLocalFile; bool? isLocalFile;
String? description; String? description;
String? dateExpire;
bool? isExpired;
bool? isAllowUpdate;
factory DocumentData.fromJson(Map<String, dynamic> json) => factory DocumentData.fromJson(Map<String, dynamic> json) => DocumentData(
DocumentData( id: json["id"],
id: json["id"], serviceProviderId: json["serviceProviderID"],
serviceProviderId: json["serviceProviderID"], documentId: json["documentID"],
documentId: json["documentID"], documentUrl: json["documentURL"],
documentUrl: json["documentURL"], status: json.containsKey("status") ? (json['status'] as int).toDocumentStatusEnum() : null,
status: json["status"], statusText: json["statusText"],
statusText: json["statusText"], comment: json["comment"],
comment: json["comment"], isActive: json["isActive"],
isActive: json["isActive"], dateExpire: json["dateExpire"],
document: null, isExpired: json["isExpired"],
fileExt: null, isAllowUpdate: json["isAllowUpdate"],
documentName: json["documentName"], document: null,
isLocalFile: false, fileExt: null,
description: null); documentName: json["documentName"],
isLocalFile: false,
description: null);
Map<String, dynamic> toJson() => Map<String, dynamic> toJson() => {
{
"id": id, "id": id,
"serviceProviderID": serviceProviderId, "serviceProviderID": serviceProviderId,
"documentID": documentId, "documentID": documentId,
@ -94,5 +100,27 @@ class DocumentData {
"status": status, "status": status,
"comment": comment, "comment": comment,
"isActive": isActive, "isActive": isActive,
"dateExpire": dateExpire,
"isExpired": isExpired,
"isAllowUpdate": isAllowUpdate,
}; };
} }
extension DocumentEnum on int {
DocumentStatusEnum toDocumentStatusEnum() {
switch (this) {
case 0:
return DocumentStatusEnum.needUpload;
case 1:
return DocumentStatusEnum.pending;
case 2:
return DocumentStatusEnum.review;
case 3:
return DocumentStatusEnum.approvedOrActive;
case 4:
return DocumentStatusEnum.rejected;
default:
throw Exception('Invalid status value: $this'); // Explicit handling for invalid cases
}
}
}

@ -82,6 +82,8 @@ class UserInfo {
this.userImageUrl, this.userImageUrl,
this.roleId, this.roleId,
this.roleName, this.roleName,
this.genderID,
this.genderName,
this.isEmailVerified, this.isEmailVerified,
this.serviceProviderBranch, this.serviceProviderBranch,
this.isVerified, this.isVerified,
@ -97,6 +99,7 @@ class UserInfo {
this.userLocalImage, this.userLocalImage,
this.cityName, this.cityName,
this.countryName, this.countryName,
}); });
int? id; int? id;
@ -105,6 +108,8 @@ class UserInfo {
String? lastName; String? lastName;
String? countryName; String? countryName;
String? cityName; String? cityName;
int? genderID;
String? genderName;
String? mobileNo; String? mobileNo;
String? email; String? email;
dynamic userImageUrl; dynamic userImageUrl;
@ -139,6 +144,8 @@ class UserInfo {
firstName = json["firstName"]; firstName = json["firstName"];
lastName = json["lastName"]; lastName = json["lastName"];
cityName = json["cityName"]; cityName = json["cityName"];
genderID = json["genderID"];
genderName = json["genderName"];
countryName = json["countryName"]; countryName = json["countryName"];
mobileNo = json["mobileNo"]; mobileNo = json["mobileNo"];
email = json["email"]; email = json["email"];
@ -205,6 +212,8 @@ class UserInfo {
"providerID": providerId, "providerID": providerId,
"customerID": customerId, "customerID": customerId,
"dealershipID": dealershipId, "dealershipID": dealershipId,
"genderName": genderName,
"genderID": genderID
}; };
@override @override

@ -208,6 +208,7 @@ class BranchRepoImp implements BranchRepo {
"documentExt": documents[i].fileExt, "documentExt": documents[i].fileExt,
"documentImage": documents[i].document, "documentImage": documents[i].document,
"isActive": true, "isActive": true,
"dateExpire":documents[i].dateExpire,
}; };
map.add(postParams); map.add(postParams);
} }

@ -4,6 +4,8 @@ import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/generated/locale_keys.g.dart';
import 'package:mc_common_app/main.dart'; import 'package:mc_common_app/main.dart';
import 'package:mc_common_app/utils/app_permission_handler.dart'; import 'package:mc_common_app/utils/app_permission_handler.dart';
import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/utils/utils.dart';
@ -56,21 +58,35 @@ class CommonServicesImp implements CommonAppServices {
return pickedFiles; return pickedFiles;
} }
@override
Future<List<File>> pickMultipleImages() async { Future<List<File>> pickMultipleImages() async {
final picker = ImagePicker(); final picker = ImagePicker();
final pickedImagesXFiles = await picker.pickMultiImage(); List<File> imageModels = [];
List<File> pickedImages = []; List<File> pickedImages = [];
if (pickedImagesXFiles == null) { var images = await picker.pickMultiImage(imageQuality: 70);
return [];
} for (var element in images) {
if (pickedImagesXFiles.isEmpty) { final extension = element.path.split('.').last.toLowerCase();
return [];
if (extension != 'jpg' && extension != 'jpeg' && extension != 'png') {
Utils.showToast(LocaleKeys.onlyJPGandPNG);
return [];
}
if (await element.length() > GlobalConsts().maxFileSizeInBytes) {
Utils.showToast(LocaleKeys.maxFileSize);
return [];
}
imageModels.add(File(element.path));
} }
for (var element in pickedImagesXFiles) {
pickedImages.add(File(element.path)); if (imageModels.length > GlobalConsts().maxFileCount) {
Utils.showToast(LocaleKeys.maxFileSelection);
imageModels = imageModels.sublist(0, GlobalConsts().maxFileCount); // Keep only the first 7 images
} }
pickedImages.addAll(imageModels);
return pickedImages; return pickedImages;
} }

@ -81,7 +81,8 @@ class LocationService implements Location {
if (granted) { if (granted) {
Geolocator.getLastKnownPosition(forceAndroidLocationManager: true).then((value) { Geolocator.getLastKnownPosition(forceAndroidLocationManager: true).then((value) {
if (value == null) { if (value == null) {
Geolocator.getCurrentPosition().then((value) { Geolocator.getCurrentPosition().then((value) async {
if(value == null) await Geolocator.openAppSettings();
done(value); done(value);
}); });
} else { } else {

@ -1194,7 +1194,14 @@ class AdVM extends BaseVM {
for (var element in images) { for (var element in images) {
imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false)); imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false));
} }
pickedPostingImages.addAll(imageModels); pickedPostingImages.addAll(imageModels);
// Added By Aamir
if (pickedPostingImages.length > GlobalConsts().maxFileCount) {
pickedPostingImages = pickedPostingImages.sublist(0, GlobalConsts().maxFileCount);
Utils.showToast(LocaleKeys.maxFileSelection);
}
if (pickedPostingImages.isNotEmpty) vehicleImageError = ""; if (pickedPostingImages.isNotEmpty) vehicleImageError = "";
notifyListeners(); notifyListeners();
} }
@ -1237,7 +1244,13 @@ class AdVM extends BaseVM {
vehicleDamageCards[index].partImages = imageModels; vehicleDamageCards[index].partImages = imageModels;
} else { } else {
vehicleDamageCards[index].partImages!.addAll(imageModels); vehicleDamageCards[index].partImages!.addAll(imageModels);
// Added By Aamir
if (vehicleDamageCards[index].partImages!.length > GlobalConsts().maxFileCount) {
vehicleDamageCards[index].partImages = vehicleDamageCards[index].partImages!.sublist(0, GlobalConsts().maxFileCount);
Utils.showToast(LocaleKeys.maxFileSelection);
}
} }
vehicleDamageCards[index].partImageErrorValue = ""; vehicleDamageCards[index].partImageErrorValue = "";
notifyListeners(); notifyListeners();
} }
@ -1287,6 +1300,11 @@ class AdVM extends BaseVM {
void pickMultipleDamageImages() async { void pickMultipleDamageImages() async {
List<File> images = await commonServices.pickMultipleImages(); List<File> images = await commonServices.pickMultipleImages();
pickedDamageImages.addAll(images); pickedDamageImages.addAll(images);
if (pickedDamageImages.length > GlobalConsts().maxFileCount) {
pickedDamageImages = pickedDamageImages.sublist(0, GlobalConsts().maxFileCount);
Utils.showToast(LocaleKeys.maxFileSelection);
}
if (pickedDamageImages.isNotEmpty) vehicleDamageImageError = ""; if (pickedDamageImages.isNotEmpty) vehicleDamageImageError = "";
notifyListeners(); notifyListeners();
} }

@ -406,6 +406,11 @@ class ChatVM extends BaseVM {
imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false)); imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false));
} }
pickedImagesForMessage.addAll(imageModels); pickedImagesForMessage.addAll(imageModels);
if (pickedImagesForMessage.length > GlobalConsts().maxFileCount) {
pickedImagesForMessage = pickedImagesForMessage.sublist(0, GlobalConsts().maxFileCount);
Utils.showToast(LocaleKeys.maxFileSelection);
}
notifyListeners(); notifyListeners();
} }

@ -231,10 +231,17 @@ class RequestsVM extends BaseVM {
imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false)); imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false));
} }
pickedVehicleImages.addAll(imageModels); pickedVehicleImages.addAll(imageModels);
if (pickedVehicleImages.length > GlobalConsts().maxFileCount) {
pickedVehicleImages = pickedVehicleImages.sublist(0, GlobalConsts().maxFileCount);
Utils.showToast(LocaleKeys.maxFileSelection);
}
if (pickedVehicleImages.isNotEmpty) vehicleImageError = ""; if (pickedVehicleImages.isNotEmpty) vehicleImageError = "";
notifyListeners(); notifyListeners();
} }
bool isFetchingRequestType = false; bool isFetchingRequestType = false;
bool isFetchingVehicleType = true; bool isFetchingVehicleType = true;
bool isFetchingVehicleDetail = false; bool isFetchingVehicleDetail = false;

@ -132,6 +132,10 @@ class ServiceVM extends BaseVM {
imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false)); imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false));
} }
pickedBranchImages.addAll(imageModels); pickedBranchImages.addAll(imageModels);
if (pickedBranchImages.length > GlobalConsts().maxFileCount) {
pickedBranchImages = pickedBranchImages.sublist(0, GlobalConsts().maxFileCount);
Utils.showToast(LocaleKeys.maxFileSelection);
}
if (pickedBranchImages.isNotEmpty) branchImageError = ""; if (pickedBranchImages.isNotEmpty) branchImageError = "";
notifyListeners(); notifyListeners();
} }
@ -201,7 +205,6 @@ class ServiceVM extends BaseVM {
} }
branchServicesFilterOptions[serviceStatusEnum.getIdFromServiceStatusEnum() - 1].isSelected = true; // -1 to match with the index branchServicesFilterOptions[serviceStatusEnum.getIdFromServiceStatusEnum() - 1].isSelected = true; // -1 to match with the index
} }
// Future<String?> selectFile(BuildContext context, int index) async { // Future<String?> selectFile(BuildContext context, int index) async {
@ -264,11 +267,7 @@ class ServiceVM extends BaseVM {
context, context,
allowMultiple: false, allowMultiple: false,
); );
if (files != null && files.any((element) => if (files != null && files.any((element) => element.path.split('.').last.toLowerCase() != 'pdf')) {
element.path
.split('.')
.last
.toLowerCase() != 'pdf')) {
Utils.showToast("Only PDF Files are allowed"); Utils.showToast("Only PDF Files are allowed");
return; return;
} }
@ -279,11 +278,11 @@ class ServiceVM extends BaseVM {
isFromNetwork: false, isFromNetwork: false,
)); ));
} }
documentID == 1 // documentID == 1
? commerceCertificates.addAll(imageModels) // ? commerceCertificates.addAll(imageModels)
: documentID == 2 // : documentID == 2
? commercialCertificates.addAll(imageModels) // ? commercialCertificates.addAll(imageModels)
: vatCertificates.addAll(imageModels); // : vatCertificates.addAll(imageModels);
document!.data![index].document = Utils.convertFileToBase64(files.first); document!.data![index].document = Utils.convertFileToBase64(files.first);
document!.data![index].fileExt = Utils.checkFileExt(files.first.path); document!.data![index].fileExt = Utils.checkFileExt(files.first.path);
document!.data![index].documentUrl = files.first.path; document!.data![index].documentUrl = files.first.path;
@ -459,10 +458,10 @@ class ServiceVM extends BaseVM {
DropValue( DropValue(
element.id ?? 0, element.id ?? 0,
((element.categoryName!.isEmpty ((element.categoryName!.isEmpty
? "N/A" ? "N/A"
: countryCode == "SA" : countryCode == "SA"
? element.categoryNameN ? element.categoryNameN
: element.categoryName) ?? : element.categoryName) ??
"N/A"), "N/A"),
"", "",
), ),
@ -657,9 +656,7 @@ class ServiceVM extends BaseVM {
File file = File(imageModel.filePath!); File file = File(imageModel.filePath!);
List<int> imageBytes = await file.readAsBytes(); List<int> imageBytes = await file.readAsBytes();
String image = base64Encode(imageBytes); String image = base64Encode(imageBytes);
String fileName = file.path String fileName = file.path.split('/').last;
.split('/')
.last;
branchPostingImages = BranchPostingImages( branchPostingImages = BranchPostingImages(
imageName: fileName, imageName: fileName,
imageStr: image, imageStr: image,

@ -170,7 +170,7 @@ class UserVM extends BaseVM {
} }
} }
Future<void> userDetailsUpdate(BuildContext context, String firstName, String lastName, String? city) async { Future<void> userDetailsUpdate(BuildContext context, String firstName, String lastName, String? city, String? cityName, String? countryName) async {
Utils.showLoading(context); Utils.showLoading(context);
Map<String, dynamic> res = await userRepo.updateUserInfo(firstName, lastName, city); Map<String, dynamic> res = await userRepo.updateUserInfo(firstName, lastName, city);
Utils.hideLoading(context); Utils.hideLoading(context);
@ -180,6 +180,13 @@ class UserVM extends BaseVM {
if (localUser.data != null) { if (localUser.data != null) {
localUser.data!.userInfo!.firstName = res["data"]["firstName"]; localUser.data!.userInfo!.firstName = res["data"]["firstName"];
localUser.data!.userInfo!.lastName = res["data"]["lastName"]; localUser.data!.userInfo!.lastName = res["data"]["lastName"];
localUser.data!.userInfo!.cityId = res["data"]["cityID"];
localUser.data!.userInfo!.countryId = res["data"]["countryID"];
if (cityName != null && countryName != null) {
localUser.data!.userInfo!.cityName = cityName;
localUser.data!.userInfo!.countryName = countryName;
}
// localUser.data!.userInfo!.cityId = res["data"]["cityId"]; // localUser.data!.userInfo!.cityId = res["data"]["cityId"];
AppState().setUser = localUser; AppState().setUser = localUser;
} }
@ -205,7 +212,15 @@ class UserVM extends BaseVM {
if (Utils.passwordValidateStructure(password)) { if (Utils.passwordValidateStructure(password)) {
if (password == confirmPassword) { if (password == confirmPassword) {
Utils.showLoading(context); Utils.showLoading(context);
RegisterUserRespModel user = await userRepo.basicComplete(userId ?? "", firstName, lastName, email, password, cityID, genderID, isNeedToPassToken: isNeedToPassToken); RegisterUserRespModel user = await userRepo.basicComplete(
userId ?? "",
firstName,
lastName,
email,
password,
cityID,
genderID,
isNeedToPassToken: isNeedToPassToken);
Utils.hideLoading(context); Utils.hideLoading(context);
if (user.messageStatus == 1) { if (user.messageStatus == 1) {
Utils.showToast(LocaleKeys.successfullyRegistered.tr()); Utils.showToast(LocaleKeys.successfullyRegistered.tr());
@ -253,8 +268,7 @@ class UserVM extends BaseVM {
Utils.showToast(LocaleKeys.pleaseAcceptTerms.tr()); Utils.showToast(LocaleKeys.pleaseAcceptTerms.tr());
//("Please accept terms"); //("Please accept terms");
isValid = false; isValid = false;
} } else if (city == null) {
else if (city == null) {
Utils.showToast(LocaleKeys.cityNameMandatory.tr()); Utils.showToast(LocaleKeys.cityNameMandatory.tr());
isValid = false; isValid = false;
} else if (gender == null) { } else if (gender == null) {
@ -591,6 +605,8 @@ class UserVM extends BaseVM {
} }
Future<void> getAllCountriesForUser() async { Future<void> getAllCountriesForUser() async {
userCountries = null;
userCities = null;
userCountries = await userRepo.getAllCountries(); userCountries = await userRepo.getAllCountries();
notifyListeners(); notifyListeners();
} }

@ -19,6 +19,7 @@ import 'package:mc_common_app/views/advertisement/ad_creation_steps/ad_creation_
import 'package:mc_common_app/views/advertisement/components/picked_images_container_widget.dart'; import 'package:mc_common_app/views/advertisement/components/picked_images_container_widget.dart';
import 'package:mc_common_app/widgets/button/show_fill_button.dart'; import 'package:mc_common_app/widgets/button/show_fill_button.dart';
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart'; import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
import 'package:mc_common_app/widgets/common_widgets/search_entity_widget.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
import 'package:mc_common_app/widgets/txt_field.dart'; import 'package:mc_common_app/widgets/txt_field.dart';
@ -35,6 +36,7 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
late ServiceVM branchVM; late ServiceVM branchVM;
bool showAttachment = false; bool showAttachment = false;
String? attachedFile; String? attachedFile;
String? formattedDate;
@override @override
void initState() { void initState() {
@ -50,7 +52,7 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
if (model.document != null && model.document!.data != null && model.document!.data!.isNotEmpty) { if (model.document != null && model.document!.data != null && model.document!.data!.isNotEmpty) {
for (var doc in model.document!.data!) { for (var doc in model.document!.data!) {
log("doc: ${doc.status}"); log("doc: ${doc.status}");
if (doc.status == 4 || doc.status == 0) { if (doc.status == DocumentStatusEnum.rejected || doc.status == DocumentStatusEnum.needUpload || doc.isAllowUpdate!) {
isShow = true; isShow = true;
} }
} }
@ -162,6 +164,7 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
padding: const EdgeInsets.symmetric(horizontal: 20), padding: const EdgeInsets.symmetric(horizontal: 20),
itemBuilder: (context, index) { itemBuilder: (context, index) {
DocumentData? document = serviceVM.document?.data![index]; DocumentData? document = serviceVM.document?.data![index];
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -172,40 +175,58 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
(document!.documentName!).toText(fontSize: 16, letterSpacing: -0.56, fontWeight: MyFonts.SemiBold), (document!.documentName!).toText(fontSize: 16, letterSpacing: -0.56, fontWeight: MyFonts.SemiBold),
if (document.statusText != null && document.statusText!.isNotEmpty) ...[ if (document.statusText != null && document.statusText!.isNotEmpty) ...[
10.width, 10.width,
Utils.statusContainerChip(text: document.statusText!.replaceFirst('OrActive', ''), chipColor: getColorByStatus(document.status ?? 1)), Utils.statusContainerChip(text: document.statusText!.replaceFirst('OrActive', ''), chipColor: getColorByStatus(document.status!)),
], ],
], ],
), ),
// if (document.status != 1 && document.status != 3) ...[ if (document.documentUrl != null) ...[
// Padding( BuildFilesContainer(
// padding: const EdgeInsets.only(top: 4, bottom: 8), image: ImageModel(id: index, filePath: document.documentUrl!, isFromNetwork: document.isLocalFile! ? false : true),
// child: LocaleKeys.enter_licence_detail.tr().toText(fontSize: 14, color: MyColors.lightTextColor), onCrossPressedPrimary: (String val) {
// ), document.documentUrl = null;
// TxtField( document.isLocalFile = false;
// hint: LocaleKeys.description.tr(), setState(() {});
// maxLines: 3, },
// isBackgroundEnabled: true, index: index,
// ), isReview: isReview(document),
// ],
10.height,
if (isNeedToShow(model: serviceVM, document: document)) ...[
PickedFilesContainer(
isReview: document.status != 0 && (document.status == 1 || document.status == 3),
allowAdButton: false,
pickedFiles: isLocalOrNetworkFiles(model: serviceVM, document: document),
onCrossPressedPrimary: isNetworkImage(document: document)
? serviceVM.removeNetworkImage
: document.documentId == 1
? serviceVM.commerceRemove
: document.documentId == 2
? serviceVM.commercialRemove
: serviceVM.vatRemove,
isPdf: true, isPdf: true,
isFromNetwork: !(document.isLocalFile ?? false), ),
onAddFilePressed: () { 5.height,
serviceVM.pickPdfReceiptFile(context, document.documentId!, index); ("${document.documentName} Expiry").toText(fontSize: 14, letterSpacing: -0.56, fontWeight: MyFonts.Medium),
5.height,
TxtField(
isBackgroundEnabled: (document.status == DocumentStatusEnum.pending || document.status == DocumentStatusEnum.approvedOrActive && !document.isAllowUpdate!),
isNeedBorder: document.isAllowUpdate! ? true : false,
isSidePaddingZero: true,
hint: LocaleKeys.expiryDate.tr(),
value: document.dateExpire != null && document.status == DocumentStatusEnum.pending || document.status == DocumentStatusEnum.approvedOrActive ? "${DateFormat('yyyy-MM-dd').format(
DateTime.parse(document.dateExpire!))}" : formattedDate == null
? ""
: "${DateFormat('yyyy-MM-dd').format(DateTime.parse(document.dateExpire!))}",
isNeedClickAll: true,
postFixDataColor: MyColors.darkTextColor,
onTap: () async {
if (document.isAllowUpdate! && document.status == DocumentStatusEnum.approvedOrActive || document.status == DocumentStatusEnum.needUpload ||
document.status == DocumentStatusEnum.rejected) {
formattedDate =
await Utils.pickDateFromDatePicker(context, lastDate: DateTime(DateTime
.now()
.year + 3, DateTime
.now()
.month + 1, DateTime
.now()
.day), firstDate: DateTime.now());
if (formattedDate!.isNotEmpty) {
document.dateExpire = formattedDate;
setState(() {});
}
}
// requestsVM.updateRequestedDate(formattedDate);
}, },
), ),
10.height,
buildCommentContainer(document: document), buildCommentContainer(document: document),
] else ] else
...[ ...[
@ -215,107 +236,133 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
text: LocaleKeys.attachPDF.tr(), text: LocaleKeys.attachPDF.tr(),
icon: MyAssets.attachmentIcon.buildSvg(), icon: MyAssets.attachmentIcon.buildSvg(),
), ),
], ]
], ],
); );
}, },
); );
} }
List<ImageModel> isLocalOrNetworkFiles({required ServiceVM model, required DocumentData document}) { bool isReview(DocumentData document) {
bool isNetworkImage = false; print(document.toJson());
bool val = false;
if (!document.isLocalFile!) { if (document.isAllowUpdate == null) {
isNetworkImage = document.documentUrl != null && document.documentUrl!.isNotEmpty ? true : false; val = false;
} }
if (isNetworkImage) { if (document.isAllowUpdate! && document.status == DocumentStatusEnum.approvedOrActive) {
return [ImageModel(id: document.id, isFromNetwork: isNetworkImage, filePath: document.documentUrl)]; val = false;
} else if (document.documentId == 1) {
return model.commerceCertificates;
} else if (document.documentId == 2) {
return model.commercialCertificates;
} else {
return model.vatCertificates;
} }
} if (!document.isAllowUpdate! && document.status == DocumentStatusEnum.approvedOrActive) {
val = true;
bool isNeedToShow({required ServiceVM model, required DocumentData document}) {
bool allow = false;
bool isNetworkImage = document.documentUrl != null && document.documentUrl!.isNotEmpty && !(document.isLocalFile ?? true);
if (isNetworkImage) {
allow = true;
} else {
if (document.documentId == 1 && model.commerceCertificates.isNotEmpty) {
allow = true;
}
if (document.documentId == 2 && model.commercialCertificates.isNotEmpty) {
allow = true;
}
if (document.documentId == 3 && model.vatCertificates.isNotEmpty) {
allow = true;
}
} }
return allow; if (document.isAllowUpdate! && document.status == DocumentStatusEnum.pending) {
} val = true;
dynamic checkOnCrossPress({required ServiceVM model, required DocumentData document}) async {
bool isNetworkImage = document.documentUrl != null && document.documentUrl!.isNotEmpty ? true : false;
if (isNetworkImage) {
return document.documentUrl;
} else {
if (document.documentId == 1) {
model.commerceRemove;
}
if (document.documentId == 2) {
model.commercialRemove;
}
if (document.documentId == 3) {
model.vatRemove;
}
} }
} if (document.isAllowUpdate! && document.status == DocumentStatusEnum.rejected) {
val = false;
bool isNetworkImage({required DocumentData document}) { }
bool isNetworkImage = false; if (document.isAllowUpdate! && document.status == DocumentStatusEnum.needUpload) {
if (!document.isLocalFile!) { val = true;
isNetworkImage = document.documentUrl != null && document.documentUrl!.isNotEmpty ? true : false;
} }
return isNetworkImage; if (document.isAllowUpdate! && document.status == DocumentStatusEnum.review) {
val = true;
}
return val;
} }
Widget buildCommentContainer({required DocumentData document}) { // List<ImageModel> isLocalOrNetworkFiles({required ServiceVM model, required DocumentData document}) {
String comment = ""; // bool isNetworkImage = false;
if (document.status == 4 && document.comment != null) { // print(document);
comment = document.comment ?? ""; // if (!document.isLocalFile!) {
} // isNetworkImage = document.documentUrl != null && document.documentUrl!.isNotEmpty ? true : false;
// }
// if (isNetworkImage) {
// return [ImageModel(id: document.id, isFromNetwork: isNetworkImage, filePath: document.documentUrl)];
// } else {
// return [ImageModel(id: document.id, isFromNetwork: false, filePath: document.documentUrl)];
// ;
// }
// }
if (comment.isEmpty) { // bool isNeedToShow({required ServiceVM model, required DocumentData document}) {
return const SizedBox(); // bool allow = false;
} // bool isNetworkImage = document.documentUrl != null && document.documentUrl!.isNotEmpty && !(document.isLocalFile ?? true);
return Center(child: comment.toString().toText(color: MyColors.adCancelledStatusColor, fontSize: 14)).toContainer( // if (isNetworkImage) {
borderRadius: 8, // allow = true;
margin: const EdgeInsets.only(top: 10), // } else {
width: double.infinity, // if (document.documentId == 1 && document.documentUrl!.isNotEmpty) {
backgroundColor: MyColors.adCancelledStatusColor.withOpacity(0.16), // allow = true;
); // }
// if (document.documentId == 2 && document.documentUrl!.isNotEmpty) {
// allow = true;
// }
// if (document.documentId == 3 && document.documentUrl!.isNotEmpty) {
// allow = true;
// }
// }
// return allow;
// }
//
// dynamic checkOnCrossPress({required ServiceVM model, required DocumentData document}) async {
// bool isNetworkImage = document.documentUrl != null && document.documentUrl!.isNotEmpty ? true : false;
// if (isNetworkImage) {
// print(document.documentUrl);
// return document.documentUrl;
// }
//} else {
// if (document.documentId == 1) {
// model.commerceRemove;
// }
// if (document.documentId == 2) {
// model.commercialRemove;
// }
// if (document.documentId == 3) {
// model.vatRemove;
// }
// }
}
bool isNetworkImage({required DocumentData document}) {
bool isNetworkImage = false;
if (!document.isLocalFile!) {
isNetworkImage = document.documentUrl != null && document.documentUrl!.isNotEmpty ? true : false;
}
return isNetworkImage;
}
Widget buildCommentContainer({required DocumentData document}) {
String comment = "";
if (document.status == 4 && document.comment != null) {
comment = document.comment ?? "";
} }
Color getColorByStatus(int docStatus) { if (comment.isEmpty) {
switch (docStatus) { return const SizedBox();
case 1: }
return MyColors.adPendingStatusColor; return Center(child: comment.toString().toText(color: MyColors.adCancelledStatusColor, fontSize: 14)).toContainer(
borderRadius: 8,
margin: const EdgeInsets.only(top: 10),
width: double.infinity,
backgroundColor: MyColors.adCancelledStatusColor.withOpacity(0.16),
);
}
case 2: Color getColorByStatus(DocumentStatusEnum docStatus) {
return MyColors.adActiveStatusColor; switch (docStatus) {
case DocumentStatusEnum.pending:
return MyColors.adPendingStatusColor;
case 3: case DocumentStatusEnum.approvedOrActive:
return MyColors.greenColor; return MyColors.adActiveStatusColor;
case 4: case DocumentStatusEnum.rejected:
return MyColors.adCancelledStatusColor; return MyColors.adCancelledStatusColor;
default: case DocumentStatusEnum.needUpload:
return MyColors.adPendingStatusColor; return MyColors.adPendingStatusColor;
} default:
return MyColors.adPendingStatusColor;
} }
} }

@ -79,7 +79,6 @@ class _RegisterPageState extends State<RegisterCustomerPage> {
DropdownField( DropdownField(
dropdownValue: selectedDrop, dropdownValue: selectedDrop,
(DropValue value) { (DropValue value) {
print("========");
selectedDrop = value; selectedDrop = value;
AppState().setUserRegisterCountrySelection = value; AppState().setUserRegisterCountrySelection = value;
setState(() { setState(() {

@ -3,6 +3,7 @@ import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/generated/locale_keys.g.dart'; import 'package:mc_common_app/generated/locale_keys.g.dart';
import 'package:mc_common_app/models/general_models/widgets_models.dart'; import 'package:mc_common_app/models/general_models/widgets_models.dart';
import 'package:mc_common_app/utils/utils.dart';
import 'package:mc_common_app/view_models/ad_view_model.dart'; import 'package:mc_common_app/view_models/ad_view_model.dart';
import 'package:mc_common_app/view_models/user_view_model.dart'; import 'package:mc_common_app/view_models/user_view_model.dart';
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart'; import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
@ -26,10 +27,19 @@ class _UpdateUserCityCountryState extends State<UpdateUserCityCountry> {
@override @override
void initState() { void initState() {
print(AppState().getUser!.data!.userInfo!.toJson());
context.read<UserVM>().getAllCountriesForUser(); context.read<UserVM>().getAllCountriesForUser();
super.initState(); super.initState();
} }
@override
void dispose() {
city = null;
country = null;
print(" Dispose Called");
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer(builder: (BuildContext context, UserVM uVM, Widget? child) { return Consumer(builder: (BuildContext context, UserVM uVM, Widget? child) {
@ -41,50 +51,56 @@ class _UpdateUserCityCountryState extends State<UpdateUserCityCountry> {
children: [ children: [
uVM.userCountries != null uVM.userCountries != null
? Container( ? Container(
padding: const EdgeInsets.only(right: 20, left: 20, top: 12), padding: const EdgeInsets.only(right: 20, left: 20, top: 12),
child: Builder(builder: (context) { child: Builder(builder: (context) {
List<DropValue> userCountryDrop = []; List<DropValue> userCountryDrop = [];
for (var element in uVM.userCountries!.data!) { for (var element in uVM.userCountries!.data!) {
if (AppState().getUser.data!.userInfo!.countryId == element.id) { var countryid = country == null ? AppState().getUser.data!.userInfo!.countryId : country!.id;
country = DropValue(element.id?.toInt() ?? 0, element.countryName ?? "", ""); print("Country ID" + countryid.toString());
} if (countryid == element.id) {
userCountryDrop.add(DropValue(element.id?.toInt() ?? 0, element.countryName ?? "", "")); print("Country Matched");
} country = DropValue(element.id?.toInt() ?? 0, element.countryName ?? "", "");
return DropdownField( }
userCountryDrop.add(DropValue(element.id?.toInt() ?? 0, element.countryName ?? "", ""));
}
return DropdownField(
(DropValue value) async { (DropValue value) async {
country = value; country = value;
await uVM.getAllCitiesForUser(country!.id); city = null;
setState(() {}); await uVM.getAllCitiesForUser(country!.id);
}, setState(() {});
list: userCountryDrop, },
dropdownValue: country != null && country != -1 ? DropValue(country!.id, country!.value, "") : null, list: userCountryDrop,
hint: country != null && country != -1 ? country!.value : "${LocaleKeys.country.tr()} *", dropdownValue: country != null && country != -1 ? DropValue(country!.id, country!.value, "") : null,
// errorValue: adVM.vehicleCountryId.errorValue, hint: country != null && country != -1 ? country!.value : "${LocaleKeys.country.tr()} *",
); // errorValue: adVM.vehicleCountryId.errorValue,
})) );
}))
: SizedBox(), : SizedBox(),
uVM.userCities != null uVM.userCities != null && uVM.userCities!.data!.isNotEmpty
? Container( ? Container(
padding: const EdgeInsets.only(right: 20, left: 20, top: 12), padding: const EdgeInsets.only(right: 20, left: 20, top: 12),
child: Builder(builder: (context) { child: Builder(builder: (context) {
List<DropValue> userCityDrop = []; List<DropValue> userCityDrop = [];
for (var element in uVM.userCities!.data!) { for (var element in uVM.userCities!.data!) {
if (AppState().getUser.data!.userInfo!.cityId == element.id) { var cid = city == null ? AppState().getUser.data!.userInfo!.cityId : city!.id;
city = DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", ""); print("City ID" + cid.toString());
} if (cid == element.id) {
userCityDrop.add(DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", "")); city = DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", "");
} }
return DropdownField( userCityDrop.add(DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", ""));
}
return DropdownField(
(DropValue value) { (DropValue value) {
city = value; city = value;
setState(() {}); setState(() {});
}, },
list: userCityDrop, list: userCityDrop,
dropdownValue: city != null && city != -1 ? DropValue(city!.id, city!.value, "") : null, dropdownValue: city != null && city!.id != -1 ? DropValue(city!.id, city!.value, "") : null,
hint: city != null && city != -1 ? city!.value : "${LocaleKeys.city.tr()} *", hint: city != null && city != -1 ? city!.value : "${LocaleKeys.city.tr()} *",
// errorValue: adVM.vehicleCountryId.errorValue, // errorValue: uVM.userCities!.data!.isEmpty ? "No Cities Found" : "",
); );
})) }))
: SizedBox(), : SizedBox(),
20.height, 20.height,
Padding( Padding(
@ -93,7 +109,9 @@ class _UpdateUserCityCountryState extends State<UpdateUserCityCountry> {
title: LocaleKeys.confirm.tr(), title: LocaleKeys.confirm.tr(),
maxWidth: double.infinity, maxWidth: double.infinity,
onPressed: () async { onPressed: () async {
await uVM.userDetailsUpdate(context, AppState().getUser.data!.userInfo!.firstName!, AppState().getUser.data!.userInfo!.lastName!, city != null ? city?.id.toString() : null);
await uVM.userDetailsUpdate(
context, AppState().getUser.data!.userInfo!.firstName!, AppState().getUser.data!.userInfo!.lastName!, city != null ? city?.id.toString() : null, city!.value, country!.value);
}, },
), ),
), ),

@ -1,3 +1,4 @@
import 'package:mc_common_app/classes/app_state.dart';
import 'package:mc_common_app/extensions/int_extensions.dart'; import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/generated/locale_keys.g.dart'; import 'package:mc_common_app/generated/locale_keys.g.dart';
@ -55,8 +56,7 @@ class _UpdateUserDetailsState extends State<UpdateUserDetails> {
title: LocaleKeys.confirm.tr(), title: LocaleKeys.confirm.tr(),
maxWidth: double.infinity, maxWidth: double.infinity,
onPressed: () async { onPressed: () async {
await userVM.userDetailsUpdate(context, firstname, lastname, null); await userVM.userDetailsUpdate(context, firstname, lastname, AppState().getUser.data!.userInfo!.cityId!.toString(), null, null);
}, },
), ),
], ],

Loading…
Cancel
Save