|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
@ -14,9 +15,11 @@ import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
|
|
|
|
|
import 'package:mc_common_app/models/provider_branches_models/profile/document.dart';
|
|
|
|
|
import 'package:mc_common_app/theme/colors.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/enums.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/navigator.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/views/advertisement/ad_creation_steps/ad_creation_steps_containers.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/common_widgets/app_bar.dart';
|
|
|
|
|
@ -24,6 +27,7 @@ import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:mc_common_app/widgets/txt_field.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:sizer/sizer.dart';
|
|
|
|
|
|
|
|
|
|
class ProviderLicensePage extends StatefulWidget {
|
|
|
|
|
const ProviderLicensePage({super.key});
|
|
|
|
|
@ -36,59 +40,72 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
|
|
|
|
|
late ServiceVM branchVM;
|
|
|
|
|
bool showAttachment = false;
|
|
|
|
|
String? attachedFile;
|
|
|
|
|
bool isAllApproved = true;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
scheduleMicrotask(() {
|
|
|
|
|
// branchVM = Provider.of<ServiceVM>(context, listen: false);
|
|
|
|
|
// branchVM = Provider.of<ServiceVM>(context, listen: false);
|
|
|
|
|
context.read<ServiceVM>().getServiceProviderDocument(AppState().getUser.data!.userInfo!.providerId ?? 0);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final serviceVm = context.read<ServiceVM>();
|
|
|
|
|
if (serviceVm.document != null && serviceVm.document!.data != null && serviceVm.document!.data!.isNotEmpty) {
|
|
|
|
|
for (var doc in serviceVm.document!.data!) {
|
|
|
|
|
if (doc.status != 3) {
|
|
|
|
|
isAllApproved = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: CustomAppBar(
|
|
|
|
|
title: LocaleKeys.defineLicences.tr(),
|
|
|
|
|
isRemoveBackButton: false,
|
|
|
|
|
),
|
|
|
|
|
body: Consumer<ServiceVM>(builder: (_, model, __) {
|
|
|
|
|
if (model.state == ViewState.busy) {
|
|
|
|
|
return const Center(
|
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(0.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
showWidget(model),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: SingleChildScrollView(child: buildContent(model)),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
|
child: ShowFillButton(
|
|
|
|
|
title: LocaleKeys.continu.tr(),
|
|
|
|
|
maxWidth: double.infinity,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (AppState().getUser.data!.userInfo!.roleId == 5) {
|
|
|
|
|
if (validation(model)) {
|
|
|
|
|
updateDocument(model);
|
|
|
|
|
if (!isAllApproved) ...[
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
|
child: ShowFillButton(
|
|
|
|
|
title: LocaleKeys.continu.tr(),
|
|
|
|
|
maxWidth: double.infinity,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
bool status = false;
|
|
|
|
|
if (AppState().getUser.data!.userInfo!.roleId == 5) {
|
|
|
|
|
if (validation(model)) {
|
|
|
|
|
status = await updateDocument(model);
|
|
|
|
|
} else {
|
|
|
|
|
Utils.showToast(LocaleKeys.allDocumentMandatoryDealershipProvider.tr());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Utils.showToast(LocaleKeys.allDocumentMandatoryDealershipProvider.tr());
|
|
|
|
|
status = await updateDocument(model);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
updateDocument(model);
|
|
|
|
|
}
|
|
|
|
|
Future.delayed(const Duration(seconds: 1), () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
Future.delayed(const Duration(seconds: 1), () {
|
|
|
|
|
if (status) {
|
|
|
|
|
pop(context);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
@ -105,120 +122,93 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
|
|
|
|
|
return valid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateDocument(ServiceVM model) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
GenericRespModel res = await model.updateDocument(model.document!.data);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
if (res.messageStatus == 1) {
|
|
|
|
|
Utils.showToast(LocaleKeys.documentsUploadedSuccessfully.tr());
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
} else {
|
|
|
|
|
Utils.showToast(res.message ?? "");
|
|
|
|
|
Future<bool> updateDocument(ServiceVM model) async {
|
|
|
|
|
try {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
GenericRespModel res = await model.updateDocument(model.document!.data);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
if (res.messageStatus == 1) {
|
|
|
|
|
Utils.showToast(LocaleKeys.documentsUploadedSuccessfully.tr());
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
Utils.showToast(res.message ?? "");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (e, s) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget showWidget(ServiceVM model) {
|
|
|
|
|
if (model.state == ViewState.idle) {
|
|
|
|
|
return model.document!.data!.isEmpty
|
|
|
|
|
? Text(LocaleKeys.somethingWrong.tr())
|
|
|
|
|
: ListView.separated(
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
DocumentData? document = model.document?.data![index];
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
10.height,
|
|
|
|
|
(document!.documentName! ?? "").toText(fontSize: 16, letterSpacing: -0.56, fontWeight: MyFonts.SemiBold),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 20, right: 20, top: 4, bottom: 8),
|
|
|
|
|
child: LocaleKeys.enter_licence_detail.tr().toText(fontSize: 14, color: MyColors.lightTextColor, textAlign: TextAlign.center),
|
|
|
|
|
),
|
|
|
|
|
TxtField(
|
|
|
|
|
hint: LocaleKeys.description.tr(),
|
|
|
|
|
maxLines: 3,
|
|
|
|
|
isBackgroundEnabled: true,
|
|
|
|
|
),
|
|
|
|
|
10.height,
|
|
|
|
|
if (isNeedToShow(model: model, document: document)) ...[
|
|
|
|
|
PickedFilesContainer(
|
|
|
|
|
// isReview: document.status == 3 ? true : false,
|
|
|
|
|
pickedFiles: isLocalOrNetworkFiles(model: model, document: document),
|
|
|
|
|
onCrossPressedPrimary: chkIsLocalOrNetwork(document: document)
|
|
|
|
|
? model.removeNetworkImag
|
|
|
|
|
: document.documentId == 1
|
|
|
|
|
? model.commerceRemove
|
|
|
|
|
: document.documentId == 2
|
|
|
|
|
? model.commercialRemove
|
|
|
|
|
: model.vatRemove,
|
|
|
|
|
isPdf: model.document!.data![index].fileExt == "pdf",
|
|
|
|
|
isFromNetwork: document.isLocalFile! ? false : true,
|
|
|
|
|
onAddFilePressed: () {
|
|
|
|
|
model.pickPdfReceiptFile(context, document.documentId!, index);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (document.comment != null && document.comment.isNotEmpty && document.status == 4) ...[buildStatusContainer(document: document)]
|
|
|
|
|
] else
|
|
|
|
|
...[
|
|
|
|
|
Widget buildContent(ServiceVM model) {
|
|
|
|
|
return model.document!.data!.isEmpty
|
|
|
|
|
? Text(LocaleKeys.somethingWrong.tr())
|
|
|
|
|
: ListView.separated(
|
|
|
|
|
separatorBuilder: (context, index) {
|
|
|
|
|
return 20.height;
|
|
|
|
|
},
|
|
|
|
|
itemCount: model.document!.data!.length,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
DocumentData? document = model.document?.data![index];
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
10.height,
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () async {
|
|
|
|
|
model.pickPdfReceiptFile(context, document.documentId!, index) ?? "";
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 45,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.transparent,
|
|
|
|
|
border: Border.all(color: MyColors.greyACColor, width: 2),
|
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(0)),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
const Icon(
|
|
|
|
|
Icons.attach_file,
|
|
|
|
|
size: 18,
|
|
|
|
|
color: MyColors.darkPrimaryColor,
|
|
|
|
|
),
|
|
|
|
|
8.width,
|
|
|
|
|
Text(
|
|
|
|
|
LocaleKeys.attachFile.tr(),
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
color: MyColors.darkPrimaryColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const Icon(
|
|
|
|
|
Icons.attach_file,
|
|
|
|
|
size: 18,
|
|
|
|
|
color: Colors.transparent,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
(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)),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
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: model, document: document)) ...[
|
|
|
|
|
PickedFilesContainer(
|
|
|
|
|
isReview: document.status != 4,
|
|
|
|
|
pickedFiles: isLocalOrNetworkFiles(model: model, document: document),
|
|
|
|
|
onCrossPressedPrimary: chkIsLocalOrNetwork(document: document)
|
|
|
|
|
? model.removeNetworkImag
|
|
|
|
|
: document.documentId == 1
|
|
|
|
|
? model.commerceRemove
|
|
|
|
|
: document.documentId == 2
|
|
|
|
|
? model.commercialRemove
|
|
|
|
|
: model.vatRemove,
|
|
|
|
|
isPdf: model.document!.data![index].fileExt == "pdf",
|
|
|
|
|
isFromNetwork: !(document.isLocalFile ?? false),
|
|
|
|
|
onAddFilePressed: () {
|
|
|
|
|
model.pickPdfReceiptFile(context, document.documentId!, index);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
buildCommentContainer(document: document),
|
|
|
|
|
] else ...[
|
|
|
|
|
10.height,
|
|
|
|
|
DottedRectContainer(
|
|
|
|
|
onTap: () => model.pickPdfReceiptFile(context, document.documentId!, index) ?? "",
|
|
|
|
|
text: LocaleKeys.attachImage.tr(),
|
|
|
|
|
icon: MyAssets.attachmentIcon.buildSvg(),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (context, index) {
|
|
|
|
|
return 20.height;
|
|
|
|
|
},
|
|
|
|
|
itemCount: model.document!.data!.length,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
20.height,
|
|
|
|
|
const Center(
|
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<ImageModel> isLocalOrNetworkFiles({required ServiceVM model, required DocumentData document}) {
|
|
|
|
|
@ -281,19 +271,39 @@ class _ProviderLicensePageState extends State<ProviderLicensePage> {
|
|
|
|
|
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,
|
|
|
|
|
Widget buildCommentContainer({required DocumentData document}) {
|
|
|
|
|
String comment = "";
|
|
|
|
|
if (document.status == 4 && document.comment != null) {
|
|
|
|
|
comment = document.comment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Color getColorByStatus(int docStatus) {
|
|
|
|
|
switch (docStatus) {
|
|
|
|
|
case 1:
|
|
|
|
|
return MyColors.adPendingStatusColor;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
return MyColors.adActiveStatusColor;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
return MyColors.greenColor;
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
return MyColors.adCancelledStatusColor;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return MyColors.adPendingStatusColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|