From b7aefbe7f32fb3f01d0365aa720465984b0bfd77 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 7 Sep 2025 10:47:20 +0300 Subject: [PATCH] task contact info in detail view, & improvements --- .../views/nurse/create_new_request_view.dart | 136 +++++---- .../tasks_wo/task_request_detail_view.dart | 2 +- .../create__device_transfer_request.dart | 278 +++++++++--------- .../device_transfer/search_device_page.dart | 90 ++++-- .../selection_fullscreen_dialog.dart | 23 +- lib/views/widgets/qr/asset_scan_qr.dart | 52 ++-- 6 files changed, 315 insertions(+), 266 deletions(-) diff --git a/lib/modules/cm_module/views/nurse/create_new_request_view.dart b/lib/modules/cm_module/views/nurse/create_new_request_view.dart index 6535c2e1..c6e603dc 100644 --- a/lib/modules/cm_module/views/nurse/create_new_request_view.dart +++ b/lib/modules/cm_module/views/nurse/create_new_request_view.dart @@ -116,75 +116,73 @@ class _CreateNewRequestState extends State with TickerProvider key: _scaffoldKey, appBar: DefaultAppBar(title: context.translation.createWorkOrder), body: Consumer(builder: (context, serviceRequestProvider, child) { - return SafeArea( - child: LoadingManager( - isLoading: _isLoading, - isFailedLoading: false, - stateCode: 200, - onRefresh: () async {}, - child: Form( - key: _formKey, - child: Column( - children: [ - SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: Column( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - scanAssetButton(), - if (pendingAssetServiceRequest != null && pendingAssetServiceRequest!.details!.isNotEmpty) ...[ - 8.height, - Row( - children: [ - const Icon(Icons.warning, color: Color(0xffEE404C), size: 14), - 8.width, - Text( - "This asset already have ${pendingAssetServiceRequest!.details!.length} request pending", - style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: Color(0xff7D859A), decoration: TextDecoration.underline), - ).expanded, - ], - ).onPress(() { - showPendingRequests(); - }), - ], - if (Provider.of(context, listen: false).showPriority) ...[ - 16.height, - highPriorityWidget(), - ], + return LoadingManager( + isLoading: _isLoading, + isFailedLoading: false, + stateCode: 200, + onRefresh: () async {}, + child: Form( + key: _formKey, + child: Column( + children: [ + SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + scanAssetButton(), + if (pendingAssetServiceRequest != null && pendingAssetServiceRequest!.details!.isNotEmpty) ...[ + 8.height, + Row( + children: [ + const Icon(Icons.warning, color: Color(0xffEE404C), size: 14), + 8.width, + Text( + "This asset already have ${pendingAssetServiceRequest!.details!.length} request pending", + style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: Color(0xff7D859A), decoration: TextDecoration.underline), + ).expanded, + ], + ).onPress(() { + showPendingRequests(); + }), + ], + if (Provider.of(context, listen: false).showPriority) ...[ 16.height, - assetStatusWidget(context), - 24.height, - AttachmentPicker( - label: context.translation.attachImage, - attachment: _deviceImages, - buttonColor: AppColor.black10, - onlyImages: false, - buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), - ), + highPriorityWidget(), ], - ).paddingAll(0).toShadowContainer(context), - 16.height, - commentWidget(serviceRequest: _serviceRequest), - ], - ), - ).expanded, - FooterActionButton.footerContainer( - context: context, - child: AppFilledButton( - // label: context.translation.submitRequest, - buttonColor: AppColor.primary10, - label: - // (pendingAssetServiceRequest != null && (pendingAssetServiceRequest!.details?.isNotEmpty ?? false)) - // ? context.translation.duplicateRequest : // @FM said show create work order button text to create request not duplicate request - context.translation.createWorkOrder, - onPressed: checkPendingRequest ? null : _submit, - // buttonColor: AppColor.primary10, - ), + 16.height, + assetStatusWidget(context), + 24.height, + AttachmentPicker( + label: context.translation.attachImage, + attachment: _deviceImages, + buttonColor: AppColor.black10, + onlyImages: false, + buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), + ), + ], + ).paddingAll(0).toShadowContainer(context), + 16.height, + commentWidget(serviceRequest: _serviceRequest), + ], + ), + ).expanded, + FooterActionButton.footerContainer( + context: context, + child: AppFilledButton( + // label: context.translation.submitRequest, + buttonColor: AppColor.primary10, + label: + // (pendingAssetServiceRequest != null && (pendingAssetServiceRequest!.details?.isNotEmpty ?? false)) + // ? context.translation.duplicateRequest : // @FM said show create work order button text to create request not duplicate request + context.translation.createWorkOrder, + onPressed: checkPendingRequest ? null : _submit, + // buttonColor: AppColor.primary10, ), - ], - ), + ), + ], ), ), ); @@ -238,7 +236,7 @@ class _CreateNewRequestState extends State with TickerProvider ], ) ], - ).toShimmer(isShow: snapshot.loading,context: context), + ).toShimmer(isShow: snapshot.loading, context: context), ], ); }); @@ -280,7 +278,7 @@ class _CreateNewRequestState extends State with TickerProvider _serviceRequest.priority = snapshot.items.firstWhere((element) => element.value == 0, orElse: null); } setState(() {}); - }).toShimmer(isShow: snapshot.loading,context: context); + }).toShimmer(isShow: snapshot.loading, context: context); }), ], ); @@ -354,7 +352,7 @@ class _CreateNewRequestState extends State with TickerProvider } List attachement = []; for (var item in _deviceImages) { - String fileName = ServiceRequestUtils.isLocalUrl(item.name??'') ? ("${item.name??''.split("/").last}|${base64Encode(File(item.name??'').readAsBytesSync())}") :item.name??''; + String fileName = ServiceRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? ''; attachement.add(WorkOrderAttachments(id: 0, name: fileName)); } _requestDetailProvider.workOrderHelperModel = WorkOrderHelperModel( diff --git a/lib/modules/tm_module/tasks_wo/task_request_detail_view.dart b/lib/modules/tm_module/tasks_wo/task_request_detail_view.dart index 4443b111..69c85321 100644 --- a/lib/modules/tm_module/tasks_wo/task_request_detail_view.dart +++ b/lib/modules/tm_module/tasks_wo/task_request_detail_view.dart @@ -122,7 +122,7 @@ class _TaskRequestDetailsViewState extends State { ], ), ], - // if (taskProvider.taskRequestModel!.taskJobContactPersons!.isNotEmpty) contactInfoCard(context, taskProvider.taskRequestModel), + if (taskProvider.taskRequestModel!.taskJobContactPersons!.isNotEmpty) contactInfoCard(context, taskProvider.taskRequestModel), if (taskProvider.taskRequestModel?.callComment != null) ...[ const Divider().defaultStyle(context), Text( diff --git a/lib/views/pages/device_transfer/create__device_transfer_request.dart b/lib/views/pages/device_transfer/create__device_transfer_request.dart index 4a1b371d..319e9be8 100644 --- a/lib/views/pages/device_transfer/create__device_transfer_request.dart +++ b/lib/views/pages/device_transfer/create__device_transfer_request.dart @@ -121,149 +121,147 @@ class _CreateDeviceTransferRequestState extends State( + context: context, + title: context.translation.site, + initialValue: _assetDestination.site, + disableValue: isInternal ? null : _pickedAsset?.site, + showShadow: false, + loading: _deviceTransferProvider.isSiteLoading, + enabled: !isInternal, + backgroundColor: AppColor.fieldBgColor(context), + showAsBottomSheet: true, + onSelect: (value) { + _assetDestination.site = value; + _assetDestination.building = null; + _assetDestination.floor = null; + _assetDestination.department = null; setState(() {}); - }), - 21.height, - requestTypeWidget(context), - 12.height, - "Destination".bodyText(context).custom(color: context.isDark ? Colors.white : AppColor.white936), - 12.height, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SingleItemDropDownMenu( - context: context, - title: context.translation.site, - initialValue: _assetDestination.site, - disableValue: isInternal ? null : _pickedAsset?.site, - showShadow: false, - loading: _deviceTransferProvider.isSiteLoading, - enabled: !isInternal, - backgroundColor: AppColor.fieldBgColor(context), - showAsBottomSheet: true, - onSelect: (value) { - _assetDestination.site = value; - _assetDestination.building = null; - _assetDestination.floor = null; - _assetDestination.department = null; - setState(() {}); - }, - ).expanded, - 8.width, - SingleItemDropDownMenu( - context: context, - title: context.translation.building, - initialValue: _assetDestination.building, - showShadow: false, - showAsBottomSheet: true, - backgroundColor: AppColor.fieldBgColor(context), - enabled: _assetDestination.site?.buildings?.isNotEmpty ?? false, - staticData: _assetDestination.site?.buildings ?? [], - onSelect: (value) { - _assetDestination.building = value; - _assetDestination.floor = null; - _assetDestination.department = null; - setState(() {}); - }, - ).expanded, - ], - ), - 8.height, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SingleItemDropDownMenu( - context: context, - title: context.translation.floor, - showShadow: false, - showAsBottomSheet: true, - initialValue: _assetDestination.floor, - backgroundColor: AppColor.fieldBgColor(context), - enabled: _assetDestination.building?.floors?.isNotEmpty ?? false, - staticData: _assetDestination.building?.floors ?? [], - onSelect: (value) { - _assetDestination.floor = value; - _assetDestination.department = null; - setState(() {}); - }, - ).expanded, - 8.width, - SingleItemDropDownMenu( - context: context, - title: context.translation.department, - showShadow: false, - showAsBottomSheet: true, - initialValue: _assetDestination.department, - backgroundColor: AppColor.fieldBgColor(context), - enabled: _assetDestination.floor?.departments?.isNotEmpty ?? false, - staticData: _assetDestination.floor?.departments ?? [], - onSelect: (value) { - _assetDestination.department = value; - _assetDestination.room = null; - setState(() {}); - }, - ).expanded, - ], - ), - 8.height, - AppTextFormField( - backgroundColor: AppColor.fieldBgColor(context), - labelText: context.translation.callComments, - labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), - alignLabelWithHint: true, - textInputType: TextInputType.multiline, - showShadow: false, - onSaved: (text) { - _transferModel.comment = text; - }, - ), - 8.height, - 23.height, - AttachmentPicker( - label: context.translation.attachImage, - attachment: attachments, - buttonColor: AppColor.black10, - onlyImages: false, - buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), - ), - // 100.height, - ], - ).toShadowContainer(context).paddingOnly(top: 20, start: 16, end: 16), - ).expanded, - FooterActionButton.footerContainer( - context: context, - child: AppFilledButton(buttonColor: AppColor.primary10, label: context.translation.submitRequest, maxWidth: true, onPressed: _onSubmit), - ), - ], - ), + }, + ).expanded, + 8.width, + SingleItemDropDownMenu( + context: context, + title: context.translation.building, + initialValue: _assetDestination.building, + showShadow: false, + showAsBottomSheet: true, + backgroundColor: AppColor.fieldBgColor(context), + enabled: _assetDestination.site?.buildings?.isNotEmpty ?? false, + staticData: _assetDestination.site?.buildings ?? [], + onSelect: (value) { + _assetDestination.building = value; + _assetDestination.floor = null; + _assetDestination.department = null; + setState(() {}); + }, + ).expanded, + ], + ), + 8.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + SingleItemDropDownMenu( + context: context, + title: context.translation.floor, + showShadow: false, + showAsBottomSheet: true, + initialValue: _assetDestination.floor, + backgroundColor: AppColor.fieldBgColor(context), + enabled: _assetDestination.building?.floors?.isNotEmpty ?? false, + staticData: _assetDestination.building?.floors ?? [], + onSelect: (value) { + _assetDestination.floor = value; + _assetDestination.department = null; + setState(() {}); + }, + ).expanded, + 8.width, + SingleItemDropDownMenu( + context: context, + title: context.translation.department, + showShadow: false, + showAsBottomSheet: true, + initialValue: _assetDestination.department, + backgroundColor: AppColor.fieldBgColor(context), + enabled: _assetDestination.floor?.departments?.isNotEmpty ?? false, + staticData: _assetDestination.floor?.departments ?? [], + onSelect: (value) { + _assetDestination.department = value; + _assetDestination.room = null; + setState(() {}); + }, + ).expanded, + ], + ), + 8.height, + AppTextFormField( + backgroundColor: AppColor.fieldBgColor(context), + labelText: context.translation.callComments, + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), + alignLabelWithHint: true, + textInputType: TextInputType.multiline, + showShadow: false, + onSaved: (text) { + _transferModel.comment = text; + }, + ), + 8.height, + 23.height, + AttachmentPicker( + label: context.translation.attachImage, + attachment: attachments, + buttonColor: AppColor.black10, + onlyImages: false, + buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), + ), + // 100.height, + ], + ).toShadowContainer(context).paddingOnly(top: 20, start: 16, end: 16), + ).expanded, + FooterActionButton.footerContainer( + context: context, + child: AppFilledButton(buttonColor: AppColor.primary10, label: context.translation.submitRequest, maxWidth: true, onPressed: _onSubmit), + ), + ], ), ), ); diff --git a/lib/views/pages/device_transfer/search_device_page.dart b/lib/views/pages/device_transfer/search_device_page.dart index 93c87714..9c9acb8b 100644 --- a/lib/views/pages/device_transfer/search_device_page.dart +++ b/lib/views/pages/device_transfer/search_device_page.dart @@ -5,6 +5,7 @@ import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; +import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart'; @@ -169,36 +170,69 @@ class _SearchDevicePageState extends State { }, ).expanded, if (widget.multiSelection && selectedAssets.isNotEmpty) - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Expanded( - child: AppFilledButton( - label: "Clear", - buttonColor: AppColor.white60, - textColor: AppColor.black10, - loading: false, - onPressed: () async { - selectedAssets.clear(); - setState(() {}); - }, + FooterActionButton.footerContainer( + context: context, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + child: AppFilledButton( + label: "Clear", + buttonColor: AppColor.white60, + textColor: AppColor.black10, + loading: false, + onPressed: () async { + selectedAssets.clear(); + setState(() {}); + }, + ), ), - ), - 12.width, - Expanded( - child: AppFilledButton( - label: context.translation.select, - buttonColor: AppColor.primary10, - loading: false, - onPressed: () async { - Navigator.of(context).pop(); - List assets = _searchableList.where((asset) => selectedAssets.contains(asset.id)).toList(); - Navigator.of(context).pop(assets); - }, + 12.width, + Expanded( + child: AppFilledButton( + label: context.translation.select, + buttonColor: AppColor.primary10, + loading: false, + onPressed: () async { + Navigator.of(context).pop(); + List assets = _searchableList.where((asset) => selectedAssets.contains(asset.id)).toList(); + Navigator.of(context).pop(assets); + }, + ), ), - ), - ], - ).toShadowContainer(context), + ], + ) + ), + // Row( + // mainAxisSize: MainAxisSize.min, + // children: [ + // Expanded( + // child: AppFilledButton( + // label: "Clear", + // buttonColor: AppColor.white60, + // textColor: AppColor.black10, + // loading: false, + // onPressed: () async { + // selectedAssets.clear(); + // setState(() {}); + // }, + // ), + // ), + // 12.width, + // Expanded( + // child: AppFilledButton( + // label: context.translation.select, + // buttonColor: AppColor.primary10, + // loading: false, + // onPressed: () async { + // Navigator.of(context).pop(); + // List assets = _searchableList.where((asset) => selectedAssets.contains(asset.id)).toList(); + // Navigator.of(context).pop(assets); + // }, + // ), + // ), + // ], + // ).toShadowContainer(context), ], ), ), diff --git a/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart b/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart index 71c8bd5d..fe95e5d0 100644 --- a/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart +++ b/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart @@ -4,6 +4,7 @@ import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/base.dart'; +import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; @@ -159,22 +160,24 @@ class _SelectionBottomSheetState extends State { Widget build(BuildContext context) { _devicesProvider = Provider.of(context); return Scaffold( - body: SafeArea( - child: Stack( + appBar: DefaultAppBar(title: widget.title), + body: Column( + children: [ + Stack( children: [ QRView( key: qrKey, @@ -102,24 +107,35 @@ class _AssetScanQrState extends State { fit: BoxFit.fitHeight, ), ), - SizedBox(height: 60.toScreenHeight, child: CustomAppBar(title: widget.title)), ], - ), - ), - bottomSheet: Container( - height: 82.toScreenHeight, - color: Colors.white, - width: MediaQuery.of(context).size.width, - child: Center( - child: SizedBox( - height: 50.toScreenHeight, - width: 358.toScreenWidth, - child: AppFilledButton( - label: context.translation.pickManually, - onPressed: _pickManually, - ), + ).expanded, + FooterActionButton.footerContainer( + context: context, + child: AppFilledButton( + label: context.translation.pickManually, + onPressed: _pickManually, ), ), - )); + ], + ), + // bottomSheet: + // 16.height, + + // Container( + // height: 82.toScreenHeight, + // color: Colors.white, + // width: MediaQuery.of(context).size.width, + // child: Center( + // child: SizedBox( + // height: 50.toScreenHeight, + // width: 358.toScreenWidth, + // child: AppFilledButton( + // label: context.translation.pickManually, + // onPressed: _pickManually, + // ), + // ), + // ), + // ) + ); } }