From 53b02874a06fe5bf601bb2b6a3f54a544351cacc Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Thu, 4 Jan 2024 11:20:15 +0300 Subject: [PATCH 1/2] Add validation on part no qty field --- lib/extensions/text_extensions.dart | 2 +- lib/views/pages/user/requests/work_order/part_no_button.dart | 2 +- lib/views/widgets/images/multi_image_picker_item.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/extensions/text_extensions.dart b/lib/extensions/text_extensions.dart index d09b3898..0cf27d12 100644 --- a/lib/extensions/text_extensions.dart +++ b/lib/extensions/text_extensions.dart @@ -27,7 +27,7 @@ extension TextStyles on String { Text overline(BuildContext context) => getTextWithStyle(this, AppTextStyles.overline, context.isDark ? AppColor.neutral10 : AppColor.neutral20); - Text getTextWithStyle(String string, TextStyle style, Color color) => Text(string, style: style.copyWith(color: color)); + Text getTextWithStyle(String string, TextStyle style, Color color) => Text(string ?? "", style: style.copyWith(color: color)); } extension CustomText on Text { diff --git a/lib/views/pages/user/requests/work_order/part_no_button.dart b/lib/views/pages/user/requests/work_order/part_no_button.dart index a4c0af22..9d8dfe67 100644 --- a/lib/views/pages/user/requests/work_order/part_no_button.dart +++ b/lib/views/pages/user/requests/work_order/part_no_button.dart @@ -78,7 +78,7 @@ class _PartNoButtonState extends State { labelText: context.translation.quantity, textInputType: TextInputType.number, backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral30, - enable: current != null, + enable: current != null && current.sparePart?.id != null, validator: (value) => value == null || value.isEmpty ? context.translation.requiredField : Validator.isNumeric(value) diff --git a/lib/views/widgets/images/multi_image_picker_item.dart b/lib/views/widgets/images/multi_image_picker_item.dart index 04666f67..7499669a 100644 --- a/lib/views/widgets/images/multi_image_picker_item.dart +++ b/lib/views/widgets/images/multi_image_picker_item.dart @@ -68,7 +68,7 @@ class MultiFilesPickerItem extends StatelessWidget { } else { if (!await launchUrl(Uri.parse(file.path), mode: LaunchMode.externalApplication)) { Fluttertoast.showToast(msg: "UnExpected Error with file."); - throw Exception('Could not launch '); + throw Exception('Could not launch'); } } }, From e8415399edd9cafa45156b603f8be42bbeec5ea2 Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Thu, 4 Jan 2024 11:24:56 +0300 Subject: [PATCH 2/2] Fix --- .../requests/work_order/work_order_details_page.dart | 8 ++++---- lib/views/widgets/requests/request_status.dart | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/views/pages/user/requests/work_order/work_order_details_page.dart b/lib/views/pages/user/requests/work_order/work_order_details_page.dart index 6c077aaa..a07c6dd9 100644 --- a/lib/views/pages/user/requests/work_order/work_order_details_page.dart +++ b/lib/views/pages/user/requests/work_order/work_order_details_page.dart @@ -49,9 +49,9 @@ class WorkOrderDetailsPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ StatusLabel( - label: workOrderDetails.currentSituation.name, - textColor: AppColor.getRequestStatusTextColorByName(context, workOrderDetails.currentSituation.name), - backgroundColor: AppColor.getRequestStatusColorByName(context, workOrderDetails.currentSituation.name), + label: workOrderDetails.currentSituation?.name, + textColor: AppColor.getRequestStatusTextColorByName(context, workOrderDetails.currentSituation?.name), + backgroundColor: AppColor.getRequestStatusColorByName(context, workOrderDetails.currentSituation?.name), ), 8.height, Text(serviceRequest.requestCode, style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), @@ -61,7 +61,7 @@ class WorkOrderDetailsPage extends StatelessWidget { style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( - '${context.translation.status}: ${workOrderDetails.currentSituation.name}', + '${context.translation.status}: ${workOrderDetails.currentSituation?.name}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( diff --git a/lib/views/widgets/requests/request_status.dart b/lib/views/widgets/requests/request_status.dart index 61d20740..52553270 100644 --- a/lib/views/widgets/requests/request_status.dart +++ b/lib/views/widgets/requests/request_status.dart @@ -15,11 +15,11 @@ class StatusLabel extends StatelessWidget { Widget build(BuildContext context) { if (id == 82) label = context.translation.highPriority; if (id == 81) label = context.translation.lowPriority; - if (label.toLowerCase() == 'In progress'.toLowerCase()) label = context.translation.inProgress; - if (label.toLowerCase() == 'Complete'.toLowerCase()) label = context.translation.completed; - if (label.toLowerCase() == 'Open'.toLowerCase()) label = context.translation.open; - if (label.toLowerCase() == 'Closed'.toLowerCase()) label = context.translation.closed; - if (label.toLowerCase() == 'Waiting for quotation'.toLowerCase()) label = context.translation.waitingForQuotation; + if (label?.toLowerCase() == 'In progress'.toLowerCase()) label = context.translation.inProgress; + if (label?.toLowerCase() == 'Complete'.toLowerCase()) label = context.translation.completed; + if (label?.toLowerCase() == 'Open'.toLowerCase()) label = context.translation.open; + if (label?.toLowerCase() == 'Closed'.toLowerCase()) label = context.translation.closed; + if (label?.toLowerCase() == 'Waiting for quotation'.toLowerCase()) label = context.translation.waitingForQuotation; return Container( padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 10), @@ -29,7 +29,7 @@ class StatusLabel extends StatelessWidget { borderRadius: BorderRadius.circular(50), ), ), - child: Text(label, style: AppTextStyles.overline.copyWith(color: textColor)), + child: Text(label ?? "", style: AppTextStyles.overline.copyWith(color: textColor)), ); }