|
|
|
|
@ -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/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/search_entity_widget.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:mc_common_app/widgets/txt_field.dart';
|
|
|
|
|
@ -35,6 +36,7 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
|
|
|
|
|
late ServiceVM branchVM;
|
|
|
|
|
bool showAttachment = false;
|
|
|
|
|
String? attachedFile;
|
|
|
|
|
String? formattedDate;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
@ -50,7 +52,7 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
|
|
|
|
|
if (model.document != null && model.document!.data != null && model.document!.data!.isNotEmpty) {
|
|
|
|
|
for (var doc in model.document!.data!) {
|
|
|
|
|
log("doc: ${doc.status}");
|
|
|
|
|
if (doc.status == 4 || doc.status == 0) {
|
|
|
|
|
if (doc.status == DocumentStatusEnum.rejected || doc.status == DocumentStatusEnum.needUpload || doc.isAllowUpdate!) {
|
|
|
|
|
isShow = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -162,6 +164,7 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
DocumentData? document = serviceVM.document?.data![index];
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
@ -172,40 +175,58 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
|
|
|
|
|
(document!.documentName!).toText(fontSize: 16, letterSpacing: -0.56, fontWeight: MyFonts.SemiBold),
|
|
|
|
|
if (document.statusText != null && document.statusText!.isNotEmpty) ...[
|
|
|
|
|
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) ...[
|
|
|
|
|
// Padding(
|
|
|
|
|
// padding: const EdgeInsets.only(top: 4, bottom: 8),
|
|
|
|
|
// child: LocaleKeys.enter_licence_detail.tr().toText(fontSize: 14, color: MyColors.lightTextColor),
|
|
|
|
|
// ),
|
|
|
|
|
// TxtField(
|
|
|
|
|
// hint: LocaleKeys.description.tr(),
|
|
|
|
|
// maxLines: 3,
|
|
|
|
|
// isBackgroundEnabled: true,
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
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,
|
|
|
|
|
if (document.documentUrl != null) ...[
|
|
|
|
|
BuildFilesContainer(
|
|
|
|
|
image: ImageModel(id: index, filePath: document.documentUrl!, isFromNetwork: document.isLocalFile! ? false : true),
|
|
|
|
|
onCrossPressedPrimary: (String val) {
|
|
|
|
|
document.documentUrl = null;
|
|
|
|
|
document.isLocalFile = false;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
index: index,
|
|
|
|
|
isReview: isReview(document),
|
|
|
|
|
isPdf: true,
|
|
|
|
|
isFromNetwork: !(document.isLocalFile ?? false),
|
|
|
|
|
onAddFilePressed: () {
|
|
|
|
|
serviceVM.pickPdfReceiptFile(context, document.documentId!, index);
|
|
|
|
|
),
|
|
|
|
|
5.height,
|
|
|
|
|
("${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),
|
|
|
|
|
] else
|
|
|
|
|
...[
|
|
|
|
|
@ -215,107 +236,133 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
|
|
|
|
|
text: LocaleKeys.attachPDF.tr(),
|
|
|
|
|
icon: MyAssets.attachmentIcon.buildSvg(),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<ImageModel> isLocalOrNetworkFiles({required ServiceVM model, required DocumentData document}) {
|
|
|
|
|
bool isNetworkImage = false;
|
|
|
|
|
|
|
|
|
|
if (!document.isLocalFile!) {
|
|
|
|
|
isNetworkImage = document.documentUrl != null && document.documentUrl!.isNotEmpty ? true : false;
|
|
|
|
|
bool isReview(DocumentData document) {
|
|
|
|
|
print(document.toJson());
|
|
|
|
|
bool val = false;
|
|
|
|
|
if (document.isAllowUpdate == null) {
|
|
|
|
|
val = 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;
|
|
|
|
|
if (document.isAllowUpdate! && document.status == DocumentStatusEnum.approvedOrActive) {
|
|
|
|
|
val = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
if (!document.isAllowUpdate! && document.status == DocumentStatusEnum.approvedOrActive) {
|
|
|
|
|
val = 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;
|
|
|
|
|
}
|
|
|
|
|
if (document.isAllowUpdate! && document.status == DocumentStatusEnum.pending) {
|
|
|
|
|
val = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isNetworkImage({required DocumentData document}) {
|
|
|
|
|
bool isNetworkImage = false;
|
|
|
|
|
if (!document.isLocalFile!) {
|
|
|
|
|
isNetworkImage = document.documentUrl != null && document.documentUrl!.isNotEmpty ? true : false;
|
|
|
|
|
if (document.isAllowUpdate! && document.status == DocumentStatusEnum.rejected) {
|
|
|
|
|
val = false;
|
|
|
|
|
}
|
|
|
|
|
if (document.isAllowUpdate! && document.status == DocumentStatusEnum.needUpload) {
|
|
|
|
|
val = true;
|
|
|
|
|
}
|
|
|
|
|
return isNetworkImage;
|
|
|
|
|
if (document.isAllowUpdate! && document.status == DocumentStatusEnum.review) {
|
|
|
|
|
val = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget buildCommentContainer({required DocumentData document}) {
|
|
|
|
|
String comment = "";
|
|
|
|
|
if (document.status == 4 && document.comment != null) {
|
|
|
|
|
comment = document.comment ?? "";
|
|
|
|
|
}
|
|
|
|
|
// List<ImageModel> isLocalOrNetworkFiles({required ServiceVM model, required DocumentData document}) {
|
|
|
|
|
// bool isNetworkImage = false;
|
|
|
|
|
// print(document);
|
|
|
|
|
// 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) {
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
}
|
|
|
|
|
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),
|
|
|
|
|
);
|
|
|
|
|
// 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 && document.documentUrl!.isNotEmpty) {
|
|
|
|
|
// 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) {
|
|
|
|
|
switch (docStatus) {
|
|
|
|
|
case 1:
|
|
|
|
|
return MyColors.adPendingStatusColor;
|
|
|
|
|
if (comment.isEmpty) {
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
}
|
|
|
|
|
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:
|
|
|
|
|
return MyColors.adActiveStatusColor;
|
|
|
|
|
Color getColorByStatus(DocumentStatusEnum docStatus) {
|
|
|
|
|
switch (docStatus) {
|
|
|
|
|
case DocumentStatusEnum.pending:
|
|
|
|
|
return MyColors.adPendingStatusColor;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
return MyColors.greenColor;
|
|
|
|
|
case DocumentStatusEnum.approvedOrActive:
|
|
|
|
|
return MyColors.adActiveStatusColor;
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
return MyColors.adCancelledStatusColor;
|
|
|
|
|
case DocumentStatusEnum.rejected:
|
|
|
|
|
return MyColors.adCancelledStatusColor;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return MyColors.adPendingStatusColor;
|
|
|
|
|
}
|
|
|
|
|
case DocumentStatusEnum.needUpload:
|
|
|
|
|
return MyColors.adPendingStatusColor;
|
|
|
|
|
default:
|
|
|
|
|
return MyColors.adPendingStatusColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|