From b592e114bc97420d11abfa36d319d619e9cbe42c Mon Sep 17 00:00:00 2001 From: WaseemAbbasi22 Date: Thu, 17 Apr 2025 11:02:39 +0300 Subject: [PATCH] gas refill attachment issue fixed --- .../pages/new_gas_refill_request_page.dart | 2 + .../update_device_transfer.dart | 16 +- .../user/gas_refill/gas_refill_details.dart | 141 ++++++++++-------- .../user/gas_refill/request_gas_refill.dart | 1 - .../widgets/images/multi_image_picker.dart | 24 +-- 5 files changed, 106 insertions(+), 78 deletions(-) diff --git a/lib/new_views/pages/new_gas_refill_request_page.dart b/lib/new_views/pages/new_gas_refill_request_page.dart index d778d5ce..f9f9dadc 100644 --- a/lib/new_views/pages/new_gas_refill_request_page.dart +++ b/lib/new_views/pages/new_gas_refill_request_page.dart @@ -67,10 +67,12 @@ class _NewGasRefillRequestPageState extends State { @override void dispose() { super.dispose(); + _gasRefillProvider!.gasRefillAttachments.clear(); } @override Widget build(BuildContext context) { + return Scaffold( appBar: DefaultAppBar(title: context.translation.newGasRefillRequest), body: Column( diff --git a/lib/views/pages/device_transfer/update_device_transfer.dart b/lib/views/pages/device_transfer/update_device_transfer.dart index 5ab3a914..7e4071dd 100644 --- a/lib/views/pages/device_transfer/update_device_transfer.dart +++ b/lib/views/pages/device_transfer/update_device_transfer.dart @@ -636,11 +636,17 @@ class _AssistantEmployeeCardState extends State { } else { employeeList = widget.formModel!.assetTransferAssistantEmployeesReceiver ?? []; } - widget.formModel?.modelAssistantEmployees = employeeList.isNotEmpty ? employeeList[0] : AssetTransferAssistantEmployees(); - AssignedEmployee? assignedUser = AssignedEmployee( - id: employeeList[0].employeeId, - name: employeeList[0].employeeName, - ); + + + widget.formModel?.modelAssistantEmployees = employeeList.isEmpty ? AssetTransferAssistantEmployees():employeeList[0]; + + AssignedEmployee? assignedUser = AssignedEmployee(); + if(employeeList.isNotEmpty){ + assignedUser= AssignedEmployee( + id: employeeList[0].employeeId, + name: employeeList[0].employeeName, + ); + } selectedEmployee = AssistantEmployees(userId: assignedUser.id, user: assignedUser); } diff --git a/lib/views/pages/user/gas_refill/gas_refill_details.dart b/lib/views/pages/user/gas_refill/gas_refill_details.dart index c35e71f6..908e4da5 100644 --- a/lib/views/pages/user/gas_refill/gas_refill_details.dart +++ b/lib/views/pages/user/gas_refill/gas_refill_details.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:test_sa/controllers/providers/api/gas_refill_comments.dart'; @@ -10,6 +12,7 @@ import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/views/pages/user/gas_refill/gas_refill_form.dart'; import 'package:test_sa/views/pages/user/gas_refill/request_gas_refill.dart'; +import 'package:test_sa/views/widgets/images/multi_image_picker.dart'; import 'package:test_sa/views/widgets/loaders/app_loading.dart'; import 'package:test_sa/views/widgets/loaders/no_data_found.dart'; @@ -39,6 +42,7 @@ class _GasRefillDetailsPageState extends State { final GlobalKey _formKey = GlobalKey(); final GlobalKey _scaffoldKey = GlobalKey(); + List _attachments = []; @override void initState() { @@ -63,6 +67,8 @@ class _GasRefillDetailsPageState extends State { return const ALoading(); } else if (snap.hasData) { _model = snap.data as GasRefillModel; + _attachments = _model.gasRefillAttachments?.map((e) => File(e.attachmentName ?? '')).toList() ?? []; + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -139,7 +145,19 @@ class _GasRefillDetailsPageState extends State { const Divider().defaultStyle(context), gasRefillModel.comment!.bodyText(context), 8.height, - ] + ], + if (_attachments.isNotEmpty) ...[ + const Divider().defaultStyle(context), + context.translation.attachments.bodyText(context), + 8.height, + MultiFilesPicker( + label: context.translation.attachments, + files: _attachments, + enabled: false, + onlyImages: false, + ), + 12.height, + ], ], ).expanded, if (_userProvider.user!.type == UsersTypes.engineer && (gasRefillModel.status?.value ?? 0) != 2) 8.height, @@ -149,69 +167,70 @@ class _GasRefillDetailsPageState extends State { style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50), ), ], + ).paddingOnly(top: 16, start: 16, end: 16), /// TBD - (_userProvider.user!.type == UsersTypes.normal_user - ? Container( - height: 50, - padding: const EdgeInsets.only(left: 16, right: 16), - alignment: Alignment.center, - width: double.infinity, - decoration: ShapeDecoration( - color: context.isDark ? AppColor.neutral50 : AppColor.neutral30, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(14), - bottomRight: Radius.circular(14), - ), - ), - ), - child: Row( - children: [ - Text( - '${context.translation.commentHere}...', - style: AppTextStyles.heading6.copyWith( - color: (context.isDark ? AppColor.neutral30 : AppColor.neutral50).withOpacity(.6), - ), - ).expanded, - "comment_send".toSvgAsset(width: 24, color: context.isDark ? AppColor.primary50 : AppColor.primary70), - ], - ), - ) - : Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Divider().defaultStyle(context), - 8.height, - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - context.translation.viewComments, - style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)), - ), - 4.width, - Icon( - Icons.arrow_forward, - color: AppColor.blueStatus(context), - size: 14, - ) - ], - ), - ], - ).paddingOnly(bottom: 16, start: 16, end: 16)) - .onPress(() { - showModalBottomSheet( - context: context, - useSafeArea: true, - isScrollControlled: true, - useRootNavigator: true, - backgroundColor: Colors.transparent, - builder: (context) => GasRefillCommentsBottomSheet(requestId: gasRefillModel.id.toString()), - ); - }), + // (_userProvider.user!.type == UsersTypes.normal_user + // ? Container( + // height: 50, + // padding: const EdgeInsets.only(left: 16, right: 16), + // alignment: Alignment.center, + // width: double.infinity, + // decoration: ShapeDecoration( + // color: context.isDark ? AppColor.neutral50 : AppColor.neutral30, + // shape: const RoundedRectangleBorder( + // borderRadius: BorderRadius.only( + // bottomLeft: Radius.circular(14), + // bottomRight: Radius.circular(14), + // ), + // ), + // ), + // child: Row( + // children: [ + // Text( + // '${context.translation.commentHere}...', + // style: AppTextStyles.heading6.copyWith( + // color: (context.isDark ? AppColor.neutral30 : AppColor.neutral50).withOpacity(.6), + // ), + // ).expanded, + // "comment_send".toSvgAsset(width: 24, color: context.isDark ? AppColor.primary50 : AppColor.primary70), + // ], + // ), + // ) + // : Column( + // mainAxisSize: MainAxisSize.min, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // const Divider().defaultStyle(context), + // 8.height, + // Row( + // mainAxisSize: MainAxisSize.min, + // children: [ + // Text( + // context.translation.viewComments, + // style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)), + // ), + // 4.width, + // Icon( + // Icons.arrow_forward, + // color: AppColor.blueStatus(context), + // size: 14, + // ) + // ], + // ), + // ], + // ).paddingOnly(bottom: 16, start: 16, end: 16)) + // .onPress(() { + // showModalBottomSheet( + // context: context, + // useSafeArea: true, + // isScrollControlled: true, + // useRootNavigator: true, + // backgroundColor: Colors.transparent, + // builder: (context) => GasRefillCommentsBottomSheet(requestId: gasRefillModel.id.toString()), + // ); + // }), ], ).toShadowContainer(context, padding: 0); } diff --git a/lib/views/pages/user/gas_refill/request_gas_refill.dart b/lib/views/pages/user/gas_refill/request_gas_refill.dart index a802ef50..9a4e23b4 100644 --- a/lib/views/pages/user/gas_refill/request_gas_refill.dart +++ b/lib/views/pages/user/gas_refill/request_gas_refill.dart @@ -176,7 +176,6 @@ class _RequestGasRefillState extends State { @override Widget build(BuildContext context) { - _userProvider = Provider.of(context); _settingProvider = Provider.of(context); _gasRefillProvider ??= Provider.of(context, listen: false); diff --git a/lib/views/widgets/images/multi_image_picker.dart b/lib/views/widgets/images/multi_image_picker.dart index a6a2242d..3608aa5b 100644 --- a/lib/views/widgets/images/multi_image_picker.dart +++ b/lib/views/widgets/images/multi_image_picker.dart @@ -51,17 +51,19 @@ class _MultiFilesPickerState extends State { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - AppDashedButton( - title: widget.label, - height: widget.buttonHeight, - buttonColor: widget.buttonColor, - icon: widget.buttonIcon, - onPressed: (widget.enabled == false) - ? () {} - : widget.showAsGrid - ? showFileSourceSheet - : onFilePicker), - 16.height, + if(widget.enabled)...[ + AppDashedButton( + title: widget.label, + height: widget.buttonHeight, + buttonColor: widget.buttonColor, + icon: widget.buttonIcon, + onPressed: (widget.enabled == false) + ? () {} + : widget.showAsGrid + ? showFileSourceSheet + : onFilePicker), + 16.height, + ], if (widget.files.isNotEmpty) Wrap( spacing: 8.toScreenWidth,