master_new_changes
Aamir.Muhammad 1 year ago
parent 15577c3cfb
commit f5a71aa15b

@ -21,16 +21,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"] == null ? null : json["totalItemsCount"], totalItemsCount: json["totalItemsCount"] == null ? null : 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"] == null ? null : json["messageStatus"], messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
message: json["message"] == null ? null : json["message"], message: json["message"] == null ? null : json["message"],
); );
Map<String, dynamic> toJson() => Map<String, dynamic> toJson() => {
{
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount, "totalItemsCount": totalItemsCount == null ? null : 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 == null ? null : messageStatus, "messageStatus": messageStatus == null ? null : messageStatus,
@ -39,7 +37,19 @@ class Document {
} }
class DocumentData { class DocumentData {
DocumentData({this.id, this.serviceProviderId, this.documentId, this.documentUrl, this.status, this.comment, this.isActive, this.document, this.fileExt, this.documentName}); DocumentData({
this.id,
this.serviceProviderId,
this.documentId,
this.documentUrl,
this.status,
this.comment,
this.isActive,
this.document,
this.fileExt,
this.documentName,
this.isLocalFile,
});
int? id; int? id;
int? serviceProviderId; int? serviceProviderId;
@ -51,9 +61,9 @@ class DocumentData {
String? document; String? document;
String? fileExt; String? fileExt;
String? documentName; String? documentName;
bool? isLocalFile;
factory DocumentData.fromJson(Map<String, dynamic> json) => factory DocumentData.fromJson(Map<String, dynamic> json) => DocumentData(
DocumentData(
id: json["id"] == null ? null : json["id"], id: json["id"] == null ? null : json["id"],
serviceProviderId: json["serviceProviderID"] == null ? null : json["serviceProviderID"], serviceProviderId: json["serviceProviderID"] == null ? null : json["serviceProviderID"],
documentId: json["documentID"] == null ? null : json["documentID"], documentId: json["documentID"] == null ? null : json["documentID"],
@ -64,10 +74,9 @@ class DocumentData {
document: null, document: null,
fileExt: null, fileExt: null,
documentName: json["documentName"] == null ? null : json["documentName"], documentName: json["documentName"] == null ? null : json["documentName"],
); isLocalFile: false);
Map<String, dynamic> toJson() => Map<String, dynamic> toJson() => {
{
"id": id == null ? null : id, "id": id == null ? null : id,
"serviceProviderID": serviceProviderId == null ? null : serviceProviderId, "serviceProviderID": serviceProviderId == null ? null : serviceProviderId,
"documentID": documentId == null ? null : documentId, "documentID": documentId == null ? null : documentId,

@ -109,4 +109,6 @@ class CommonServicesImp implements CommonAppServices {
return 0.0; return 0.0;
} }
} }
} }

@ -65,6 +65,7 @@ class ServiceVM extends BaseVM {
List<ImageModel> commerceCertificates = []; List<ImageModel> commerceCertificates = [];
List<ImageModel> commercialCertificates = []; List<ImageModel> commercialCertificates = [];
List<ImageModel> vatCertificates = []; List<ImageModel> vatCertificates = [];
List<CategoryData> categories = [];
void updateSelectionOpenTime(String date) { void updateSelectionOpenTime(String date) {
openTime = date; openTime = date;
@ -119,59 +120,101 @@ class ServiceVM extends BaseVM {
notifyListeners(); notifyListeners();
} }
// Future<String?> selectFile(BuildContext context, int index) async { filterUserBranchCategories() {
// final status = await AppPermissions.checkStoragePermissions(context); categories = [];
// if (status) { print("Filter Branch Executed");
// final File? file = await commonServices.pickFile( List<BranchDetailModel>? localbranches;
// context, if (branches!.data != null) {
// fileType: FileType.custom, if (selectedBranchStatus == 3) {
// allowedExtensions: ['png', 'pdf', 'jpeg'], localbranches = branches!.data!.serviceProviderBranch!.where((element) => element.statusId == 3).toList();
// ); } else {
// if (file != null) { localbranches = branches!.data!.serviceProviderBranch!.where((element) => element.statusId != 3).toList();
// int sizeInBytes = file.lengthSync(); }
// // double sizeInMb = sizeInBytes / (1024 * 1024); }
// if (sizeInBytes > 1000000) {
// Utils.showToast(LocaleKeys.fileLarger.tr()); for (var branch in localbranches!) {
// } else { for (var element in branch.branchServices!) {
// document!.data![index].document = Utils.convertFileToBase64(file); categories.add(
// document!.data![index].fileExt = Utils.checkFileExt(file.path); CategoryData(
// document!.data![index].documentUrl = file.path; id: element.categoryId,
// setState(ViewState.idle); categoryName: element.categoryName,
// // return document!.data![index].document; categoryNameN: element.categoryName,
// } ),
// } else { );
// // User canceled the picker }
// } categories = categories.toSet().toList();
// } for (var payment in categories) {
// } for (var element in branch.branchServices!) {
if (payment.id == element.categoryId) {
// Future<String?> selectFile(BuildContext context, int index) async { payment.services ??= [];
// File? file = await commonServices.pickFile(context, fileType: FileType.custom, allowedExtensions: ['png', 'pdf', 'jpeg']); payment.services!.add(element);
// }
// if (file != null) { }
// int sizeInBytes = file.lengthSync(); }
// // double sizeInMb = sizeInBytes / (1024 * 1024); }
// if (sizeInBytes > 1000000) {
// Utils.showToast(LocaleKeys.fileLarger.tr()); categories = categories;
// } else { }
// document!.data![index].document = Utils.convertFileToBase64(file);
// document!.data![index].fileExt = Utils.checkFileExt(file.path); // Future<String?> selectFile(BuildContext context, int index) async {
// document!.data![index].documentUrl = file.path; // final status = await AppPermissions.checkStoragePermissions(context);
// document!.data![index].isFileAttached = true; // if (status) {
// return Utils.convertFileToBase64(file); // final File? file = await commonServices.pickFile(
// } // context,
// } else { // fileType: FileType.custom,
// // User canceled the picker // allowedExtensions: ['png', 'pdf', 'jpeg'],
// } // );
// return null; // if (file != null) {
// } // int sizeInBytes = file.lengthSync();
// // double sizeInMb = sizeInBytes / (1024 * 1024);
// if (sizeInBytes > 1000000) {
// Utils.showToast(LocaleKeys.fileLarger.tr());
// } else {
// document!.data![index].document = Utils.convertFileToBase64(file);
// document!.data![index].fileExt = Utils.checkFileExt(file.path);
// document!.data![index].documentUrl = file.path;
// setState(ViewState.idle);
// // return document!.data![index].document;
// }
// } else {
// // User canceled the picker
// }
// }
// }
// Future<String?> selectFile(BuildContext context, int index) async {
// File? file = await commonServices.pickFile(context, fileType: FileType.custom, allowedExtensions: ['png', 'pdf', 'jpeg']);
//
// if (file != null) {
// int sizeInBytes = file.lengthSync();
// // double sizeInMb = sizeInBytes / (1024 * 1024);
// if (sizeInBytes > 1000000) {
// Utils.showToast(LocaleKeys.fileLarger.tr());
// } else {
// document!.data![index].document = Utils.convertFileToBase64(file);
// document!.data![index].fileExt = Utils.checkFileExt(file.path);
// document!.data![index].documentUrl = file.path;
// document!.data![index].isFileAttached = true;
// return Utils.convertFileToBase64(file);
// }
// } else {
// // User canceled the picker
// }
// return null;
// }
Future<void> pickPdfReceiptFile(BuildContext context, int documentID, int index) async { Future<void> pickPdfReceiptFile(BuildContext context, int documentID, int index) async {
List<ImageModel> imageModels = []; List<ImageModel> imageModels = [];
List<File>? files = await commonServices.pickMultipleFiles(context, allowMultiple: false); List<File>? files = await commonServices.pickMultipleFiles(
context,
allowMultiple: false,
);
if (files == null) return null; if (files == null) return null;
for (var element in files) { for (var element in files) {
imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false)); imageModels.add(ImageModel(
filePath: element.path,
isFromNetwork: false,
));
} }
documentID == 1 documentID == 1
? commerceCertificates.addAll(imageModels) ? commerceCertificates.addAll(imageModels)
@ -181,6 +224,7 @@ class ServiceVM extends BaseVM {
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;
document!.data![index].isLocalFile = true;
notifyListeners(); notifyListeners();
} }
@ -193,6 +237,16 @@ class ServiceVM extends BaseVM {
notifyListeners(); notifyListeners();
} }
Future<void> removeNetworkImag(String filePath) async {
int index = document!.data!.indexWhere((element) => element.documentUrl == filePath);
if (index == -1) {
return;
}
document!.data![index].documentUrl = null;
document!.data![index].isLocalFile = true;
notifyListeners();
}
Future<void> commercialRemove(String filePath) async { Future<void> commercialRemove(String filePath) async {
int index = commercialCertificates.indexWhere((element) => element.filePath == filePath); int index = commercialCertificates.indexWhere((element) => element.filePath == filePath);
if (index == -1) { if (index == -1) {
@ -215,7 +269,7 @@ class ServiceVM extends BaseVM {
return await branchRepo.serviceProviderDocumentsUpdate(data); return await branchRepo.serviceProviderDocumentsUpdate(data);
} }
// Create new branch // Create new branch
Future<void> getBranchAndServices() async { Future<void> getBranchAndServices() async {
setState(ViewState.busy); setState(ViewState.busy);
branches = await branchRepo.getBranchAndServices(); branches = await branchRepo.getBranchAndServices();
@ -319,7 +373,7 @@ class ServiceVM extends BaseVM {
pickedBranchImages.clear(); pickedBranchImages.clear();
} }
// Create Services // Create Services
Services? services; Services? services;
List<DropValue> categoryDropList = []; List<DropValue> categoryDropList = [];
List<DropValue> servicesDropList = []; List<DropValue> servicesDropList = [];
@ -382,7 +436,9 @@ class ServiceVM extends BaseVM {
} }
Future<GenericRespModel> createService(List<Map<String, dynamic>> map) async { Future<GenericRespModel> createService(List<Map<String, dynamic>> map) async {
setState(ViewState.busy);
return await branchRepo.createService(map); return await branchRepo.createService(map);
setState(ViewState.idle);
} }
Future<GenericRespModel> updateServices(List<Map<String, dynamic>> map) async { Future<GenericRespModel> updateServices(List<Map<String, dynamic>> map) async {
@ -435,7 +491,7 @@ class ServiceVM extends BaseVM {
return await branchRepo.duplicateItems(map); return await branchRepo.duplicateItems(map);
} }
// Branch Users // Branch Users
List<BranchUser> allProviderDealersList = []; List<BranchUser> allProviderDealersList = [];
List<BranchUser> branchUserList = []; List<BranchUser> branchUserList = [];
@ -449,6 +505,28 @@ class ServiceVM extends BaseVM {
setState(ViewState.idle); setState(ViewState.idle);
} }
// filterUserBranchCategories() {
// for (var element in branchData.branchServices!) {
// categories.add(
// CategoryData(
// id: element.categoryId,
// categoryName: element.categoryName,
// categoryNameN: element.categoryName,
// ),
// );
// }
// categories = categories.toSet().toList();
// for (var payment in categories) {
// for (var element in branchData.branchServices!) {
// if (payment.id == element.categoryId) {
// payment.services ??= [];
// payment.services!.add(element);
// }
// }
// }
// branchData.categories = categories;
// }
Future<void> getBranchUsers(Map<String, dynamic> map) async { Future<void> getBranchUsers(Map<String, dynamic> map) async {
setState(ViewState.busy); setState(ViewState.busy);
GenericRespModel response = await branchRepo.getBranchUsers(map); GenericRespModel response = await branchRepo.getBranchUsers(map);
@ -482,7 +560,9 @@ 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.split('/').last; String fileName = file.path
.split('/')
.last;
branchPostingImages = BranchPostingImages( branchPostingImages = BranchPostingImages(
imageName: fileName, imageName: fileName,
imageStr: image, imageStr: image,

@ -24,7 +24,7 @@ class _CarouselWithIndicatorState extends State<ImagesCorouselWidget> {
if (widget.imagesList.isEmpty) { if (widget.imagesList.isEmpty) {
return Center( return Center(
child: SizedBox( child: SizedBox(
height: 25.h, height: 26.h,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@ -39,11 +39,12 @@ class _CarouselWithIndicatorState extends State<ImagesCorouselWidget> {
); );
} }
return SizedBox( return SizedBox(
height: 25.h, height: 26.h,
child: Column(children: [ child: ListView(shrinkWrap: true, children: [
CarouselSlider( CarouselSlider(
items: widget.imagesList items: widget.imagesList
.map((item) => Container( .map((item) =>
Container(
margin: const EdgeInsets.all(5.0), margin: const EdgeInsets.all(5.0),
child: ClipRRect( child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(5.0)), borderRadius: const BorderRadius.all(Radius.circular(5.0)),
@ -64,7 +65,10 @@ class _CarouselWithIndicatorState extends State<ImagesCorouselWidget> {
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: widget.imagesList.asMap().entries.map((entry) { children: widget.imagesList
.asMap()
.entries
.map((entry) {
return GestureDetector( return GestureDetector(
onTap: () => _controller.animateToPage(entry.key), onTap: () => _controller.animateToPage(entry.key),
child: Container( child: Container(

@ -34,7 +34,7 @@ class AdsListWidget extends StatelessWidget {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
LocaleKeys.noAdsShow.tr().toText(fontSize: 16, color: MyColors.lightTextColor), LocaleKeys.noAdsShow.tr().toText(fontSize: 16, color: MyColors.lightTextColor, fontWeight: MyFonts.Medium),
], ],
); );
} }

@ -37,7 +37,7 @@ class _DamagePicturesListState extends State<DamagePicturesList> {
return Center(child: CircularProgressIndicator()); return Center(child: CircularProgressIndicator());
} }
return appointmentsVM.serviceItemsFromApi.isEmpty return appointmentsVM.serviceItemsFromApi.isEmpty
? const EmptyWidget() ? const EmptyWidget(text: "No Items Found", isWrapedColumn: false,)
: ListView.separated( : ListView.separated(
itemCount: appointmentsVM.serviceItemsFromApi.length, itemCount: appointmentsVM.serviceItemsFromApi.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {

@ -167,7 +167,7 @@ class AppointmentHomeTileWidget extends StatelessWidget {
height: 19 / 12, height: 19 / 12,
) )
: const SizedBox(), : const SizedBox(),
(AppState().currentAppType == AppType.provider ? appointmentListModel!.providerName ?? "" : appointmentListModel!.branchName ?? "").toText(color: MyColors.black, fontSize: 16, letterSpacing: -0.64, height: 24 / 16), (AppState().currentAppType == AppType.provider ? appointmentListModel!.customerName ?? "" : appointmentListModel!.branchName ?? "").toText(color: MyColors.black, fontSize: 16, letterSpacing: -0.64, height: 24 / 16),
Row( Row(
children: [ children: [
!isForProvider ? MyAssets.miniClock.buildSvg(height: 12) : const SizedBox(), !isForProvider ? MyAssets.miniClock.buildSvg(height: 12) : const SizedBox(),

@ -15,6 +15,7 @@ import 'package:mc_common_app/models/provider_branches_models/profile/document.d
import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/enums.dart';
import 'package:mc_common_app/utils/utils.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/service_view_model.dart'; import 'package:mc_common_app/view_models/service_view_model.dart';
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';
@ -40,8 +41,8 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
void initState() { void initState() {
super.initState(); super.initState();
scheduleMicrotask(() { scheduleMicrotask(() {
branchVM = Provider.of<ServiceVM>(context, listen: false); // branchVM = Provider.of<ServiceVM>(context, listen: false);
branchVM.getServiceProviderDocument(AppState().getUser.data!.userInfo!.providerId ?? 0); context.read<ServiceVM>().getServiceProviderDocument(AppState().getUser.data!.userInfo!.providerId ?? 0);
}); });
} }
@ -106,11 +107,11 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
updateDocument(ServiceVM model) async { updateDocument(ServiceVM model) async {
Utils.showLoading(context); Utils.showLoading(context);
GenericRespModel res = await model.updateDocument(model.document!.data); GenericRespModel res = await model.updateDocument(model.document!.data);
Utils.hideLoading(context); Utils.hideLoading(context);
if (res.messageStatus == 1) { if (res.messageStatus == 1) {
Utils.showToast(LocaleKeys.documentsUploadedSuccessfully.tr()); Utils.showToast(LocaleKeys.documentsUploadedSuccessfully.tr());
Navigator.of(context).pop();
} else { } else {
Utils.showToast(res.message ?? ""); Utils.showToast(res.message ?? "");
} }
@ -138,27 +139,24 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
isBackgroundEnabled: true, isBackgroundEnabled: true,
), ),
10.height, 10.height,
if (document.documentId == 1 if (isNeedToShow(model: model, document: document)) ...[
? model.commerceCertificates.isNotEmpty
: document.documentId == 2
? model.commercialCertificates.isNotEmpty
: model.vatCertificates.isNotEmpty) ...[
PickedFilesContainer( PickedFilesContainer(
pickedFiles: document.documentId == 1 // isReview: document.status == 3 ? true : false,
? model.commerceCertificates pickedFiles: isLocalOrNetworkFiles(model: model, document: document),
: document.documentId == 2 onCrossPressedPrimary: chkIsLocalOrNetwork(document: document)
? model.commercialCertificates ? model.removeNetworkImag
: model.vatCertificates, : document.documentId == 1
onCrossPressedPrimary: document.documentId == 1
? model.commerceRemove ? model.commerceRemove
: document.documentId == 2 : document.documentId == 2
? model.commercialRemove ? model.commercialRemove
: model.vatRemove, : model.vatRemove,
isPdf: model.document!.data![index].fileExt == "pdf", isPdf: model.document!.data![index].fileExt == "pdf",
isFromNetwork: document.isLocalFile! ? false : true,
onAddFilePressed: () { onAddFilePressed: () {
model.pickPdfReceiptFile(context, document.documentId!, index); model.pickPdfReceiptFile(context, document.documentId!, index);
}, },
), ),
if (document.comment != null && document.comment.isNotEmpty && document.status == 4) ...[buildStatusContainer(document: document)]
] else ] else
...[ ...[
10.height, 10.height,
@ -222,4 +220,80 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
); );
} }
} }
List<ImageModel> isLocalOrNetworkFiles({required ServiceVM model, required DocumentData document}) {
bool isNetworkImage = false;
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 if (document.documentId == 1) {
return model.commerceCertificates;
} else if (document.documentId == 2) {
return model.commercialCertificates;
} else {
return model.vatCertificates;
}
}
bool isNeedToShow({required ServiceVM model, required DocumentData document}) {
bool allow = false;
bool isNetworkImage = document.documentUrl != null && document.documentUrl.isNotEmpty ? true : false;
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;
}
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;
}
}
}
bool chkIsLocalOrNetwork({required DocumentData document}) {
bool isNetworkImage = false;
if (!document.isLocalFile!) {
isNetworkImage = document.documentUrl != null && document.documentUrl.isNotEmpty ? true : false;
}
return isNetworkImage;
}
Widget buildStatusContainer({required DocumentData document}) {
return Center(
child: document.comment.toString().toText(
color: MyColors.adCancelledStatusColor,
fontSize: 14,
// isItalic: true,
),
).toContainer(
marginAll: 10,
paddingAll: 10,
borderRadius: 8,
width: double.infinity,
backgroundColor: MyColors.adCancelledStatusColor.withOpacity(0.16),
);
}
} }

@ -1,11 +1,25 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
class EmptyWidget extends StatelessWidget { class EmptyWidget extends StatelessWidget {
const EmptyWidget({Key? key}) : super(key: key); final String text;
final bool isWrapedColumn;
const EmptyWidget({Key? key, required this.text, this.isWrapedColumn = true}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Center(child: "No Data Found".toText()); if (isWrapedColumn) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
text.toText(fontSize: 16, color: MyColors.lightTextColor, fontWeight: MyFonts.Medium),
],
);
}
return Center(child: text.toText(fontSize: 16, color: MyColors.lightTextColor, fontWeight: MyFonts.Medium));
} }
} }

Loading…
Cancel
Save