|
|
|
|
@ -34,6 +34,7 @@ import 'package:test_sa/providers/work_order/vendor_provider.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
|
|
|
|
|
import '../../../../../../new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
import '../../models/new_models/department.dart';
|
|
|
|
|
import 'demo_document_lookup_provider.dart';
|
|
|
|
|
import 'models/demo_form_model.dart';
|
|
|
|
|
|
|
|
|
|
class UpdateDemoRequestView extends StatefulWidget {
|
|
|
|
|
@ -47,7 +48,7 @@ class UpdateDemoRequestView extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _UpdateDemoRequestViewState extends State<UpdateDemoRequestView> with TickerProviderStateMixin {
|
|
|
|
|
final List<DemoAttachments> attachments = [];
|
|
|
|
|
final List<GenericAttachmentModel> attachments = [];
|
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
DemoFormModel _demoFormModel = DemoFormModel();
|
|
|
|
|
@ -65,6 +66,7 @@ class _UpdateDemoRequestViewState extends State<UpdateDemoRequestView> with Tick
|
|
|
|
|
late SiteProvider siteProvider;
|
|
|
|
|
late DemoProvider demoProvider;
|
|
|
|
|
bool isLoading = true;
|
|
|
|
|
Lookup? demoDocumentLookup;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
@ -161,7 +163,7 @@ class _UpdateDemoRequestViewState extends State<UpdateDemoRequestView> with Tick
|
|
|
|
|
for (final item in widget.dataModel.demoAttachments!) {
|
|
|
|
|
if ((item.attachmentName ?? '').isNotEmpty) {
|
|
|
|
|
attachments.add(
|
|
|
|
|
DemoAttachments(attachmentName: item.attachmentName, id: item.id ?? 0, originalName: item.originalName),
|
|
|
|
|
GenericAttachmentModel(name: item.attachmentName, id: item.id ?? 0, originalName: item.originalName, documentTypeId: item.documentType),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -197,14 +199,36 @@ class _UpdateDemoRequestViewState extends State<UpdateDemoRequestView> with Tick
|
|
|
|
|
16.height,
|
|
|
|
|
...vendorDetailsSection(),
|
|
|
|
|
16.height,
|
|
|
|
|
// AttachmentPicker(
|
|
|
|
|
// label: context.translation.attachments,
|
|
|
|
|
// attachment: attachments,
|
|
|
|
|
// buttonColor: AppColor.black10,
|
|
|
|
|
// onlyImages: false,
|
|
|
|
|
// showAsListView: true,
|
|
|
|
|
// buttonIcon: 'image-plus'.toSvgAsset(color: context.isDark ? AppColor.primary10 : AppColor.neutral120),
|
|
|
|
|
// ),
|
|
|
|
|
"Attachments".bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, DemoDocumentLookupProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
title: "Document Type",
|
|
|
|
|
initialValue: demoDocumentLookup,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
demoDocumentLookup = value;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
16.height,
|
|
|
|
|
AttachmentPicker(
|
|
|
|
|
label: context.translation.attachments,
|
|
|
|
|
attachment: attachments,
|
|
|
|
|
buttonColor: AppColor.black10.withOpacity(demoDocumentLookup != null ? 1 : .4),
|
|
|
|
|
onlyImages: false,
|
|
|
|
|
documentType: demoDocumentLookup,
|
|
|
|
|
enabled: demoDocumentLookup != null,
|
|
|
|
|
showAsListView: true,
|
|
|
|
|
buttonIcon: 'image-plus'.toSvgAsset(color: (context.isDark ? AppColor.primary10 : AppColor.neutral120).withOpacity(demoDocumentLookup != null ? 1 : .4)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context, borderRadius: 20),
|
|
|
|
|
).expanded,
|
|
|
|
|
@ -496,11 +520,18 @@ class _UpdateDemoRequestViewState extends State<UpdateDemoRequestView> with Tick
|
|
|
|
|
'${'Vendor Name'.addTranslation}: ${_demoFormModel.vendorName?.cleanupWhitespace.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Text(
|
|
|
|
|
'${'Representative Name'.addTranslation}: ${_demoFormModel.vendorRepresentativeName?.cleanupWhitespace.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${'Contact'.addTranslation}: ${_demoFormModel.vendorContactNumber?.cleanupWhitespace.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${'Email'.addTranslation}: ${_demoFormModel.vendorEmail?.cleanupWhitespace.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
8.height,
|
|
|
|
|
@ -582,9 +613,9 @@ class _UpdateDemoRequestViewState extends State<UpdateDemoRequestView> with Tick
|
|
|
|
|
_demoFormModel.demoAttachment = [];
|
|
|
|
|
// _demoFormModel.id = 3;
|
|
|
|
|
for (var item in attachments) {
|
|
|
|
|
// String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
|
|
|
|
|
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
|
|
|
|
|
//Todo need to pass attachmentType id as well.
|
|
|
|
|
// _demoFormModel.demoAttachment?.add(DemoAttachments(id: item.id, demoRequestId: _demoFormModel.id ?? 0, attachmentName: fileName));
|
|
|
|
|
_demoFormModel.demoAttachment?.add(DemoAttachments(id: item.id, demoRequestId: _demoFormModel.id ?? 0, attachmentName: fileName,originalName: fileName, documentTypeId: item.documentTypeId!.id));
|
|
|
|
|
}
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
DemoProvider demoProvider = Provider.of<DemoProvider>(context, listen: false);
|
|
|
|
|
|