diff --git a/lib/controllers/api_routes/urls.dart b/lib/controllers/api_routes/urls.dart index f8226e55..f06859cc 100644 --- a/lib/controllers/api_routes/urls.dart +++ b/lib/controllers/api_routes/urls.dart @@ -3,14 +3,14 @@ class URLs { static const String appReleaseBuildNumber = "24"; - static const host1 = "https://atomsm.hmg.com"; // production url + // static const host1 = "https://atomsm.hmg.com"; // production url // static const host1 = "https://atomsmdev.hmg.com"; // local DEV url - // static const host1 = "https://atomsmuat.hmg.com"; // local UAT url + static const host1 = "https://atomsmuat.hmg.com"; // local UAT url - // static String _baseUrl = "$_host/mobile"; + static String _baseUrl = "$_host/mobile"; // static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis // static final String _baseUrl = "$_host/mobile"; // host local UAT - static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM + // static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM static String _host = host1; diff --git a/lib/modules/cm_module/service_request_detail_provider.dart b/lib/modules/cm_module/service_request_detail_provider.dart index 50636738..cf7454cb 100644 --- a/lib/modules/cm_module/service_request_detail_provider.dart +++ b/lib/modules/cm_module/service_request_detail_provider.dart @@ -252,6 +252,7 @@ class ServiceRequestDetailProvider extends ChangeNotifier { } catch (e) { log("getWorkOrder [error] : $e"); isLoading = false; + currentWorkOrder = null; notifyListeners(); return null; } diff --git a/lib/modules/cm_module/views/components/service_request_detail_view.dart b/lib/modules/cm_module/views/components/service_request_detail_view.dart index 1bb4a9fb..f74c2c11 100644 --- a/lib/modules/cm_module/views/components/service_request_detail_view.dart +++ b/lib/modules/cm_module/views/components/service_request_detail_view.dart @@ -137,43 +137,49 @@ class _ServiceRequestDetailViewState extends State { children: [ Row( mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (Provider.of(context, listen: false).showPriority) ...[ - StatusLabel( - label: workOrder.priority?.name, - id: workOrder.priority!.id!, - radius: 4, - textColor: AppColor.getPriorityStatusTextColor(context, workOrder.priority!.id!), - backgroundColor: AppColor.getPriorityStatusColor(context, workOrder.priority!.id!), - ), - 8.width, - ], - if (workOrder.itgFormWorkOrderStatus != null) ...[ - StatusLabel( - label: workOrder.itgFormWorkOrderStatus, - id: 0, - radius: 4, - textColor: AppColor.getPriorityStatusTextColor(context, 82), - backgroundColor: AppColor.getPriorityStatusColor(context, 0), - ), - 8.width, - ], - StatusLabel( - radius: 4, - label: workOrder.status!.name, - textColor: AppColor.getHistoryLogStatusTextColorByName(workOrder.status!.name!), - backgroundColor: AppColor.getHistoryLogStatusColorByName(workOrder.status!.name!), - ), - if (workOrder.since != null) ...[ - 8.width, - StatusLabel( - radius: 4, - label: '${workOrder.since} days', - textColor: AppColor.neutral50, - backgroundColor: AppColor.orange30, - ), - ], - 1.width.expanded, + Wrap( + // spacing: 8, + runSpacing: 8, + children: [ + if (Provider.of(context, listen: false).showPriority) ...[ + StatusLabel( + label: workOrder.priority?.name, + id: workOrder.priority!.id!, + radius: 4, + textColor: AppColor.getPriorityStatusTextColor(context, workOrder.priority!.id!), + backgroundColor: AppColor.getPriorityStatusColor(context, workOrder.priority!.id!), + ), + 8.width, + ], + if (workOrder.itgFormWorkOrderStatus != null) ...[ + StatusLabel( + label: workOrder.itgFormWorkOrderStatus, + id: 0, + radius: 4, + textColor: AppColor.getPriorityStatusTextColor(context, 82), + backgroundColor: AppColor.getPriorityStatusColor(context, 0), + ), + 8.width, + ], + StatusLabel( + radius: 4, + label: workOrder.status!.name, + textColor: AppColor.getHistoryLogStatusTextColorByName(workOrder.status!.name!), + backgroundColor: AppColor.getHistoryLogStatusColorByName(workOrder.status!.name!), + ), + if (workOrder.since != null) ...[ + 8.width, + StatusLabel( + radius: 4, + label: '${workOrder.since} days', + textColor: AppColor.neutral50, + backgroundColor: AppColor.orange30, + ), + ], + ], + ).expanded, Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ @@ -181,7 +187,7 @@ class _ServiceRequestDetailViewState extends State { // context.translation.code.toSvgAsset(width: 48).onPress(() { // // Navigator.push(context, MaterialPageRoute(builder: (context) => UpdateServiceRequestPage(serviceRequest: serviceRequest))); // }), - if (userProvider.user!.type == UsersTypes.engineer) 16.height, + // if (userProvider.user!.type == UsersTypes.engineer) 16.height, Text( workOrder.requestedDate!.toString().toServiceRequestCardFormat, textAlign: TextAlign.end, @@ -191,6 +197,7 @@ class _ServiceRequestDetailViewState extends State { ) ], ), + 8.height, Text( context.translation.assetInformation, style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), @@ -507,9 +514,7 @@ class _ServiceRequestDetailViewState extends State { style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), ).expanded, if (!provider.isReadOnlyRequest) - "edit_icon".toSvgAsset(height: 21, width: 21, - color: context.isDark?AppColor.primary10:null - ).onPress(() async { + "edit_icon".toSvgAsset(height: 21, width: 21, color: context.isDark ? AppColor.primary10 : null).onPress(() async { provider.refreshTimer = false; await Navigator.push(context, MaterialPageRoute(builder: (context) => CostDetailFormScreen(isEdit: true))); provider.refreshTimer = true; diff --git a/lib/new_views/common_widgets/single_item_drop_down_menu.dart b/lib/new_views/common_widgets/single_item_drop_down_menu.dart index 404269fa..6c8bf17c 100644 --- a/lib/new_views/common_widgets/single_item_drop_down_menu.dart +++ b/lib/new_views/common_widgets/single_item_drop_down_menu.dart @@ -16,6 +16,7 @@ class SingleItemDropDownMenu exte final BuildContext context; final Function(T?)? onSelect; // Now accepts nullable values final T? initialValue; + final T? disableValue; final bool enabled; final bool showAsBottomSheet; final bool showAsFullScreenDialog; @@ -35,6 +36,7 @@ class SingleItemDropDownMenu exte required this.context, this.onSelect, this.initialValue, + this.disableValue, this.enabled = true, this.height, this.showAsBottomSheet = false, @@ -160,11 +162,13 @@ class _SingleItemDropDownMenuState) ?? [], // Provide default empty list if null selectedItem: _selectedItem, + disableItem: widget.disableValue, title: widget.title, showCancel: widget.showCancel, onSelect: (selectedT) { 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 89a7eff8..403249df 100644 --- a/lib/views/pages/device_transfer/create__device_transfer_request.dart +++ b/lib/views/pages/device_transfer/create__device_transfer_request.dart @@ -80,7 +80,7 @@ class _CreateDeviceTransferRequestState extends State attachement = []; for (var item in attachments) { - 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(AssetTransferAttachment(id: item.id, attachmentName: fileName)); } _transferModel.attachments = attachement; @@ -135,19 +135,26 @@ class _CreateDeviceTransferRequestState extends State extends StatefulWidget { +class SelectionFullScreenDialog extends StatefulWidget { final List? items; final T? selectedItem; // Now nullable + final T? disableItem; // Now nullable final String title; final bool showCancel; final SelectionBuilderString builderString; final Function(T?) onSelect; - const SelectionFullScreenDialog({Key? key, this.items, this.selectedItem, this.title = "", required this.builderString, this.showCancel = false, required this.onSelect}) : super(key: key); + const SelectionFullScreenDialog({Key? key, this.items, this.selectedItem, this.disableItem, this.title = "", required this.builderString, this.showCancel = false, required this.onSelect}) + : super(key: key); @override _SelectionBottomSheetState createState() => _SelectionBottomSheetState(); } -class _SelectionBottomSheetState extends State> { +class _SelectionBottomSheetState extends State> { T? _selectedValue; // Now nullable String query = ""; @@ -86,12 +89,12 @@ class _SelectionBottomSheetState extends State> backgroundColor: WidgetStateProperty.all( AppColor.fieldBgColor(context), // Your custom background color ), - leading: Icon(Icons.search, color: AppColor.iconColor(context)), + leading: Icon(Icons.search, color: AppColor.iconColor(context)), textStyle: WidgetStateProperty.all( - TextStyle(color: AppColor.textColor(context), fontSize: 16.0), + TextStyle(color: AppColor.textColor(context), fontSize: 16.0), ), hintStyle: WidgetStateProperty.all( - TextStyle(color: AppColor.textColor(context), fontSize: 14.0), + TextStyle(color: AppColor.textColor(context), fontSize: 14.0), ), hintText: 'Search by name', onChanged: (queryString) { @@ -124,39 +127,43 @@ class _SelectionBottomSheetState extends State> 8.height, Expanded( child: ListView.builder( - itemCount: filteredList?.length, - padding: EdgeInsets.zero, - itemBuilder: (cxt, index) =>Theme( - data: Theme.of(context).copyWith( - radioTheme: RadioThemeData( - fillColor: MaterialStateColor.resolveWith((states) { - if (states.contains(MaterialState.selected)) { - return AppColor.iconColor(context); // Active color - } - return Colors.grey; // Inactive color - }), - ), - ), - child: RadioListTile( - // Specify type for RadioListTile - value: filteredList![index], - dense: true, - contentPadding: const EdgeInsets.only(left: 16, right: 16), - groupValue: _selectedValue, - activeColor: AppColor.iconColor(context), - hoverColor: Colors.transparent, - onChanged: (value) { - _selectedValue = value; - searchFocusNode.unfocus(); - setState(() {}); - }, - title: Text( - widget.builderString(filteredList![index]).cleanupWhitespace.capitalizeFirstOfEach ?? "", - style: Theme.of(context).textTheme.bodyLarge, - ), - ), - ), - ), + itemCount: filteredList?.length, + padding: EdgeInsets.zero, + itemBuilder: (cxt, index) { + bool isDisabledItem = widget.disableItem != null && widget.disableItem?.identifier == filteredList![index].identifier; + return Theme( + data: Theme.of(context).copyWith( + radioTheme: RadioThemeData( + fillColor: MaterialStateColor.resolveWith((states) { + if (states.contains(MaterialState.selected)) { + return AppColor.iconColor(context); // Active color + } + return Colors.grey; // Inactive color + }), + ), + ), + child: RadioListTile( + // Specify type for RadioListTile + value: filteredList![index], + dense: true, + contentPadding: const EdgeInsets.only(left: 16, right: 16), + groupValue: _selectedValue, + activeColor: AppColor.iconColor(context), + hoverColor: Colors.transparent, + onChanged: isDisabledItem + ? null + : (value) { + _selectedValue = value; + searchFocusNode.unfocus(); + setState(() {}); + }, + title: Text( + widget.builderString(filteredList![index]).cleanupWhitespace.capitalizeFirstOfEach ?? "", + style: Theme.of(context).textTheme.bodyLarge?.copyWith(color: isDisabledItem ? AppColor.neutral20:null), + ), + ), + ); + }), ), 8.height, if (_selectedValue != null)