From 0908cda2b0786040a57e0637d50740609b5b5758 Mon Sep 17 00:00:00 2001 From: WaseemAbbasi22 Date: Tue, 20 Jan 2026 17:52:33 +0300 Subject: [PATCH] Ui improvement and delivery inspection new apis implemented --- lib/controllers/api_routes/urls.dart | 2 + .../providers/api/devices_provider.dart | 4 +- .../helper_function.dart | 4 +- .../delivery_inspection_form_model.dart | 6 +- .../technical_inspection_asset_model.dart | 4 + .../pages/asset_delivery_page.dart | 10 +- .../pages/attachment_view.dart | 21 +- .../delivery_inspection_form_view.dart | 203 +++++++----------- .../inpection_bottomsheet.dart | 117 +++++++--- .../end_user_cost_center_list_view.dart | 2 +- ...ate_end_user_cost_center_details_view.dart | 10 +- .../pages/history_log_view.dart | 132 ++++++------ .../status_checklist_view.dart | 14 +- .../technical_inpection_asset_card_view.dart | 5 + .../technical_inspection_lines_list_view.dart | 2 +- .../update_child_asset_view.dart | 31 +-- .../update_parent_asset_view.dart | 49 ++--- ...pdate_technical_inspection_lines_view.dart | 27 +-- .../provider/asset_delivery_provider.dart | 46 ++++ .../common_widgets/app_filled_button.dart | 4 +- .../widgets/e_signature/e_signature.dart | 108 ++++++---- 21 files changed, 434 insertions(+), 367 deletions(-) diff --git a/lib/controllers/api_routes/urls.dart b/lib/controllers/api_routes/urls.dart index 0930ace5..fc41f648 100644 --- a/lib/controllers/api_routes/urls.dart +++ b/lib/controllers/api_routes/urls.dart @@ -412,6 +412,8 @@ class URLs { static get getAssetDeliveryInspectionData => '$_baseUrl/AssetDeliveryExternalDeliveryInspection/GetAssetDeliveryExternalDeliveryInspectionByDeliveryId'; static get getOracleUserList => '$_baseUrl/AssetDeliveryExternal/GetEmployeesFromOracle'; + static get saveMasterInfoDeliveryInspection => '$_baseUrl/AssetDeliveryExternalDeliveryInspection/SaveMaseterInfoDeliveryInspection'; + static get sendEmailToAddSignature => '$_baseUrl/Signature/SendEmailToAddSignature'; static get getLineFromExternalPo => '$_baseUrl/AssetDeliveryExternalDeliveryInspection/GetLineFromExternalPo'; static get getCostCenterListToLineDeliveryInspection => '$_baseUrl/AssetDeliveryExternalDeliveryInspection/GetCostCenterToLineDeliveryInspection'; diff --git a/lib/controllers/providers/api/devices_provider.dart b/lib/controllers/providers/api/devices_provider.dart index ab196c11..bc0e5a61 100644 --- a/lib/controllers/providers/api/devices_provider.dart +++ b/lib/controllers/providers/api/devices_provider.dart @@ -40,7 +40,7 @@ class AssetProvider extends ChangeNotifier { List _devices = []; List _searchDevices = []; - List technicalInspectionAsset= []; + List technicalInspectionAsset = []; List get devices => _devices; @@ -133,8 +133,6 @@ class AssetProvider extends ChangeNotifier { if (response.statusCode >= 200 && response.statusCode < 300) { List equipmentListJson = json.decode(response.body)["data"]; var dList = equipmentListJson.map((asset) => TechnicalInspectionAssetBasicInfoModel.fromJson(asset)).toList() ?? []; - log('dlist ${dList.length}'); - technicalInspectionAsset.addAll(dList); nextPage = true; } else { diff --git a/lib/modules/asset_delivery_module/helper_function.dart b/lib/modules/asset_delivery_module/helper_function.dart index 0cfb122e..f2958ebe 100644 --- a/lib/modules/asset_delivery_module/helper_function.dart +++ b/lib/modules/asset_delivery_module/helper_function.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:test_sa/controllers/providers/api/device_transfer_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; +import 'package:test_sa/extensions/string_extensions.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/pages/attachment_view.dart'; @@ -58,7 +60,7 @@ class HelperFunction { children: [ SingleItemDropDownMenu( context: context, - title: context.translation.reason, + title: 'Attachment Type'.addTranslation, onSelect: (value) { Navigator.pop(context, value); }, diff --git a/lib/modules/asset_delivery_module/models/delivery_inspection_form_model.dart b/lib/modules/asset_delivery_module/models/delivery_inspection_form_model.dart index 4d73b496..e15082f7 100644 --- a/lib/modules/asset_delivery_module/models/delivery_inspection_form_model.dart +++ b/lib/modules/asset_delivery_module/models/delivery_inspection_form_model.dart @@ -44,13 +44,13 @@ class DeliveryInspectionFormModel { 'deliveryInspectionInspectedDateTo': deliveryInspectionInspectedDateTo?.toIso8601String(), 'totalTime': totalTime, 'deliveryInspectionInspectedBy': inspectedByModel?.name, - "deliveryInspectionInspectedBySignature": inspectedByModel?.signature, + // "deliveryInspectionInspectedBySignature": inspectedByModel?.signature, "deliveryInspectionInspectedByEmail": inspectedByModel?.email, 'deliveryInspectionApprovedBy': approvedByModel?.name, - "deliveryInspectionApprovedBySignature": approvedByModel?.signature, + // "deliveryInspectionApprovedBySignature": approvedByModel?.signature, "deliveryInspectionApprovedByEmail": approvedByModel?.email, "deliveryInspectionThirdApproverBy": thirdApprovalModel?.name, - "deliveryInspectionThirdApproverBySignature": thirdApprovalModel?.signature, + // "deliveryInspectionThirdApproverBySignature": thirdApprovalModel?.signature, "deliveryInspectionThirdApproverByEmail": thirdApprovalModel?.email, }; } diff --git a/lib/modules/asset_delivery_module/models/technical_inspection_asset_model.dart b/lib/modules/asset_delivery_module/models/technical_inspection_asset_model.dart index fafcc277..31f2913d 100644 --- a/lib/modules/asset_delivery_module/models/technical_inspection_asset_model.dart +++ b/lib/modules/asset_delivery_module/models/technical_inspection_asset_model.dart @@ -14,6 +14,7 @@ class TechnicalInspectionAssetModel { num? id; num? tableItemId; num? lineId; + num? lineNo; num? assetDeliveryInternalDetailAssetId; num? assetDeliveryInternalDetailAssetChildId; num? costCenterId; @@ -47,6 +48,7 @@ class TechnicalInspectionAssetModel { this.tableItemId, this.status, this.lineId, + this.lineNo, this.costCenterId, this.assetNumber, this.assetOrigin, @@ -73,6 +75,7 @@ class TechnicalInspectionAssetModel { TechnicalInspectionAssetModel.fromJson(Map json) { id = json['id']; + lineNo = json['lineNo']; assetDeliveryInternalDetailAssetId = json['assetDeliveryInternalDetailAssetId']; assetDeliveryInternalDetailAssetChildId = json['assetDeliveryInternalDetailAssetChildId']; assetNumber = json['assetNumber']; @@ -106,6 +109,7 @@ class TechnicalInspectionAssetModel { Map toJson() { final Map data = {}; data['id'] = id; + // data['lineNo'] = lineNo; data['assetDeliveryInternalDetailAssetId'] = assetDeliveryInternalDetailAssetId; data['assetDeliveryExternalDeliveryId'] = tableItemId; data['assetDeliveryExternalDetailId'] = lineId; diff --git a/lib/modules/asset_delivery_module/pages/asset_delivery_page.dart b/lib/modules/asset_delivery_module/pages/asset_delivery_page.dart index a4ce0983..28391201 100644 --- a/lib/modules/asset_delivery_module/pages/asset_delivery_page.dart +++ b/lib/modules/asset_delivery_module/pages/asset_delivery_page.dart @@ -87,13 +87,13 @@ class _AssetDeliveryPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - requestDetailCard(context), - const Divider().defaultStyle(context), + requestDetailCard(context).toShadowContainer(context, borderRadius: 20), + 20.height, Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - "Asset Delivery Table", + "Asset Delivery Table".addTranslation, style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), ), Row( @@ -130,10 +130,10 @@ class _AssetDeliveryPageState extends State { }), ], ), - 8.height, + 16.height, assetDeliveryTableList(context: context, assetDeliveryProvider: provider), ], - ).toShadowContainer(context, borderRadius: 20), + ), ); }, ), diff --git a/lib/modules/asset_delivery_module/pages/attachment_view.dart b/lib/modules/asset_delivery_module/pages/attachment_view.dart index 2f4020e7..5759ebe8 100644 --- a/lib/modules/asset_delivery_module/pages/attachment_view.dart +++ b/lib/modules/asset_delivery_module/pages/attachment_view.dart @@ -27,10 +27,10 @@ class AssetDeliveryAttachmentView extends StatefulWidget { bool viewOnly = false; final List attachmentList; - AssetDeliveryAttachmentView({ + AssetDeliveryAttachmentView({ super.key, required this.attachmentList, - this.viewOnly=false, + this.viewOnly = false, this.attachmentType, this.tableItemId, }); @@ -106,15 +106,16 @@ class _AssetDeliveryAttachmentViewState extends State ), ]); model = results[0] as DeliveryInspectionFormModel; - setState(() { - isLoading = false; - }); + if (mounted) { + setState(() { + isLoading = false; + }); + } } @override @@ -91,12 +93,6 @@ class _DeliveryInspectionFormViewState extends State Widget build(BuildContext context) { return Scaffold( backgroundColor: Theme.of(context).scaffoldBackgroundColor, - // appBar: DefaultAppBar( - // title: 'Delivery Inspection'.addTranslation, - // onBackPress: () { - // Navigator.pop(context); - // }, - // ), body: isLoading ? const CircularProgressIndicator(color: AppColor.primary10).center : Form( @@ -104,51 +100,38 @@ class _DeliveryInspectionFormViewState extends State child: Column( children: [ SingleChildScrollView( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (!viewOnly) ...[inspectionDetailsForm()] else ...[inspectionDetails()], - 8.height, - Text( - 'Total Time'.addTranslation, - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), - ), - 8.height, - Text( - formatInspectionDuration(model.totalTime), - style: AppTextStyles.bodyText2.copyWith( - color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, - ), - ), - - // Text( - // model.totalTime != null ? '${model.totalTime.toString()} hours' : '-', - // style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120), - // ), - 8.height, - const Divider().defaultStyle(context), - Text( - "Lines", - style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), - ), - 8.height, - linesList(context), - ], - ).toShadowContainer(context, borderRadius: 20, padding: 12)) - .expanded, + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (!viewOnly) ...[inspectionDetailsForm()] else ...[inspectionDetails()], + 20.height, + Text( + "Lines", + style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), + ), + 8.height, + linesList(context), + ], + )).expanded, FooterActionButton.footerContainer( context: context, child: !viewOnly ? Column( children: [ - AppFilledButton( - buttonColor: AppColor.primary10, - label: 'Attachments'.addTranslation, - maxWidth: true, - onPressed: () { - HelperFunction.attachmentTap(context: context, assetDeliveryProvider: assetDeliveryProvider!, deliveryTableItemId: widget.deliveryTableModel.id); - }), + Row( + children: [ + AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap).expanded, + 8.width, + AppFilledButton( + buttonColor: AppColor.primary10, + label: 'Attachments'.addTranslation, + maxWidth: true, + onPressed: () { + HelperFunction.attachmentTap(context: context, assetDeliveryProvider: assetDeliveryProvider!, deliveryTableItemId: widget.deliveryTableModel.id); + }).expanded, + ], + ), 16.height, Row( children: [ @@ -247,6 +230,7 @@ class _DeliveryInspectionFormViewState extends State Widget inspectionDetailsForm() { return Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ _inspectionTile( title: 'Inspected by'.addTranslation, @@ -264,7 +248,6 @@ class _DeliveryInspectionFormViewState extends State } }, ), - 8.height, _inspectionTile( title: 'Approved by'.addTranslation, @@ -285,13 +268,13 @@ class _DeliveryInspectionFormViewState extends State if (widget.requestModel?.paymentTerm?.value == 2) ...[ 8.height, _inspectionTile( - title: 'Third Approved by'.addTranslation, + title: 'ThirdApprover'.addTranslation, model: model.thirdApprovalModel, isHmg: widget.requestModel?.isHMG == true, onTap: () async { final result = await showInspectionBottomSheet( context, - title: 'Third Approved by'.addTranslation, + title: 'ThirdApprover'.addTranslation, isHmg: widget.requestModel?.isHMG == true, initialModel: model.thirdApprovalModel ?? InspectionPersonModel(), ); @@ -301,57 +284,6 @@ class _DeliveryInspectionFormViewState extends State }, ), ], - - // if (widget.requestModel?.isHMG == true) ...[ - // OracleUserAutoCompleteField( - // clearAfterPick: false, - // initialValue: model.deliveryInspectionInspectedBy ?? '', - // label: 'Inspected by'.addTranslation, - // onPick: (value) { - // model.deliveryInspectionInspectedBy = value.fullName; - // setState(() {}); - // }, - // onChanged: (value) {}, - // ), - // 8.height, - // OracleUserAutoCompleteField( - // clearAfterPick: false, - // initialValue: model.deliveryInspectionApprovedBy ?? '', - // label: 'Approved by'.addTranslation, - // onChanged: (value) {}, - // onPick: (value) { - // model.deliveryInspectionApprovedBy = value.fullName; - // setState(() {}); - // }, - // ), - // ] //No HMG user free text insted of dropdown ... - // else ...[ - // AppTextFormField( - // labelText: 'Inspected by'.addTranslation, - // backgroundColor: AppColor.fieldBgColor(context), - // initialValue: model.deliveryInspectionInspectedBy ?? '', - // textAlign: TextAlign.center, - // labelStyle: AppTextStyles.textFieldLabelStyle, - // showShadow: false, - // onChange: (value) { - // model.deliveryInspectionInspectedBy = value; - // }, - // style: Theme.of(context).textTheme.titleMedium, - // ), - // 8.height, - // AppTextFormField( - // labelText: 'Approved by'.addTranslation, - // backgroundColor: AppColor.fieldBgColor(context), - // initialValue: model.deliveryInspectionApprovedBy ?? '', - // textAlign: TextAlign.center, - // labelStyle: AppTextStyles.textFieldLabelStyle, - // showShadow: false, - // onChange: (value) { - // model.deliveryInspectionApprovedBy = value; - // }, - // style: Theme.of(context).textTheme.titleMedium, - // ), - // ], 8.height, ADatePicker( label: 'Inspected Date/Time From'.addTranslation, @@ -385,7 +317,6 @@ class _DeliveryInspectionFormViewState extends State setState(() {}); }, ), - 8.height, ADatePicker( label: 'Inspected Date/Time To'.addTranslation, @@ -424,8 +355,20 @@ class _DeliveryInspectionFormViewState extends State setState(() {}); }, ), + 8.height, + Text( + 'Total Time'.addTranslation, + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), + ), + 8.height, + Text( + formatInspectionDuration(model.totalTime), + style: AppTextStyles.bodyText2.copyWith( + color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, + ), + ), ], - ); + ).toShadowContainer(context, borderRadius: 20, padding: 12); } bool _validateInspectionDates({DateTime? from, DateTime? to}) { @@ -552,8 +495,20 @@ class _DeliveryInspectionFormViewState extends State model.deliveryInspectionInspectedDateTo != null ? model.deliveryInspectionInspectedDateTo!.toString().toServiceRequestDetailsFormat : '-', style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120), ), + 8.height, + Text( + 'Total Time'.addTranslation, + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), + ), + 8.height, + Text( + formatInspectionDuration(model.totalTime), + style: AppTextStyles.bodyText2.copyWith( + color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, + ), + ), ], - ); + ).toShadowContainer(context, borderRadius: 20, padding: 12); } Widget _inspectionTile({ @@ -603,24 +558,6 @@ class _DeliveryInspectionFormViewState extends State ); } - Future showAttachmentTypePicker() { - return showDialog( - context: context, - builder: (_) { - return AlertDialog( - content: SingleItemDropDownMenu( - context: context, - title: context.translation.reason, - showAsFullScreenDialog: false, - onSelect: (value) { - Navigator.pop(context, value); - }, - ), - ); - }, - ); - } - void _cancelTap() async { showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); await assetDeliveryProvider!.changeDeliveryStatusToCancel(itemId: widget.deliveryTableModel.id).then((status) async { @@ -632,6 +569,19 @@ class _DeliveryInspectionFormViewState extends State }); } + void _saveTap() async { + _formKey.currentState!.save(); + showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); + model.assetDeliveryExternalDeliveryId = widget.deliveryTableModel.id; + await assetDeliveryProvider!.saveMasterInfoDeliveryInspection(requestPayload: model.toJson()).then((status) async { + Navigator.pop(context); + if (status) { + Navigator.pop(context); + await assetDeliveryProvider!.getAssetDeliveryTableListById(requestId: widget.requestModel?.id); + } + }); + } + void _nextTap() { if (widget.deliveryTableModel.isContainsTechnicalInspection == true) { // Navigator.push( @@ -678,8 +628,8 @@ class _DeliveryInspectionFormViewState extends State void _changeStatusTap() async { _formKey.currentState!.save(); showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); - model.assetDeliveryExternalDeliveryId = widget.deliveryTableModel.id; - await assetDeliveryProvider!.changeDeliveryStatus(requestPayload: model.toJson()).then((status) async { + // await assetDeliveryProvider!.changeDeliveryStatus(requestPayload: model.toJson()).then((status) async { + await assetDeliveryProvider!.changeDeliveryStatus(itemId: widget.deliveryTableModel.id).then((status) async { Navigator.pop(context); if (status) { Navigator.pop(context); @@ -707,6 +657,7 @@ class _DeliveryInspectionFormViewState extends State return InspectionPersonBottomSheet( title: title, isHmg: isHmg, + tableId: widget.deliveryTableModel.id, model: InspectionPersonModel( name: initialModel.name, email: initialModel.email, diff --git a/lib/modules/asset_delivery_module/pages/delivery_inspection/inpection_bottomsheet.dart b/lib/modules/asset_delivery_module/pages/delivery_inspection/inpection_bottomsheet.dart index 434f3382..de928263 100644 --- a/lib/modules/asset_delivery_module/pages/delivery_inspection/inpection_bottomsheet.dart +++ b/lib/modules/asset_delivery_module/pages/delivery_inspection/inpection_bottomsheet.dart @@ -2,14 +2,19 @@ import 'dart:convert'; import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; +import 'package:test_sa/dashboard_latest/widgets/app_bar_widget.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/string_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; +import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/modules/asset_delivery_module/models/inspection_person_model.dart'; import 'package:test_sa/modules/asset_delivery_module/pages/delivery_inspection/oracle_user_autocomplete_field.dart'; +import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; +import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart'; import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart'; import 'package:test_sa/views/widgets/e_signature/e_signature.dart'; @@ -17,12 +22,14 @@ class InspectionPersonBottomSheet extends StatefulWidget { final String title; bool isHmg; final InspectionPersonModel model; + int? tableId; InspectionPersonBottomSheet({ super.key, required this.title, required this.isHmg, required this.model, + this.tableId, }); @override @@ -67,7 +74,7 @@ class _InspectionPersonBottomSheetState extends State(context, listen: false); + if (nameController.text.isEmpty) { + return 'Enter Name'.showToast; + } + String type = ''; + if (widget.title.contains('Inspected')) { + type = 'Inspected'; + } else if (widget.title.contains('Approved')) { + type = 'Approved'; + } else if (widget.title.contains('ThirdApprover')) { + type = 'ThirdApprover'; + } + + Map payload = { + "recordId": widget.tableId, + "parameter1": "DeliveryInspection", + "parameter2": type, + "username": nameController.text, + "email": emailController.text + }; + showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); + await assetDeliveryProvider.sendEmailToAddSignature(requestPayload: payload).then((status) async { + Navigator.pop(context); + if (status) { + 'Email sent successfully'.showToast; + } + }); + + //send email. + }), + ], + ], ), - 12.height, + 8.height, ESignature( title: '', + editable: false, oldSignature: _model.localSignature == null ? _model.signature : null, newSignature: _model.localSignature, backgroundColor: AppColor.neutral100, showShadow: false, - onChange: (signature) { - if (signature.isEmpty) return; - setState(() { - _model.localSignature = signature; - _model.signature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; - }); - }, - onSaved: (signature) { - if (signature == null || signature.isEmpty) return; - setState(() { - _model.localSignature = signature; - _model.signature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; - }); - }, + // onChange: (signature) { + // if (signature.isEmpty) return; + // setState(() { + // _model.localSignature = signature; + // _model.signature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; + // }); + // }, + // onSaved: (signature) { + // if (signature == null || signature.isEmpty) return; + // setState(() { + // _model.localSignature = signature; + // _model.signature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; + // }); + // }, ), - 20.height, + 12.height, AppFilledButton( label: context.translation.save, maxWidth: true, diff --git a/lib/modules/asset_delivery_module/pages/end_user_acceptance/end_user_cost_center_list_view.dart b/lib/modules/asset_delivery_module/pages/end_user_acceptance/end_user_cost_center_list_view.dart index f032d75a..7b9336bc 100644 --- a/lib/modules/asset_delivery_module/pages/end_user_acceptance/end_user_cost_center_list_view.dart +++ b/lib/modules/asset_delivery_module/pages/end_user_acceptance/end_user_cost_center_list_view.dart @@ -83,7 +83,7 @@ class _EndUserCostCenterLIstViewState extends State { : Column( children: [ //Refactor this - SingleChildScrollView(padding: const EdgeInsets.all(16), child: linesList(context).toShadowContainer(context, borderRadius: 20, padding: 12)).expanded, + SingleChildScrollView(padding: const EdgeInsets.all(16), child: linesList(context)).expanded, !viewOnly ? FooterActionButton.footerContainer( diff --git a/lib/modules/asset_delivery_module/pages/end_user_acceptance/update_end_user_cost_center_details_view.dart b/lib/modules/asset_delivery_module/pages/end_user_acceptance/update_end_user_cost_center_details_view.dart index 1234a018..3b5d74bb 100644 --- a/lib/modules/asset_delivery_module/pages/end_user_acceptance/update_end_user_cost_center_details_view.dart +++ b/lib/modules/asset_delivery_module/pages/end_user_acceptance/update_end_user_cost_center_details_view.dart @@ -108,9 +108,7 @@ class _UpdateEndUserCostCenterDetailsViewState extends State createState() => _AssetDeliveryHistoryLogViewState(); } - - - class _AssetDeliveryHistoryLogViewState extends State { List history = []; + bool loading = false; + @override void initState() { WidgetsBinding.instance.addPostFrameCallback((_) { @@ -33,10 +33,18 @@ class _AssetDeliveryHistoryLogViewState extends State(context, listen: false).getHistory(tableItemId: widget.tableItemId); + if (mounted) { + setState(() { + loading = false; + }); + } } + @override Widget build(BuildContext context) { return Scaffold( @@ -47,65 +55,64 @@ class _AssetDeliveryHistoryLogViewState extends State(builder: (context, provider, _) { - return provider.isLoading - ? const CircularProgressIndicator(color: AppColor.primary10).center - : Stack( - children: [ - Padding( - padding: EdgeInsets.only(left: 122.toScreenWidth), - child: const VerticalDivider( - color: AppColor.white40, - thickness: 2, - width: 20, - indent: 10, - endIndent: 10, - ), - ), - SafeArea( - child: Builder(builder: (cxt) { - List items = []; - String lastStatus = ""; - DateTime? nextDate; - for (int i = 0; i < history.length; i++) { - var object = history[i]; - String currentStatus = object.status!.name!; - if (lastStatus.isEmpty) { - lastStatus = currentStatus; - } - if (lastStatus == currentStatus) { - if (i + 1 < history.length) { - nextDate = history[i + 1].createdDate; - String timeDifference = CMRequestUtils.calculateTimeDifference(object.createdDate!, nextDate!); - object.timeDifference = timeDifference; - } else { - object.timeDifference = ''; // Empty string for the last action + body: loading + ? const CircularProgressIndicator(color: AppColor.primary10).center + : Stack( + children: [ + Padding( + padding: EdgeInsets.only(left: 122.toScreenWidth), + child: const VerticalDivider( + color: AppColor.white40, + thickness: 2, + width: 20, + indent: 10, + endIndent: 10, + ), + ), + SafeArea( + child: Builder(builder: (cxt) { + List items = []; + String lastStatus = ""; + DateTime? nextDate; + for (int i = 0; i < history.length; i++) { + var object = history[i]; + String currentStatus = object.status!.name!; + if (lastStatus.isEmpty) { + lastStatus = currentStatus; + } + if (lastStatus == currentStatus) { + if (i + 1 < history.length) { + nextDate = history[i + 1].createdDate; + String timeDifference = CMRequestUtils.calculateTimeDifference(object.createdDate!, nextDate!); + object.timeDifference = timeDifference; + } else { + object.timeDifference = ''; // Empty string for the last action + } + items.add(historyLogCard(cxt, object)); + } else { + items.add(statusCard(cxt, lastStatus)); + lastStatus = currentStatus; + if (i + 1 < history.length) { + nextDate = history[i + 1].createdDate; + String timeDifference = CMRequestUtils.calculateTimeDifference(object.createdDate!, nextDate!); + object.timeDifference = timeDifference; + } else { + object.timeDifference = ''; // Empty string for the last action + } + items.add(historyLogCard(cxt, object)); + } } - items.add(historyLogCard(cxt, object)); - } else { items.add(statusCard(cxt, lastStatus)); - lastStatus = currentStatus; - if (i + 1 < history.length) { - nextDate = history[i + 1].createdDate; - String timeDifference = CMRequestUtils.calculateTimeDifference(object.createdDate!, nextDate!); - object.timeDifference = timeDifference; - } else { - object.timeDifference = ''; // Empty string for the last action - } - items.add(historyLogCard(cxt, object)); - } - } - items.add(statusCard(cxt, lastStatus)); - return SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: Column(children: items), - ); - }), + return SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column(children: items), + ); + }), + ), + ], ), - ], - ); - }), - );} + ); + } Widget historyLogCard(BuildContext context, AssetDeliveryHistoryModel object) { String title = object.status!.name!; @@ -148,7 +155,8 @@ class _AssetDeliveryHistoryLogViewState extends State { } Widget inspectionStatusRadioWidget({required int index, required InspectionChecklistItem model, required BuildContext context}) { - bool status = (model.status == null || model.status == null) ? true : (model.status != null ? (model.status == 'true' ? true : false) : false); + bool status = (model.status == null) ? false : (model.status != null ? (model.status == 'true' ? true : false) : false); return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Text( + // ' (${index+1}) ${model.title}', model.title ?? '', - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? Colors.white : AppColor.white936), + softWrap: true, + // maxLines: 1, + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? Colors.white : AppColor.white936, height: 1.5), ), - 14.height, + 7.height, // Column( // crossAxisAlignment: CrossAxisAlignment.start, // children: [ @@ -119,6 +120,7 @@ class _InspectionCheckListViewState extends State { status = !status; model.status = status.toString(); }); + updateStatus(index, status.toString()); }, child: Container( width: 99.toScreenWidth, @@ -158,7 +160,7 @@ class _InspectionCheckListViewState extends State { ), ), ], - ).paddingOnly(top: 4, bottom: 4); + ).paddingOnly(top: 14); } Widget buildToggleOption({ diff --git a/lib/modules/asset_delivery_module/pages/technical_inpection/technical_inpection_asset_card_view.dart b/lib/modules/asset_delivery_module/pages/technical_inpection/technical_inpection_asset_card_view.dart index b09eb878..c609d6ab 100644 --- a/lib/modules/asset_delivery_module/pages/technical_inpection/technical_inpection_asset_card_view.dart +++ b/lib/modules/asset_delivery_module/pages/technical_inpection/technical_inpection_asset_card_view.dart @@ -66,6 +66,11 @@ class TechnicalInspectionAssetCard extends StatelessWidget { ), 2.height, ], + if (!ischild) + Text( + 'Line No: ${assetModel.lineNo ?? '-'}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), Text( 'Asset Name: ${assetModel.modelDefinition?.assetName ?? '-'}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), 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 e2c05093..80b2308a 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 @@ -130,7 +130,7 @@ class _TechnicalInspectionLinesListViewState extends State { inspectionDetailsForm( lineId: widget.lineId, provider: provider, - ), - 8.height, - const Divider().defaultStyle(context), - 8.height, + ).toShadowContainer(context, borderRadius: 20, padding: 12), + 20.height, testLines( context: context, ) ], - ).toShadowContainer(context, borderRadius: 20, padding: 12)) + )) .expanded, FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap)), ], @@ -165,26 +163,7 @@ class _UpdateChildAssetViewState extends State { showShadow: false, enable: false, style: Theme.of(context).textTheme.titleMedium, - ).onPress(() async { - var data = await Navigator.push( - context, - MaterialPageRoute( - builder: (context) => TechnicalInspectionSearchAssetView( - lineId: lineId, - ))); - if (data != null) { - TechnicalInspectionAssetModel? assetModel = await provider.getAssetDetails(assetId: data?.id); - - if (assetModel != null) { - provider.setChildModel(assetModel); - if (assetModel.site != null) { - await provider.getSiteData(siteId: assetModel.site?.id, model: provider.childFormModel); - } - provider.setParentModel(assetModel); - populateTextFields(model: provider.childFormModel); - } - } - }), + ), 8.height, AppTextFormField( labelText: 'Asset Name'.addTranslation, @@ -415,7 +394,7 @@ class _UpdateChildAssetViewState extends State { orElse: () => InspectionChecklistItem(status: 'FAIL'), ) .status == - 'PASS'; + 'true'; } buildInspectionPayload(List checklist) { diff --git a/lib/modules/asset_delivery_module/pages/technical_inpection/update_parent_asset_view.dart b/lib/modules/asset_delivery_module/pages/technical_inpection/update_parent_asset_view.dart index ceafcfe6..41beefcb 100644 --- a/lib/modules/asset_delivery_module/pages/technical_inpection/update_parent_asset_view.dart +++ b/lib/modules/asset_delivery_module/pages/technical_inpection/update_parent_asset_view.dart @@ -114,34 +114,31 @@ class _UpdateParentAssetViewState extends State { : Column( children: [ SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + inspectionDetailsForm(lineId: widget.lineId, provider: provider).toShadowContainer(context, borderRadius: 20, padding: 12), + 20.height, + Row( children: [ - inspectionDetailsForm(lineId: widget.lineId, provider: provider), - 8.height, - const Divider().defaultStyle(context), - 8.height, - Row( - children: [ - Text( - "Test List", - style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), - ), - 8.width, - 'web_link_icon'.toSvgAsset().onPress(() { - openInspectionChecklist(context); - }), - ], + Text( + "Test List", + style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), ), - 8.height, - childList( - context: context, - provider: provider, - ) + 8.width, + 'web_link_icon'.toSvgAsset().onPress(() { + openInspectionChecklist(context); + }), ], - ).toShadowContainer(context, borderRadius: 20, padding: 12)) - .expanded, + ), + 16.height, + childList( + context: context, + provider: provider, + ) + ], + )).expanded, FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap)), ], ); @@ -468,7 +465,7 @@ class _UpdateParentAssetViewState extends State { orElse: () => InspectionChecklistItem(status: 'FAIL'), ) .status == - 'PASS'; + 'true'; } buildInspectionPayload(List checklist) { diff --git a/lib/modules/asset_delivery_module/pages/technical_inpection/update_technical_inspection_lines_view.dart b/lib/modules/asset_delivery_module/pages/technical_inpection/update_technical_inspection_lines_view.dart index 035fffe3..9edda2f6 100644 --- a/lib/modules/asset_delivery_module/pages/technical_inpection/update_technical_inspection_lines_view.dart +++ b/lib/modules/asset_delivery_module/pages/technical_inpection/update_technical_inspection_lines_view.dart @@ -89,24 +89,27 @@ class _UpdateTechnicalInspectionLinesViewState extends State saveMasterInfoDeliveryInspection({ + Map? requestPayload, + }) async { + isLoading = true; + try { + final response = await ApiManager.instance.post(URLs.saveMasterInfoDeliveryInspection, body: requestPayload??{}); + stateCode = response.statusCode; + if (response.statusCode >= 200 && response.statusCode < 300) { + isLoading = false; + notifyListeners(); + return true; + } else { + isLoading = false; + notifyListeners(); + return false; + } + } catch (error) { + isLoading = false; + notifyListeners(); + return false; + } + } + + Future sendEmailToAddSignature({ + Map? requestPayload, + }) async { + isLoading = true; + try { + final response = await ApiManager.instance.post(URLs.sendEmailToAddSignature, body: requestPayload??{}); + stateCode = response.statusCode; + if (response.statusCode >= 200 && response.statusCode < 300) { + isLoading = false; + notifyListeners(); + return true; + } else { + isLoading = false; + notifyListeners(); + return false; + } + } catch (error) { + isLoading = false; + notifyListeners(); + return false; + } + } + Future getAssetDeliveryInspectionData({int? itemId}) async { isLoading = true; DeliveryInspectionFormModel deliveryInspectionFormModel = DeliveryInspectionFormModel(); diff --git a/lib/new_views/common_widgets/app_filled_button.dart b/lib/new_views/common_widgets/app_filled_button.dart index f543615a..1ab0daf5 100644 --- a/lib/new_views/common_widgets/app_filled_button.dart +++ b/lib/new_views/common_widgets/app_filled_button.dart @@ -18,6 +18,7 @@ class AppFilledButton extends StatelessWidget { final bool showBorder; final double radius; final int height; + final double? width; final bool disableButton; const AppFilledButton( @@ -29,6 +30,7 @@ class AppFilledButton extends StatelessWidget { this.fontSize, this.loading = false, this.height = 56, + this.width, this.showBorder = false, this.disableButton = false, this.buttonColor, @@ -41,7 +43,7 @@ class AppFilledButton extends StatelessWidget { Widget build(BuildContext context) { return Container( height: height.toScreenHeight, - width: maxWidth ? double.infinity : null, + width: maxWidth ? double.infinity : width, alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), diff --git a/lib/views/widgets/e_signature/e_signature.dart b/lib/views/widgets/e_signature/e_signature.dart index 71f76ab0..64d297e3 100644 --- a/lib/views/widgets/e_signature/e_signature.dart +++ b/lib/views/widgets/e_signature/e_signature.dart @@ -4,6 +4,7 @@ import 'package:signature/signature.dart'; import 'package:test_sa/controllers/api_routes/urls.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; +import 'package:test_sa/extensions/string_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; @@ -16,10 +17,12 @@ class ESignature extends StatefulWidget { final Function(Uint8List?)? onSaved; final Color? backgroundColor; final Function(Uint8List)? onChange; + final bool editable; final bool showShadow; final String title; - const ESignature({Key? key, required this.title, required this.oldSignature, this.backgroundColor, this.onSaved, this.onChange, this.showShadow = true, required this.newSignature}) + const ESignature( + {Key? key, required this.title, required this.oldSignature, this.backgroundColor, this.onSaved, this.onChange, this.editable = true, this.showShadow = true, required this.newSignature}) : super(key: key); @override @@ -39,7 +42,6 @@ class _ESignatureState extends State { if (widget.newSignature != null) { signature = widget.newSignature; } - super.initState(); } @@ -69,54 +71,70 @@ class _ESignatureState extends State { borderRadius: _editable ? const BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)) : BorderRadius.circular(10), boxShadow: widget.showShadow ? [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)] : null, ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - widget.title.tinyFont(context).paddingOnly(top: 8), - (!_editable - ? "edit".toSvgAsset(width: 48).paddingOnly(top: 8) - : Container( - width: 48.toScreenWidth, - height: 48.toScreenWidth, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(100), border: Border.all(color: AppColor.neutral30)), - padding: const EdgeInsets.all(11), - margin: const EdgeInsets.only(top: 8), - child: "done".toSvgAsset(width: 26), - )) - .onPress(() async { - if (_editable) { - signature = await _controller!.toPngBytes(); - if (widget.onChange != null && signature != null) { - widget.onChange!(signature!); - } - } - _editable = !_editable; - setState(() {}); - }), - ], - ), - ((widget.oldSignature != null || signature != null) && !_editable) - ? Container( + child: widget.editable == false + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Signature'.addTranslation, + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), + ), + Container( height: 135.toScreenHeight, width: MediaQuery.of(context).size.width, padding: const EdgeInsets.only(bottom: 8), child: signature != null ? Image.memory(signature!) : ImageLoader(showDefaultIcon: true, boxFit: BoxFit.contain, url: URLs.getFileUrl(widget.oldSignature) ?? ''), - ) - : AbsorbPointer( - absorbing: !_editable, - child: Signature( - controller: _controller!, - height: 135.toScreenHeight, - width: MediaQuery.of(context).size.width - 64.toScreenWidth, - backgroundColor: Colors.transparent, - ), ), - ], - ), + ], + ) + : Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + widget.title.tinyFont(context).paddingOnly(top: 8), + (!_editable + ? "edit".toSvgAsset(width: 48).paddingOnly(top: 8) + : Container( + width: 48.toScreenWidth, + height: 48.toScreenWidth, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(100), border: Border.all(color: AppColor.neutral30)), + padding: const EdgeInsets.all(11), + margin: const EdgeInsets.only(top: 8), + child: "done".toSvgAsset(width: 26), + )) + .onPress(() async { + if (_editable) { + signature = await _controller!.toPngBytes(); + if (widget.onChange != null && signature != null) { + widget.onChange!(signature!); + } + } + _editable = !_editable; + setState(() {}); + }), + ], + ), + ((widget.oldSignature != null || signature != null) && !_editable) + ? Container( + height: 135.toScreenHeight, + width: MediaQuery.of(context).size.width, + padding: const EdgeInsets.only(bottom: 8), + child: signature != null ? Image.memory(signature!) : ImageLoader(showDefaultIcon: true, boxFit: BoxFit.contain, url: URLs.getFileUrl(widget.oldSignature) ?? ''), + ) + : AbsorbPointer( + absorbing: !_editable, + child: Signature( + controller: _controller!, + height: 135.toScreenHeight, + width: MediaQuery.of(context).size.width - 64.toScreenWidth, + backgroundColor: Colors.transparent, + ), + ), + ], + ), ), if (_editable) Container(