From 015b73b634b29c7927b31e4092a47d9a24d20e2b Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 17 Apr 2025 15:07:21 +0300 Subject: [PATCH] ponit 87 fixed. --- .../providers/api/all_requests_provider.dart | 10 ++++++++++ lib/models/new_models/gas_refill_model.dart | 2 +- lib/models/ppm/recurrent_wo.dart | 2 +- .../pages/user/gas_refill/gas_refill_form.dart | 5 ++++- .../components/room_inspection_card.dart | 15 ++------------- .../recurrent_wo/components/task_info_widget.dart | 4 ++-- .../widgets/status/assistant_employee_menu.dart | 5 +++-- .../service_report_assistant_employee_menu.dart | 1 + 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/lib/controllers/providers/api/all_requests_provider.dart b/lib/controllers/providers/api/all_requests_provider.dart index f4f96064..afaf7b54 100644 --- a/lib/controllers/providers/api/all_requests_provider.dart +++ b/lib/controllers/providers/api/all_requests_provider.dart @@ -201,6 +201,16 @@ class AllRequestsProvider extends ChangeNotifier { stateCode = response.statusCode; if (response.statusCode >= 200 && response.statusCode < 300) { recurrentWoData = RecurrentWoData.fromJson(json.decode(response.body)["data"]); + recurrentWoData?.planRecurrentMedicalTaskRooms?.forEach((element){ + element.planRecurrentMedicalTaskRoomTabs?.forEach((tabs){ + tabs.planRecurrentMedicalTaskRoomTabAttributes?.forEach((attribute){ + print(attribute.attribute?.name); + if(attribute.attribute?.type=="bool" && attribute.attributeValue ==null) { + attribute.attributeValue = "true"; + } + }); + }); + }); notifyListeners(); } isLoading = false; diff --git a/lib/models/new_models/gas_refill_model.dart b/lib/models/new_models/gas_refill_model.dart index 0750dd33..bfd69bb2 100644 --- a/lib/models/new_models/gas_refill_model.dart +++ b/lib/models/new_models/gas_refill_model.dart @@ -72,7 +72,7 @@ class GasRefillModel { List? gasRefillDetails; // Now nullable Uint8List? localNurseSignature; // Now nullable Uint8List? localEngineerSignature; // Now nullable - TimerModel? timer; + TimerModel? timer = TimerModel(); //TODO need to check when api provided.. List? timerModelList = []; diff --git a/lib/models/ppm/recurrent_wo.dart b/lib/models/ppm/recurrent_wo.dart index c8161054..e5d27c10 100644 --- a/lib/models/ppm/recurrent_wo.dart +++ b/lib/models/ppm/recurrent_wo.dart @@ -294,7 +294,7 @@ class PlanRecurrentMedicalTaskRoomTabAttributes { PlanRecurrentMedicalTaskRoomTabAttributes.fromJson(Map json) { id = json['id']; attribute = json['attribute'] != null ? Attribute.fromJson(json['attribute']) : null; - attributeValue = json['attributeValue'] ?? (json['attribute']['type'] == 'bool' ? (json['attributeValue']?.toString() == 'true') : json['attributeValue']); + attributeValue = json['attributeValue']; } Map toJson() { diff --git a/lib/views/pages/user/gas_refill/gas_refill_form.dart b/lib/views/pages/user/gas_refill/gas_refill_form.dart index a03281e2..b7c89455 100644 --- a/lib/views/pages/user/gas_refill/gas_refill_form.dart +++ b/lib/views/pages/user/gas_refill/gas_refill_form.dart @@ -203,6 +203,9 @@ class _GasRefillFormState extends State { // setState(() {}); // }); } + double totalWorkingHours = + _formModel.gasRefillTimers?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDate!).difference(DateTime.parse(item.startDate!)).inSeconds) ?? 0; + return Scaffold( appBar: DefaultAppBar(title: context.translation.gasRefill), key: _scaffoldKey, @@ -263,7 +266,7 @@ class _GasRefillFormState extends State { // : context.translation.onlyNumbers, // ), // 8.height, - _timerWidget(context, _formModel.workingHours ?? 0), + _timerWidget(context, totalWorkingHours), 8.height, // SingleItemDropDownMenu( // context: context, diff --git a/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/room_inspection_card.dart b/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/room_inspection_card.dart index a4161ce5..511ae268 100644 --- a/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/room_inspection_card.dart +++ b/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/room_inspection_card.dart @@ -52,19 +52,8 @@ class _RoomInspectionCardState extends State { ).toShadowContainer(context).paddingOnly(top: 12); } - Widget inspectionStatusRadioWidget({ - required int index, - required PlanRecurrentMedicalTaskRoomTabAttributes model, - required BuildContext context, - }) { - - bool status = (model.attribute == null || model.attributeValue == null) - ? true - : model.attribute != null - ? model.attributeValue == 'true' - ? true - : false - : false; + Widget inspectionStatusRadioWidget({required int index, required PlanRecurrentMedicalTaskRoomTabAttributes model, required BuildContext context}) { + bool status = (model.attribute == null || model.attributeValue == null) ? true : (model.attribute != null ? (model.attributeValue == 'true' ? true : false) : false); return Row( diff --git a/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/task_info_widget.dart b/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/task_info_widget.dart index 26f5ba20..a7d81af4 100644 --- a/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/task_info_widget.dart +++ b/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/task_info_widget.dart @@ -64,8 +64,8 @@ class RecurrentTaskInfoWidget extends StatelessWidget { // ], ).toShadowContainer(context, padding: 12) : Column( - children: [_timerWidget(context, model!.totalWorkingHours!).toShadowContainer(context, padding: 12), 8.height, _commentWidget(context: context, model: model)], - ), + children: [_timerWidget(context, model!.totalWorkingHours!), 8.height, _commentWidget(context: context, model: model)], + ).toShadowContainer(context, padding: 12), ], ); } diff --git a/lib/views/widgets/status/assistant_employee_menu.dart b/lib/views/widgets/status/assistant_employee_menu.dart index 259d38cc..01d66f8a 100644 --- a/lib/views/widgets/status/assistant_employee_menu.dart +++ b/lib/views/widgets/status/assistant_employee_menu.dart @@ -18,8 +18,9 @@ class AssistantEmployeeMenu extends StatefulWidget { final String? title; // Now nullable final bool enable; final bool showAsBottomSheet; + final bool hideShadow; - AssistantEmployeeMenu({Key? key, required this.statuses, this.title, this.showAsBottomSheet = false, required this.onSelect, this.initialStatus, this.backgroundColor, this.enable = true}) + AssistantEmployeeMenu({Key? key, required this.statuses, this.title, this.showAsBottomSheet = false,this.hideShadow = false, required this.onSelect, this.initialStatus, this.backgroundColor, this.enable = true}) : super(key: key); @override @@ -74,7 +75,7 @@ class _SingleAssistantEmployeeMenuState extends State { decoration: BoxDecoration( color: widget.backgroundColor ?? (context.isDark ? AppColor.neutral50 : AppColor.neutral120), borderRadius: BorderRadius.circular(10), - boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], + boxShadow: widget.hideShadow ? null : [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], ), child: Stack( alignment: Alignment.center, diff --git a/lib/views/widgets/status/report/service_report_assistant_employee_menu.dart b/lib/views/widgets/status/report/service_report_assistant_employee_menu.dart index 533faace..636ffe3a 100644 --- a/lib/views/widgets/status/report/service_report_assistant_employee_menu.dart +++ b/lib/views/widgets/status/report/service_report_assistant_employee_menu.dart @@ -31,6 +31,7 @@ class ServiceReportAssistantEmployeeMenu extends StatelessWidget { initialStatus: initialValue, title: title, showAsBottomSheet: true, + hideShadow: true, statuses: menuProvider.assistantEmployees ?? [], backgroundColor: backgroundColor, // Provide an empty list if null