|
|
|
|
@ -11,6 +11,7 @@ import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
|
|
|
|
|
import 'package:test_sa/models/generic_attachment_model.dart';
|
|
|
|
|
import 'package:test_sa/models/lookup.dart';
|
|
|
|
|
import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.dart';
|
|
|
|
|
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
|
|
|
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
|
|
|
@ -26,6 +27,7 @@ import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
|
class AssetDeliveryAttachmentView extends StatefulWidget {
|
|
|
|
|
final int? tableItemId;
|
|
|
|
|
final int? attachmentType;
|
|
|
|
|
final Lookup? documentType;
|
|
|
|
|
bool viewOnly = false;
|
|
|
|
|
final List<GenericAttachmentModel> attachmentList;
|
|
|
|
|
|
|
|
|
|
@ -34,6 +36,7 @@ class AssetDeliveryAttachmentView extends StatefulWidget {
|
|
|
|
|
required this.attachmentList,
|
|
|
|
|
this.viewOnly = false,
|
|
|
|
|
this.attachmentType,
|
|
|
|
|
this.documentType,
|
|
|
|
|
this.tableItemId,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@ -76,73 +79,74 @@ class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentVie
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
body:Column(
|
|
|
|
|
body: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Flexible(
|
|
|
|
|
fit: FlexFit.loose, // ✅ expands only as much as needed
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Flexible(
|
|
|
|
|
fit: FlexFit.loose, // ✅ expands only as much as needed
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
widget.attachmentType == 5 && !widget.viewOnly
|
|
|
|
|
? AttachmentPicker(
|
|
|
|
|
label: context.translation.attachments,
|
|
|
|
|
showTypeDropdown: false,
|
|
|
|
|
attachment: _attachments,
|
|
|
|
|
moduleId: RequestAttachmentTypeEnum.assetDelivery.id,
|
|
|
|
|
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),
|
|
|
|
|
)
|
|
|
|
|
: Column(
|
|
|
|
|
children: [
|
|
|
|
|
InfoHeader16Widget("Attachments".addTranslation),
|
|
|
|
|
FilesList( showAsListView: true,
|
|
|
|
|
types: _attachments.map((doc) {
|
|
|
|
|
final attachmentType = doc.documentType?.name ?? '';
|
|
|
|
|
return attachmentType.isNotEmpty ? attachmentType : 'Asset Guide';
|
|
|
|
|
}).toList(),
|
|
|
|
|
images: _attachments.map((e) => 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
|
|
|
|
|
? AttachmentPicker(
|
|
|
|
|
label: context.translation.attachments,
|
|
|
|
|
showTypeDropdown: false,
|
|
|
|
|
attachment: _attachments,
|
|
|
|
|
moduleId: RequestAttachmentTypeEnum.assetDelivery.id,
|
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
|
documentType: widget.documentType,
|
|
|
|
|
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),
|
|
|
|
|
)
|
|
|
|
|
: FilesList(
|
|
|
|
|
showAsListView: true,
|
|
|
|
|
types: _attachments.map((doc) {
|
|
|
|
|
final attachmentType = doc.documentType?.name ?? '';
|
|
|
|
|
return attachmentType.isNotEmpty ? attachmentType : 'Asset Guide';
|
|
|
|
|
}).toList(),
|
|
|
|
|
images: _attachments
|
|
|
|
|
.map(
|
|
|
|
|
(e) => 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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _onSavePressed() async {
|
|
|
|
|
final List<GenericAttachmentModel> attachmentPayload = _attachments.map((item) {
|
|
|
|
|
final List<Map<String, dynamic>> attachmentPayload = _attachments.map((item) {
|
|
|
|
|
final String name = CMRequestUtils.isLocalUrl(item.name ?? '') ? '${item.name?.split("/").last}|${base64Encode(File(item.name!).readAsBytesSync())}' : item.name ?? '';
|
|
|
|
|
|
|
|
|
|
return GenericAttachmentModel(
|
|
|
|
|
id: item.id ?? 0,
|
|
|
|
|
name: name,
|
|
|
|
|
documentType: item.documentType,
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
documentType: widget.documentType,
|
|
|
|
|
).toAssetDeliveryJson();
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
showDialog(
|
|
|
|
|
|