From 08dfc807fce6971fac40d989994fdff6ab78cccd Mon Sep 17 00:00:00 2001 From: WaseemAbbasi22 <50428976+WaseemAbbasi22@users.noreply.github.com> Date: Wed, 26 Aug 2026 11:23:45 +0300 Subject: [PATCH] bug fixes attachment can be uploaded at any stage --- .../helper_function.dart | 7 +- .../pages/attachment_view.dart | 91 ++++++++++--------- .../delivery_inspection_form_view.dart | 2 +- .../technical_inspection_lines_list_view.dart | 6 +- 4 files changed, 55 insertions(+), 51 deletions(-) diff --git a/lib/modules/asset_delivery_module/helper_function.dart b/lib/modules/asset_delivery_module/helper_function.dart index c8948b6f..ba1c2584 100644 --- a/lib/modules/asset_delivery_module/helper_function.dart +++ b/lib/modules/asset_delivery_module/helper_function.dart @@ -35,14 +35,14 @@ class HelperFunction { builder: (context) => AssetDeliveryAttachmentView( tableItemId: deliveryTableItemId, attachmentType: result!.value, - viewOnly: viewOnly, + // viewOnly: viewOnly, attachmentList: list, ))); // } } } - static void cancelRequest({required BuildContext context, int ?itemId, int? requestId}) async { + static void cancelRequest({required BuildContext context, int? itemId, int? requestId}) async { AssetDeliveryProvider assetDeliveryProvider = Provider.of(context, listen: false); showDialog( context: context, @@ -68,7 +68,8 @@ class HelperFunction { static Future showAttachmentTypeBottomSheet(BuildContext context) { return showModalBottomSheet( context: context, - isScrollControlled: true,backgroundColor: AppColor.bottomSheetColor(context), + isScrollControlled: true, + backgroundColor: AppColor.bottomSheetColor(context), shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical(top: Radius.circular(20)), ), diff --git a/lib/modules/asset_delivery_module/pages/attachment_view.dart b/lib/modules/asset_delivery_module/pages/attachment_view.dart index 57d9cecb..fc9d8fbd 100644 --- a/lib/modules/asset_delivery_module/pages/attachment_view.dart +++ b/lib/modules/asset_delivery_module/pages/attachment_view.dart @@ -24,13 +24,13 @@ import 'package:test_sa/views/widgets/loaders/no_data_found.dart'; class AssetDeliveryAttachmentView extends StatefulWidget { final int? tableItemId; final int? attachmentType; - bool viewOnly = false; + // bool viewOnly = false; final List attachmentList; AssetDeliveryAttachmentView({ super.key, required this.attachmentList, - this.viewOnly = false, + // this.viewOnly = false, this.attachmentType, this.tableItemId, }); @@ -74,51 +74,54 @@ class _AssetDeliveryAttachmentViewState extends State URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []).toShadowContainer( - context, - borderRadius: 20, - padding: 12, - margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), - ), - ], - ), - ), - if (widget.attachmentType == 5 && !widget.viewOnly) - FooterActionButton.footerContainer( - context: context, - child: AppFilledButton( - buttonColor: AppColor.primary10, - label: 'Save'.addTranslation, - maxWidth: true, - onPressed: _onSavePressed, - ), - ), + // widget.attachmentType == 5 && !widget.viewOnly + widget.attachmentType == 5 //only add the attachment for current + ? AttachmentPicker( + label: context.translation.attachments, + attachment: _attachments, + buttonColor: AppColor.primary10, + onlyImages: false, + showAsListView: true, + buttonIcon: 'quotation_icon'.toSvgAsset(color: AppColor.primary10), + onChange: (attachment) {}, + ).toShadowContainer( + context, + borderRadius: 20, + padding: 12, + margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + ) + : _attachments.isNotEmpty + ? FilesList(images: _attachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []).toShadowContainer( + context, + borderRadius: 20, + padding: 12, + margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + ) + : const NoDataFound().center.expanded, ], ), + ), + if (widget.attachmentType == 5) + FooterActionButton.footerContainer( + context: context, + child: AppFilledButton( + buttonColor: AppColor.primary10, + label: 'Save'.addTranslation, + maxWidth: true, + onPressed: _onSavePressed, + ), + ), + ], + ), ); } diff --git a/lib/modules/asset_delivery_module/pages/delivery_inspection/delivery_inspection_form_view.dart b/lib/modules/asset_delivery_module/pages/delivery_inspection/delivery_inspection_form_view.dart index 14c70c87..8d5f31d8 100644 --- a/lib/modules/asset_delivery_module/pages/delivery_inspection/delivery_inspection_form_view.dart +++ b/lib/modules/asset_delivery_module/pages/delivery_inspection/delivery_inspection_form_view.dart @@ -160,7 +160,7 @@ class _DeliveryInspectionFormViewState extends State maxWidth: true, // textColor: AppColor.black10, onPressed: () { - HelperFunction.attachmentTap(context: context, viewOnly: true, assetDeliveryProvider: assetDeliveryProvider!, deliveryTableItemId: widget.deliveryTableModel.id); + HelperFunction.attachmentTap(context: context, viewOnly: viewOnly, assetDeliveryProvider: assetDeliveryProvider!, deliveryTableItemId: widget.deliveryTableModel.id); }).expanded, 8.width, AppFilledButton(buttonColor: AppColor.primary10, label: 'Next'.addTranslation, maxWidth: true, onPressed: _nextTap).expanded, diff --git a/lib/modules/asset_delivery_module/pages/technical_inpection/technical_inspection_lines_list_view.dart b/lib/modules/asset_delivery_module/pages/technical_inpection/technical_inspection_lines_list_view.dart index 082d9d09..aca0992d 100644 --- a/lib/modules/asset_delivery_module/pages/technical_inpection/technical_inspection_lines_list_view.dart +++ b/lib/modules/asset_delivery_module/pages/technical_inpection/technical_inspection_lines_list_view.dart @@ -161,13 +161,13 @@ class _TechnicalInspectionLinesListViewState extends State