From b67e6dea11bc6a75a236f24916074191ca8a7cbc Mon Sep 17 00:00:00 2001 From: WaseemAbbasi22 Date: Tue, 18 Feb 2025 11:34:23 +0300 Subject: [PATCH] Recurrent Work Order Complete ready to test --- .../providers/api/ppm_provider.dart | 17 ++ lib/l10n/app_ar.arb | 13 +- lib/l10n/app_en.arb | 10 +- .../plan_preventive_visit_model.dart | 265 +++++++++--------- lib/new_views/app_style/app_color.dart | 3 + .../my_request/my_requests_page.dart | 1 - .../pages/user/ppm/ppm_details_page.dart | 2 +- .../components/room_inspection_card.dart | 208 ++++++++++++-- .../components/room_tabs_widget.dart | 15 +- .../components/task_info_widget.dart | 2 +- .../pages/user/ppm/update_ppm/update_ppm.dart | 4 +- .../user/ppm/update_ppm/wo_info_form.dart | 219 +++++++++------ pubspec.lock | 8 + pubspec.yaml | 1 + 14 files changed, 520 insertions(+), 248 deletions(-) diff --git a/lib/controllers/providers/api/ppm_provider.dart b/lib/controllers/providers/api/ppm_provider.dart index 1dae3536..a1d1a172 100644 --- a/lib/controllers/providers/api/ppm_provider.dart +++ b/lib/controllers/providers/api/ppm_provider.dart @@ -133,6 +133,23 @@ class PpmProvider extends ChangeNotifier { // } } + Future updateRecurrentWo({required int status,required PlanPreventiveVisit planPreventiveVisit}) async { + isLoading = true; + Response response; + try { + response = await ApiManager.instance.post(URLs.updateRecurrentPlanUrl, body: planPreventiveVisit.toJson(status: status)); + stateCode = response.statusCode; + isLoading = false; + notifyListeners(); + return response.statusCode; + } catch (error) { + isLoading = false; + stateCode = -1; + notifyListeners(); + return -1; + } + } + Future updateVisitByEngineer(BuildContext context, {required User user, required Ppm ppm}) async { try { ppm.visitTimers?.add( diff --git a/lib/l10n/app_ar.arb b/lib/l10n/app_ar.arb index 0fa2b641..3ad1f2b4 100644 --- a/lib/l10n/app_ar.arb +++ b/lib/l10n/app_ar.arb @@ -530,13 +530,20 @@ "createdDate": "تاريخ الإنشاء", "employeeId": "رقم الموظف", "extensionNo": "رقم التمديد", - "checkIn": "تسجيل الدخول", "pmWo": "أمر العمل الوقائي", - "taskNo": "رقم المهمة", "assignEngineer": "تعيين مهندس", "scheduledDate": "التاريخ المجدول", "complete": "اكتمل", - "recurrentWo": "أمر العمل المتكرر" + "recurrentWo": "أمر العمل المتكرر", + "fail": "فشل", + "pass": "نجاح", + "pmPlanNo": "رقم خطة الصيانة الوقائية", + "nextPmDate": "تاريخ الصيانة الوقائية التالي", + "executionTimeFrame": "إطار زمني للتنفيذ", + "pmTestResult": "نتيجة اختبار الصيانة الوقائية", + "actualVisit": "الزيارة الفعلية", + "typeOfPm": "نوع الصيانة الوقائية" + } \ No newline at end of file diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 80cf85eb..e534870d 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -539,5 +539,13 @@ "complete": "Complete", "createdDate": "Created Date", "employeeId": "Employee ID", - "extensionNo": "Extension No" + "extensionNo": "Extension No", + "fail": "FAIL", + "pass": "PASS", + "pmPlanNo": "PM Plan No", + "nextPmDate": "Next PM Date", + "executionTimeFrame": "Execution Time Frame", + "pmTestResult": "PM Test Result", + "actualVisit": "Actual Visit", + "typeOfPm": "Type of PM" } \ No newline at end of file diff --git a/lib/models/plan_preventive_visit/plan_preventive_visit_model.dart b/lib/models/plan_preventive_visit/plan_preventive_visit_model.dart index 1f49787c..d02c0e5c 100644 --- a/lib/models/plan_preventive_visit/plan_preventive_visit_model.dart +++ b/lib/models/plan_preventive_visit/plan_preventive_visit_model.dart @@ -146,74 +146,89 @@ class PlanPreventiveVisit { if (json['preventiveVisitSuppliers'] != null) { preventiveVisitSuppliers = []; json['preventiveVisitSuppliers'].forEach((v) { - preventiveVisitSuppliers!.add(new PreventiveVisitSuppliers.fromJson(v)); + preventiveVisitSuppliers!.add( PreventiveVisitSuppliers.fromJson(v)); }); } } - Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['visitNo'] = this.visitNo; - if (this.asset != null) { - data['asset'] = this.asset!.toJson(); - } - data['planNo'] = this.planNo; - data['planName'] = this.planName; - data['nextPMDate'] = this.nextPMDate; - data['assetName'] = this.assetName; - data['model'] = this.model; - data['manufacturer'] = this.manufacturer; - data['supplierName'] = this.supplierName; - data['siteName'] = this.siteName; - data['buildingName'] = this.buildingName; - data['floorName'] = this.floorName; - data['departmentName'] = this.departmentName; - data['roomName'] = this.roomName; - data['fromDate'] = this.fromDate; - data['toDate'] = this.toDate; - if (this.assignedEmployee != null) { - data['assignedEmployee'] = this.assignedEmployee!.toJson(); - } - data['acutalDateOfVisit'] = this.acutalDateOfVisit; - if (this.typeOfService != null) { - data['typeOfService'] = this.typeOfService!.toJson(); - } - if (this.visitStatus != null) { - data['visitStatus'] = this.visitStatus!.toJson(); - } - data['travelingHours'] = this.travelingHours; - data['comments'] = this.comments; - data['executionTimeFrame'] = this.executionTimeFrame; - if (this.taskStatus != null) { - data['taskStatus'] = this.taskStatus!.toJson(); - } - if (this.deviceStatus != null) { - data['deviceStatus'] = this.deviceStatus!.toJson(); - } - data['assetAvailability'] = this.assetAvailability; - if (this.safety != null) { - data['safety'] = this.safety!.toJson(); - } - data['engSignature'] = this.engSignature; - data['nurseSignature'] = this.nurseSignature; - if (this.preventiveVisitAttachments != null) { - data['preventiveVisitAttachments'] = this.preventiveVisitAttachments!.map((v) => v.toJson()).toList(); - } - if (this.preventiveVisitCalibrations != null) { - data['preventiveVisitCalibrations'] = this.preventiveVisitCalibrations!.map((v) => v.toJson()).toList(); - } - if (this.preventiveVisitChecklists != null) { - data['preventiveVisitChecklists'] = this.preventiveVisitChecklists!.map((v) => v.toJson()).toList(); - } - if (this.preventiveVisitKits != null) { - data['preventiveVisitKits'] = this.preventiveVisitKits!.map((v) => v.toJson()).toList(); - } - if (this.preventiveVisitTimers != null) { - data['preventiveVisitTimers'] = this.preventiveVisitTimers!.map((v) => v.toJson()).toList(); - } - if (this.preventiveVisitSuppliers != null) { - data['preventiveVisitSuppliers'] = this.preventiveVisitSuppliers!.map((v) => v.toJson()).toList(); + Map toJson({required int status}) { + final Map data = {}; + data['id'] = id; + data['acutalDateOfVisit'] = acutalDateOfVisit; + data['statusValue'] = status; + data['typeOfServiceId'] = typeOfService?.id; + data['visitStatusValue'] = visitStatus?.value; + data['travelingHours'] = travelingHours; + data['comments'] = comments; + data['taskStatusId'] = taskStatus?.id; + data['deviceStatusId'] = deviceStatus?.id; + data['assetAvailabilityId'] = assetAvailability?.id; + data['safetyId'] = safety?.id; + data['engSignature'] = engSignature; + data['nurseSignature'] = nurseSignature; + // + // if (asset != null) { + // data['asset'] = asset!.toJson(); + // } + // data['visitNo'] = visitNo; + // data['planNo'] = planNo; + // data['planName'] = planName; + // data['nextPMDate'] = nextPMDate; + // data['assetName'] = assetName; + // data['model'] = model; + // data['manufacturer'] = manufacturer; + // data['supplierName'] = supplierName; + // data['siteName'] = siteName; + // data['buildingName'] = buildingName; + // data['floorName'] = floorName; + // data['departmentName'] = departmentName; + // data['roomName'] = roomName; + // data['fromDate'] = fromDate; + // data['toDate'] = toDate; + // if (assignedEmployee != null) { + // data['assignedEmployee'] = assignedEmployee!.toJson(); + // } + // data['acutalDateOfVisit'] = acutalDateOfVisit; + // if (typeOfService != null) { + // data['typeOfService'] = typeOfService!.toJson(); + // } + // if (visitStatus != null) { + // data['visitStatus'] = visitStatus!.toJson(); + // } + // data['travelingHours'] = travelingHours; + // data['comments'] = comments; + // data['executionTimeFrame'] = executionTimeFrame; + // if (taskStatus != null) { + // data['taskStatus'] = taskStatus!.toJson(); + // } + // if (deviceStatus != null) { + // data['deviceStatus'] = deviceStatus!.toJson(); + // } + // data['assetAvailability'] = assetAvailability; + // if (safety != null) { + // data['safety'] = safety!.toJson(); + // } + // data['engSignature'] = engSignature; + // data['nurseSignature'] = nurseSignature; + + + if (preventiveVisitAttachments != null) { + data['preventiveVisitAttachments'] = preventiveVisitAttachments!.map((v) => v.toJson()).toList(); + } + if (preventiveVisitCalibrations != null) { + data['preventiveVisitCalibrations'] = preventiveVisitCalibrations!.map((v) => v.toJson()).toList(); + } + if (preventiveVisitChecklists != null) { + data['preventiveVisitChecklists'] = preventiveVisitChecklists!.map((v) => v.toJson()).toList(); + } + if (preventiveVisitKits != null) { + data['preventiveVisitKits'] = preventiveVisitKits!.map((v) => v.toJson()).toList(); + } + if (preventiveVisitTimers != null) { + data['preventiveVisitTimers'] = preventiveVisitTimers!.map((v) => v.toJson()).toList(); + } + if (preventiveVisitSuppliers != null) { + data['preventiveVisitSuppliers'] = preventiveVisitSuppliers!.map((v) => v.toJson()).toList(); } return data; } @@ -687,9 +702,9 @@ class PreventiveVisitAttachments { } Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['attachmentName'] = this.attachmentName; + final Map data = {}; + data['id'] = id; + data['attachmentName'] = attachmentName; return data; } } @@ -703,24 +718,24 @@ class PreventiveVisitCalibrations { PreventiveVisitCalibrations.fromJson(Map json) { id = json['id']; - asset = json['asset'] != null ? new Asset.fromJson(json['asset']) : null; + asset = json['asset'] != null ? Asset.fromJson(json['asset']) : null; calibrationDateOfTesters = json['calibrationDateOfTesters']; } Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - if (this.asset != null) { - data['asset'] = this.asset!.toJson(); + final Map data = {}; + data['id'] = id; + if (asset != null) { + data['asset'] = asset!.toJson(); } - data['calibrationDateOfTesters'] = this.calibrationDateOfTesters; + data['calibrationDateOfTesters'] = calibrationDateOfTesters; return data; } } class PreventiveVisitSuppliers { int? id; - Supplier? supplier; + SupplierDetails? supplier; SuppPersons? suppPerson; String? startDateTime; String? endDateTime; @@ -730,25 +745,25 @@ class PreventiveVisitSuppliers { PreventiveVisitSuppliers.fromJson(Map json) { id = json['id']; - supplier = json['supplier'] != null ? new Supplier.fromJson(json['supplier']) : null; - suppPerson = json['suppPerson'] != null ? new SuppPersons.fromJson(json['suppPerson']) : null; + supplier = json['supplier'] != null ? SupplierDetails.fromJson(json['supplier']) : null; + suppPerson = json['suppPerson'] != null ? SuppPersons.fromJson(json['suppPerson']) : null; startDateTime = json['startDateTime']; endDateTime = json['endDateTime']; workingHours = json['workingHours']; } Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - if (this.supplier != null) { - data['supplier'] = this.supplier!.toJson(); + final Map data = {}; + data['id'] = id; + if (supplier != null) { + data['supplier'] = supplier!.toJson(); } - if (this.suppPerson != null) { - data['suppPerson'] = this.suppPerson!.toJson(); + if (suppPerson != null) { + data['suppPerson'] = suppPerson!.toJson(); } - data['startDateTime'] = this.startDateTime; - data['endDateTime'] = this.endDateTime; - data['workingHours'] = this.workingHours; + data['startDateTime'] = startDateTime; + data['endDateTime'] = endDateTime; + data['workingHours'] = workingHours; return data; } } @@ -848,37 +863,37 @@ class Supplier { } Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['suppliername'] = this.suppliername; - data['name'] = this.name; - data['website'] = this.website; - data['email'] = this.email; - data['code'] = this.code; - data['suppNo'] = this.suppNo; - data['suppStatusId'] = this.suppStatusId; - data['cityId'] = this.cityId; - data['person'] = this.person; - data['comment'] = this.comment; - data['zipcode'] = this.zipcode; - data['contact'] = this.contact; - if (this.telephones != null) { - data['telephones'] = this.telephones!.map((v) => v).toList(); - } - if (this.faxes != null) { - data['faxes'] = this.faxes!.map((v) => v).toList(); - } - if (this.addresses != null) { - data['addresses'] = this.addresses!.map((v) => v).toList(); - } - if (this.attachments != null) { - data['attachments'] = this.attachments!.map((v) => v).toList(); - } - if (this.suppPersons != null) { - data['suppPersons'] = this.suppPersons!.map((v) => v.toJson()).toList(); - } - if (this.suppTCodes != null) { - data['suppTCodes'] = this.suppTCodes!.map((v) => v).toList(); + final Map data = {}; + data['id'] = id; + data['suppliername'] = suppliername; + data['name'] = name; + data['website'] = website; + data['email'] = email; + data['code'] = code; + data['suppNo'] = suppNo; + data['suppStatusId'] = suppStatusId; + data['cityId'] = cityId; + data['person'] = person; + data['comment'] = comment; + data['zipcode'] = zipcode; + data['contact'] = contact; + if (telephones != null) { + data['telephones'] = telephones!.map((v) => v).toList(); + } + if (faxes != null) { + data['faxes'] = faxes!.map((v) => v).toList(); + } + if (addresses != null) { + data['addresses'] = addresses!.map((v) => v).toList(); + } + if (attachments != null) { + data['attachments'] = attachments!.map((v) => v).toList(); + } + if (suppPersons != null) { + data['suppPersons'] = suppPersons!.map((v) => v.toJson()).toList(); + } + if (suppTCodes != null) { + data['suppTCodes'] = suppTCodes!.map((v) => v).toList(); } return data; } @@ -922,7 +937,7 @@ class PreventiveVisitKits { int? id; PartCatalogItem? partCatalogItem; - PreventiveVisitKits({this.id, this.partCatalogItem}); + PreventiveVisitKits({this.id, partCatalogItem}); PreventiveVisitKits.fromJson(Map json) { id = json['id']; @@ -931,9 +946,9 @@ class PreventiveVisitKits { Map toJson() { final Map data = new Map(); - data['id'] = this.id; - if (this.partCatalogItem != null) { - data['partCatalogItem'] = this.partCatalogItem!.toJson(); + data['id'] = id; + if (partCatalogItem != null) { + data['partCatalogItem'] = partCatalogItem!.toJson(); } return data; } @@ -955,11 +970,11 @@ class PartCatalogItem { } Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['partName'] = this.partName; - data['partNumber'] = this.partNumber; - data['oracleCode'] = this.oracleCode; + final Map data = {}; + data['id'] = id; + data['partName'] = partName; + data['partNumber'] = partNumber; + data['oracleCode'] = oracleCode; return data; } } diff --git a/lib/new_views/app_style/app_color.dart b/lib/new_views/app_style/app_color.dart index 8ccc5700..571e4f06 100644 --- a/lib/new_views/app_style/app_color.dart +++ b/lib/new_views/app_style/app_color.dart @@ -46,6 +46,7 @@ class AppColor { static const Color white50 = Color(0xffECECEC); static const Color white60 = Color(0xffEFEFEF); static const Color white70 = Color(0xffF1F1F1); + static const Color white80 = Color(0xffF2F4FA); static const Color white936 = Color(0xff212936); //black @@ -55,6 +56,7 @@ class AppColor { static const Color black1E = Color(0xff1E1F20); //red + static const Color red20 = Color(0xfff2c5ca); static const Color red30 = Color(0xffF63939); static const Color red40 = Color(0xffFFDBDC); static const Color red50 = Color(0xffD02127); @@ -69,6 +71,7 @@ class AppColor { static const Color green60 = Color(0xff065E38); static const Color green70 = Color(0xff54C166); static const Color green15 = Color(0xff157D14); + static const Color green20 = Color(0xffcde6e1); //orange static const Color orange30 = Color(0xffFDE19B); diff --git a/lib/new_views/pages/land_page/my_request/my_requests_page.dart b/lib/new_views/pages/land_page/my_request/my_requests_page.dart index 0519bd03..fa744dbd 100644 --- a/lib/new_views/pages/land_page/my_request/my_requests_page.dart +++ b/lib/new_views/pages/land_page/my_request/my_requests_page.dart @@ -44,7 +44,6 @@ class _MyRequestsPageState extends State { WidgetsBinding.instance.addPostFrameCallback((_) { _provider!.getAllRequests(context); }); - } return Scaffold( diff --git a/lib/views/pages/user/ppm/ppm_details_page.dart b/lib/views/pages/user/ppm/ppm_details_page.dart index 8767104e..e649efb1 100644 --- a/lib/views/pages/user/ppm/ppm_details_page.dart +++ b/lib/views/pages/user/ppm/ppm_details_page.dart @@ -107,7 +107,7 @@ class _PpmDetailsPageState extends State { AppFilledButton( onPressed: () async { //TODO remove after testing.. - // await Navigator.of(context).push(MaterialPageRoute(builder: (_) => RecurrentWorkOrderView( request: widget.request))); + await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit, details: widget.request))); // setState(() {}); }, 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 f827aef5..0eccc069 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 @@ -1,6 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:test_sa/dashboard_latest/dashboard_view.dart'; +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'; @@ -8,6 +9,7 @@ import 'package:test_sa/models/enums/recurrent_task_inspection_data_type.dart'; import 'package:test_sa/models/ppm/recurrent_wo.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart'; +import 'package:toggle_switch/toggle_switch.dart'; class RoomInspectionCard extends StatefulWidget { final PlanRecurrentMedicalTaskRoomTabs? inspectionModel; @@ -19,8 +21,7 @@ class RoomInspectionCard extends StatefulWidget { } class _RoomInspectionCardState extends State { - late List inspectionValues; - + int selectedIndex =0; @override void initState() { super.initState(); @@ -60,7 +61,6 @@ class _RoomInspectionCardState extends State { ], ).toShadowContainer(context).paddingOnly(top: 12); } - Widget inspectionStatusRadioWidget({ required int index, required PlanRecurrentMedicalTaskRoomTabAttributes model, @@ -68,10 +68,9 @@ class _RoomInspectionCardState extends State { }) { bool status = model.attribute != null ? model.attributeValue == 'true' - ? true - : false + ? true + : false : false; - String statusString = status ? 'Pass' : 'Fail'; return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -80,29 +79,121 @@ class _RoomInspectionCardState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - model.attribute!.name!.bodyText2(context).custom(color: AppColor.white936, fontWeight: FontWeight.w500), - statusString.bodyText2(context).custom(color: AppColor.neutral120, fontWeight: FontWeight.w500), + SizedBox( + width: 220.toScreenWidth, + child: Text( + model.attribute!.name!, + overflow: TextOverflow.ellipsis, + maxLines: 1, // Ensures text is limited to one line before ellipsis + ), + ), + (status ? 'Pass' : 'Fail').bodyText2(context).custom(color: AppColor.neutral120, fontWeight: FontWeight.w500), ], ), - SizedBox( - height: 24.toScreenHeight, - width: 41.toScreenWidth, - child: CupertinoSwitch( - thumbColor: status ? AppColor.green50 : AppColor.red30, - activeColor: AppColor.green30, - trackColor: AppColor.red80, - value: status, - onChanged: (state) { - setState(() { - model.attributeValue = state; - status = state; - }); - }, + GestureDetector( + onTap: () { + setState(() { + status = !status; + model.attributeValue = status.toString(); + }); + }, + child: Container( + width: 99.toScreenWidth, + height: 30.toScreenHeight, + padding: EdgeInsetsDirectional.all(4.toScreenHeight), + decoration: BoxDecoration( + color:AppColor.white80, + borderRadius: BorderRadius.circular(5), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + buildToggleOption( + label: "PASS", + isActive: status, + activeColor: AppColor.green20, + inactiveColor: Colors.transparent, + textColor: status ? AppColor.green50 :AppColor.black20, + ), + buildToggleOption( + label: "FAIL", + isActive: !status, + activeColor: AppColor.red20, + inactiveColor: Colors.transparent, + textColor: status ? AppColor.black20 : AppColor.red30, + ), + ], + ), ), - ) + ), ], ).paddingOnly(bottom: 12); } + Widget buildToggleOption({ + required String label, + required bool isActive, + required Color activeColor, + required Color inactiveColor, + required Color textColor, + }) { + return Container( + width: 44.toScreenWidth, + height: 22.toScreenHeight, + alignment: Alignment.center, + decoration: BoxDecoration( + color: isActive ? activeColor : inactiveColor, + borderRadius: BorderRadius.circular(3), + ), + child: label.bodyText2(context).custom(color: textColor), + ); + } + + + // Widget inspectionStatusRadioWidget({ + // required int index, + // required PlanRecurrentMedicalTaskRoomTabAttributes model, + // required BuildContext context, + // }) { + // + // bool status = model.attribute != null + // ? model.attributeValue == 'true' + // ? true + // : false + // : false; + // String statusString = status ? 'Pass' : 'Fail'; + // List state = ['PASS','FAIL']; + // + // return Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // model.attribute!.name!.bodyText2(context).custom(color: AppColor.white936, fontWeight: FontWeight.w500), + // statusString.bodyText2(context).custom(color: AppColor.neutral120, fontWeight: FontWeight.w500), + // ], + // ), + // + // SizedBox( + // height: 24.toScreenHeight, + // width: 41.toScreenWidth, + // child: CupertinoSwitch( + // thumbColor: status ? AppColor.green50 : AppColor.red30, + // activeColor: AppColor.green30, + // trackColor: AppColor.red80, + // value: status, + // onChanged: (state) { + // setState(() { + // model.attributeValue = state.toString(); + // status = state; + // }); + // }, + // ), + // ) + // ], + // ).paddingOnly(bottom: 12); + // } Widget inspectionStatusNumberWidget({ required int index, @@ -113,7 +204,7 @@ class _RoomInspectionCardState extends State { borderRadius: BorderRadius.circular(4), // Optional: Slight rounding borderSide: const BorderSide( color: AppColor.white70, // Border color - width: 1, // 1px border + width: 0, // 1px border ), ); return Row( @@ -128,9 +219,9 @@ class _RoomInspectionCardState extends State { contentPadding: EdgeInsets.symmetric(horizontal: 5.toScreenWidth), filled: true, fillColor: AppColor.neutral100, - constraints: const BoxConstraints( - maxHeight: 30, - maxWidth: 50, + constraints: BoxConstraints( + maxWidth: 99.toScreenWidth, + maxHeight: 30.toScreenHeight, ), border: border, enabledBorder: border, @@ -144,3 +235,66 @@ class _RoomInspectionCardState extends State { ).paddingOnly(bottom: 12); } } + + + + + +// // I need it here .... +// Container( +// padding: EdgeInsets.all(6.toScreenHeight), +// // height: 57.toScreenHeight, +// // width: 120.toScreenWidth, +// decoration: BoxDecoration( +// color: context.isDark ? AppColor.neutral50 : AppColor.white80, +// borderRadius: BorderRadius.circular(10), +// ), +// child: Row( +// mainAxisSize: MainAxisSize.min, +// // mainAxisAlignment: MainAxisAlignment.spaceAround, +// children: state.asMap().entries.map((task) { +// final int index = task.key; +// final String label = task.value; +// return GestureDetector( +// onTap: () { +// setState(() { +// selectedIndex = index; +// }); +// }, +// child: Container( +// // margin: EdgeInsets.only(right: 8.toScreenWidth), +// height: 49.toScreenHeight, +// padding: EdgeInsets.symmetric( +// // vertical: 20.toScreenHeight, +// horizontal: 15.toScreenWidth, +// ), +// alignment: Alignment.center, +// decoration: BoxDecoration( +// color: selectedIndex == index ? (context.isDark ? AppColor.neutral60 : status ? AppColor.green20 : AppColor.red20) : Colors.transparent, +// // color: status ? AppColor.green20 : AppColor.red20, +// borderRadius: BorderRadius.circular(7), +// ), +// child: label.bodyText2(context).custom( +// // color: status?AppColor.green50:AppColor.red30, +// color: selectedIndex == index ? (context.isDark ? AppColor.neutral60 : status ? AppColor.green50 : AppColor.red30) : AppColor.black20, +// ), +// ), +// ); +// }).toList(), +// ), +// ), +// // ToggleSwitch( +// // minWidth: 41.toScreenWidth, +// // minHeight: 50.toScreenHeight, +// // fontSize: 12.0, +// // initialLabelIndex: 1, +// // activeBgColor: [Colors.green], +// // activeFgColor: Colors.white, +// // inactiveBgColor: Colors.grey, +// // inactiveFgColor: Colors.grey[900], +// // totalSwitches: 2, +// // labels: ['PASS', 'FAIL'], +// // onToggle: (index) { +// // print('switched to: $index'); +// // }, +// // ), \ No newline at end of file diff --git a/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/room_tabs_widget.dart b/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/room_tabs_widget.dart index decd93e1..1aa6fa01 100644 --- a/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/room_tabs_widget.dart +++ b/lib/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/room_tabs_widget.dart @@ -10,7 +10,8 @@ import 'package:test_sa/views/widgets/loaders/app_loading.dart'; class RoomTabsWidget extends StatefulWidget { final RecurrentWoData? model; - const RoomTabsWidget({Key? key,required this.model}) : super(key: key); + + const RoomTabsWidget({Key? key, required this.model}) : super(key: key); @override State createState() => _RoomTabsWidgetState(); @@ -36,9 +37,9 @@ class _RoomTabsWidgetState extends State { child: ListView( scrollDirection: Axis.horizontal, // mainAxisAlignment: MainAxisAlignment.spaceAround, - children: widget.model!.planRecurrentMedicalTaskRooms!.asMap().entries.map((entry) { - final int index = entry.key; - final String label = entry.value.room!.roomId!; + children: widget.model!.planRecurrentMedicalTaskRooms!.asMap().entries.map((task) { + final int index = task.key; + final String label = task.value.room!.roomId!; return GestureDetector( onTap: () { setState(() { @@ -61,11 +62,11 @@ class _RoomTabsWidgetState extends State { ), alignment: Alignment.center, decoration: BoxDecoration( - color: selectedIndex == index ? (context.isDark ? AppColor.neutral60 : AppColor.neutral110) : Colors.transparent, + color: selectedIndex == index ? (context.isDark ? AppColor.neutral60 : AppColor.neutral110) : Colors.transparent, borderRadius: BorderRadius.circular(7), ), child: label.bodyText(context).custom( - color:AppColor.white936, + color: AppColor.white936, ), ), ); @@ -73,7 +74,7 @@ class _RoomTabsWidgetState extends State { ), ), isLoading - ? SizedBox(height: 120.toScreenHeight, child: const ALoading().center) + ? const ALoading().paddingOnly(top: 150) : ListView( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), 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 bb52866c..46cd88e4 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 @@ -76,7 +76,7 @@ class RecurrentTaskInfoWidget extends StatelessWidget { label: context.translation.timer, timer: snapshot.recurrentWoData?.recurrentWoTimerModel, width: double.infinity, - enabled: snapshot.recurrentWoData?.recurrentWoTimerModel?.endAt == null, + // enabled: snapshot.recurrentWoData?.recurrentWoTimerModel?.endAt == null, decoration: BoxDecoration( color: AppColor.neutral100, borderRadius: BorderRadius.circular(10), diff --git a/lib/views/pages/user/ppm/update_ppm/update_ppm.dart b/lib/views/pages/user/ppm/update_ppm/update_ppm.dart index fc534325..8db64344 100644 --- a/lib/views/pages/user/ppm/update_ppm/update_ppm.dart +++ b/lib/views/pages/user/ppm/update_ppm/update_ppm.dart @@ -55,7 +55,7 @@ class _UpdatePpmState extends State with SingleTickerProviderStateMix void initState() { _ppm = widget.ppm; _planPreventiveVisit = widget.planPreventiveVisit; - _tabController = TabController(length: 4, vsync: this); + _tabController = TabController(length: 3, vsync: this); super.initState(); } @@ -122,7 +122,7 @@ class _UpdatePpmState extends State with SingleTickerProviderStateMix physics: const NeverScrollableScrollPhysics(), controller: _tabController, children: [ - PpmExternalDetailsForm(models: []), + // PpmExternalDetailsForm(models: []), PpmCalibrationToolsForm(models: _planPreventiveVisit.preventiveVisitCalibrations), PpmPMKitsForm(models: _planPreventiveVisit.preventiveVisitKits,assetId: _planPreventiveVisit.asset?.id), diff --git a/lib/views/pages/user/ppm/update_ppm/wo_info_form.dart b/lib/views/pages/user/ppm/update_ppm/wo_info_form.dart index 3ede281a..5da2df4e 100644 --- a/lib/views/pages/user/ppm/update_ppm/wo_info_form.dart +++ b/lib/views/pages/user/ppm/update_ppm/wo_info_form.dart @@ -2,14 +2,18 @@ import 'package:flutter/material.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/models/plan_preventive_visit/plan_preventive_visit_model.dart'; import 'package:test_sa/models/service_request/supplier_details.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/providers/loading_list_notifier.dart'; import 'package:test_sa/providers/ppm_asset_availability_provider.dart'; import 'package:test_sa/providers/ppm_electrical_safety_provider.dart'; +import 'package:test_sa/providers/ppm_service_provider.dart'; import 'package:test_sa/providers/ppm_task_status_provider.dart'; import 'package:test_sa/providers/work_order/vendor_provider.dart'; +import 'package:test_sa/views/widgets/requests/request_status.dart'; import '../../../../../models/lookup.dart'; import '../../../../../new_views/common_widgets/app_text_form_field.dart'; @@ -32,6 +36,17 @@ class _WoInfoFormState extends State { SupplierDetails? initialSupplier; SuppPersons? _suppPerson; + @override + void initState() { +// TODO need to use model attributes directly no need to assign to new variable. when confirm from backend we need one or multiple suppliers. + if (widget.planPreventiveVisit.preventiveVisitSuppliers != null && widget.planPreventiveVisit.preventiveVisitSuppliers!.isNotEmpty) { + initialSupplier = SupplierDetails.fromJson(widget.planPreventiveVisit.preventiveVisitSuppliers?[0].supplier?.toJson()); + _suppPerson = SuppPersons.fromJson(widget.planPreventiveVisit.preventiveVisitSuppliers?[0].suppPerson?.toJson()); + } + + super.initState(); + } + @override Widget build(BuildContext context) { // widget.planPreventiveVisit ??= []; @@ -45,65 +60,62 @@ class _WoInfoFormState extends State { return ListView( padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16), children: [ - SingleItemDropDownMenu( - context: context, - initialValue: - widget.planPreventiveVisit.visitStatus?.id == null ? null : Lookup(name: widget.planPreventiveVisit.visitStatus?.name ?? "", id: widget.planPreventiveVisit.visitStatus?.id?.toInt()), - title: context.translation.ppmVisit, - onSelect: (value) { - if (value?.value == 4) { - "Status cannot be change to ${value?.name}.".addTranslation.showToast; - setState(() {}); - return; - } - - if (value != null) { - widget.planPreventiveVisit.visitStatus?.name = value.name; - widget.planPreventiveVisit.visitStatus?.id = value.id; - } - }, - ), - 8.height, - if (totalWorkingHours > 0.0) ...[ - Container( - height: 56.toScreenHeight, - padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), - alignment: Alignment.centerLeft, - decoration: BoxDecoration( - color: context.isDark ? AppColor.neutral40 : AppColor.background(context), - borderRadius: BorderRadius.circular(10), - boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (widget.planPreventiveVisit.visitStatus != null) + StatusLabel( + label: widget.planPreventiveVisit.visitStatus?.name, + textColor: AppColor.getRequestStatusTextColorByName(context, widget.planPreventiveVisit.visitStatus?.name), + backgroundColor: AppColor.getRequestStatusColorByName(context, widget.planPreventiveVisit.visitStatus?.name), + ), + 8.height, + widget.planPreventiveVisit.planName!.bodyText(context).custom(color: AppColor.black10), + 2.height, + '${context.translation.pmPlanNo}: ${widget.planPreventiveVisit.planNo}'.bodyText2(context).custom(color: AppColor.neutral120), + '${context.translation.nextPmDate}: ${widget.planPreventiveVisit.nextPMDate?.toMonthYearFormat}'.bodyText2(context).custom(color: AppColor.neutral120), + '${context.translation.assignEngineer}: ${widget.planPreventiveVisit.assignedEmployee?.userName ?? ""}'.bodyText2(context).custom(color: AppColor.neutral120), + '${context.translation.executionTimeFrame}: ${widget.planPreventiveVisit.executionTimeFrame ?? ""}'.bodyText2(context).custom(color: AppColor.neutral120), + ], + ).toShadowContainer(context), + 12.height, + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - "Total Working Time", - style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500), - ), - Text( - " ${formatDuration(totalWorkingHours.round())}", - style: Theme.of(context).textTheme.bodyMedium, - ), + widget.planPreventiveVisit.assetName!.bodyText(context).custom(color: AppColor.black10), + "info_icon".toSvgAsset(height: 17, width: 17), ], ), - ), - 8.height, - ], - AppTimer( - label: context.translation.timer, - timer: widget.planPreventiveVisit.tbsTimer, - enabled: widget.planPreventiveVisit.tbsTimer?.endAt == null, - timerProgress: (isRunning) { - print("timerProgress:$isRunning"); - }, - onChange: (timer) async { - widget.planPreventiveVisit.tbsTimer = timer; - return true; - }, - ), - 8.height, + 2.height, + '${context.translation.assetNo}: ${widget.planPreventiveVisit.asset?.assetNumber}'.bodyText2(context).custom(color: AppColor.neutral120), + '${context.translation.model}: ${widget.planPreventiveVisit.model}'.bodyText2(context).custom(color: AppColor.neutral120), + ], + ).toShadowContainer(context), + + // SingleItemDropDownMenu( + // context: context, + // initialValue: + // widget.planPreventiveVisit.visitStatus?.id == null ? null : Lookup(name: widget.planPreventiveVisit.visitStatus?.name ?? "", id: widget.planPreventiveVisit.visitStatus?.id?.toInt()), + // title: context.translation.ppmVisit, + // onSelect: (value) { + // if (value?.value == 4) { + // "Status cannot be change to ${value?.name}.".addTranslation.showToast; + // setState(() {}); + // return; + // } + // + // if (value != null) { + // widget.planPreventiveVisit.visitStatus?.name = value.name; + // widget.planPreventiveVisit.visitStatus?.id = value.id; + // } + // }, + // ), + // SingleItemDropDownMenu( // context: context, // initialValue: widget.planPreventiveVisit.deviceStatusId == null ? null : Lookup(name: widget.model.deviceStatusName ?? "", id: widget.model.deviceStatusId?.toInt()), @@ -141,6 +153,7 @@ class _WoInfoFormState extends State { } }, ), + 8.height, SingleItemDropDownMenu( context: context, @@ -154,27 +167,69 @@ class _WoInfoFormState extends State { }, ), 8.height, - // SingleItemDropDownMenu( - // context: context, - // initialValue: widget.model.typeOfServiceId == null ? null : Lookup(name: widget.model.typeOfServiceName ?? "", id: widget.model.typeOfServiceId?.toInt()), - // title: context.translation.serviceType, - // onSelect: (value) { - // if (value != null) { - // widget.model.typeOfServiceId = value.id; - // widget.model.typeOfServiceName = value.name; - // - // widget.model.supplierId = null; - // widget.model.supplierName = null; - // initialSupplier = null; - // _suppPerson = null; - // widget.model.suppPersonId = null; - // widget.model.suppPerson = null; - // - // setState(() {}); - // } - // }, - // ), + SingleItemDropDownMenu( + context: context, + initialValue: + widget.planPreventiveVisit.typeOfService == null ? null : Lookup(name: widget.planPreventiveVisit.typeOfService?.name ?? "", id: widget.planPreventiveVisit.typeOfService?.id?.toInt()), + title: context.translation.serviceType, + onSelect: (value) { + if (value != null) { + widget.planPreventiveVisit.typeOfService?.id = value.id; + widget.planPreventiveVisit.typeOfService?.name = value.name; + //TODO check this why make all values null.. + + // widget.planPreventiveVisit?.preventiveVisitSuppliers?. = null; + // widget.model.supplierName = null; + // initialSupplier = null; + // _suppPerson = null; + // widget.model.suppPersonId = null; + // widget.model.suppPerson = null; + + setState(() {}); + } + }, + ), + 8.height, + AppTimer( + label: context.translation.timer, + timer: widget.planPreventiveVisit.tbsTimer, + enabled: widget.planPreventiveVisit.tbsTimer?.endAt == null, + timerProgress: (isRunning) { + print("timerProgress:$isRunning"); + }, + onChange: (timer) async { + widget.planPreventiveVisit.tbsTimer = timer; + return true; + }, + ), 8.height, + if (totalWorkingHours > 0.0) ...[ + Container( + height: 56.toScreenHeight, + padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), + alignment: Alignment.centerLeft, + decoration: BoxDecoration( + color: context.isDark ? AppColor.neutral40 : AppColor.background(context), + borderRadius: BorderRadius.circular(10), + boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Total Working Time", + style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500), + ), + Text( + " ${formatDuration(totalWorkingHours.round())}", + style: Theme.of(context).textTheme.bodyMedium, + ), + ], + ), + ), + 8.height, + ], if (widget.planPreventiveVisit.typeOfService?.id == 66) ...[ SingleItemDropDownMenu( context: context, @@ -183,6 +238,9 @@ class _WoInfoFormState extends State { showAsBottomSheet: true, onSelect: (supplier) { if (supplier != null) { + initialSupplier = supplier; + print('supplier dtails is ${supplier.toJson()}'); + // widget.planPreventiveVisit.preventiveVisitSuppliers?[0].supplier=supplier; // widget.model.supplierId = supplier.id; // widget.model.supplierName = supplier.name; // initialSupplier = supplier; @@ -213,15 +271,16 @@ class _WoInfoFormState extends State { 8.height, // AppTextFormField( // labelText: "Telephone", - // initialValue: (widget.planPreventiveVisit.telephone ?? "").toString(), + // initialValue: (initialSupplier?.telephones?[0].telephone ?? "").toString(), // textAlign: TextAlign.center, // style: Theme.of(context).textTheme.titleMedium, // textInputType: TextInputType.number, // onChange: (value) { - // widget.model.telephone = value; + // initialSupplier?.telephones?[0].telephone = value; // }, // ), - // 8.height, + 8.height, + //TODO implement this after feedback from backend. // AppTimer( // label: "External Supplier Timer", // timer: widget.model.externalEngineerTimer, @@ -234,7 +293,7 @@ class _WoInfoFormState extends State { // return true; // }, // ), - 8.height, + // 8.height, ], ADatePicker( label: context.translation.actualVisitDate, diff --git a/pubspec.lock b/pubspec.lock index 7e051fcd..389acf4a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1562,6 +1562,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.9.4" + toggle_switch: + dependency: "direct main" + description: + name: toggle_switch + sha256: dca04512d7c23ed320d6c5ede1211a404f177d54d353bf785b07d15546a86ce5 + url: "https://pub.dev" + source: hosted + version: "2.3.0" typed_data: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9d81d41e..0d605c47 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -93,6 +93,7 @@ dependencies: wifi_iot: ^0.3.19+1 just_audio: ^0.9.30 safe_device: ^1.1.9 + toggle_switch: ^2.3.0 local_auth_darwin: any dev_dependencies: