diff --git a/lib/controllers/api_routes/urls.dart b/lib/controllers/api_routes/urls.dart index ad5c3307..fd320f8f 100644 --- a/lib/controllers/api_routes/urls.dart +++ b/lib/controllers/api_routes/urls.dart @@ -1,7 +1,7 @@ class URLs { URLs._(); - static const String appReleaseBuildNumber = "21"; + static const String appReleaseBuildNumber = "22"; // static const host1 = "https://atomsm.hmg.com"; // production url // static const host1 = "https://atomsmdev.hmg.com"; // local DEV url diff --git a/lib/controllers/providers/api/ppm_provider.dart b/lib/controllers/providers/api/ppm_provider.dart index 900f88bc..81a7e066 100644 --- a/lib/controllers/providers/api/ppm_provider.dart +++ b/lib/controllers/providers/api/ppm_provider.dart @@ -8,6 +8,7 @@ import 'package:http/http.dart'; import 'package:test_sa/controllers/api_routes/api_manager.dart'; import 'package:test_sa/controllers/api_routes/urls.dart'; import 'package:test_sa/extensions/context_extension.dart'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart'; import 'package:test_sa/models/ppm/ppm.dart'; import 'package:test_sa/models/ppm/ppm_search.dart'; @@ -38,11 +39,11 @@ class PpmProvider extends ChangeNotifier { notifyListeners(); } - List _ppmPlanAttachments = []; + List _ppmPlanAttachments = []; - List get ppmPlanAttachments => _ppmPlanAttachments; + List get ppmPlanAttachments => _ppmPlanAttachments; - set ppmPlanAttachments(List value) { + set ppmPlanAttachments(List value) { _ppmPlanAttachments = value; notifyListeners(); } diff --git a/lib/dashboard_latest/dashboard_view.dart b/lib/dashboard_latest/dashboard_view.dart index 01ef9b67..149a9e24 100644 --- a/lib/dashboard_latest/dashboard_view.dart +++ b/lib/dashboard_latest/dashboard_view.dart @@ -147,7 +147,7 @@ class _DashboardViewState extends State { height: 100.toScreenHeight, decoration: BoxDecoration( shape: BoxShape.circle, - color: AppColor.white10, + color: AppColor.background(context), border: Border.all(color: AppColor.primary10.withOpacity(0.5), width: 2), ), child: Consumer(builder: (context, userProvider, child) { @@ -159,7 +159,7 @@ class _DashboardViewState extends State { 8.height, Text( ("${context.translation.checkIn}\n${userProvider.swipeTransactionModel.swipeTime != null ? SwipeGeneralUtils.instance.formatTimeOnly(userProvider.swipeTransactionModel.swipeTime!) : '--:--'}"), - style: AppTextStyles.bodyText2.copyWith(color: AppColor.white936, fontWeight: FontWeight.w500, fontFamily: "Poppins"), + style: AppTextStyles.bodyText2.copyWith(color: AppColor.textColor(context), fontWeight: FontWeight.w500, fontFamily: "Poppins"), ), ], ); diff --git a/lib/dashboard_latest/widgets/progress_fragment.dart b/lib/dashboard_latest/widgets/progress_fragment.dart index b7329fd3..f6533c91 100644 --- a/lib/dashboard_latest/widgets/progress_fragment.dart +++ b/lib/dashboard_latest/widgets/progress_fragment.dart @@ -248,7 +248,7 @@ class ProgressFragment extends StatelessWidget { showChartValuesOutside: false, decimalPlaces: 1, ), - ).toShimmer(isShow: snapshot.isAllCountLoading, radius: 250).paddingAll(0).toShadowContainer(context), + ).toShimmer(isShow: snapshot.isAllCountLoading, radius: 250,context: context).paddingAll(0).toShadowContainer(context), ], ), ), diff --git a/lib/dashboard_latest/widgets/requests_fragment.dart b/lib/dashboard_latest/widgets/requests_fragment.dart index f5cbdd1b..ba45b3f5 100644 --- a/lib/dashboard_latest/widgets/requests_fragment.dart +++ b/lib/dashboard_latest/widgets/requests_fragment.dart @@ -60,7 +60,7 @@ class RequestsFragment extends StatelessWidget { CustomBadge( value: isLoading ? 0 : value, child: Container( - child: (icon ?? "").toSvgAsset(height: 26, width: 26, color: iconColor).toShimmer(isShow: isLoading), + child: (icon ?? "").toSvgAsset(height: 26, width: 26, color: iconColor).toShimmer(isShow: isLoading,context: context), ).toShadowCircleContainer(context, padding: 17), ), 10.height, @@ -70,7 +70,7 @@ class RequestsFragment extends StatelessWidget { style: AppTextStyles.tinyFont.copyWith( color: context.isDark ? AppColor.neutral30 : AppColor.black20, ), - ).toShimmer(isShow: isLoading), + ).toShimmer(isShow: isLoading,context: context), ], ), ); diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index bea487f4..0bb4ec12 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -79,14 +79,15 @@ extension WidgetExtensions on Widget { : this; } - Widget toShimmer({bool isShow = true, double radius = 20}) => isShow + Widget toShimmer({bool isShow = true, double radius = 20,required BuildContext context}) => isShow ? Shimmer.fromColors( - baseColor: const Color(0xffe8eff0), - highlightColor: Colors.white, + // baseColor: const Color(0xffe8eff0), + baseColor: Theme.of(context).scaffoldBackgroundColor, + highlightColor: AppColor.background(context), child: ClipRRect( borderRadius: BorderRadius.circular(radius), child: Container( - color: Colors.white, + color: AppColor.background(context), child: this, ), ), @@ -97,20 +98,21 @@ extension WidgetExtensions on Widget { ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const SizedBox(width: 250, height: 24).toShimmer(isShow: isShow), + const SizedBox(width: 250, height: 24).toShimmer(isShow: isShow,context: context), 8.height, - const SizedBox(width: 160, height: 16).toShimmer(isShow: isShow), + const SizedBox(width: 160, height: 16).toShimmer(isShow: isShow,context: context), 8.height, - const SizedBox(width: 120, height: 18).toShimmer(isShow: isShow).toShimmer(isShow: isShow), + const SizedBox(width: 120, height: 18).toShimmer(isShow: isShow,context: context).toShimmer(isShow: isShow,context: context), ], ).toShadowContainer(context) : this; Widget toShadowContainer(BuildContext context, - {bool showShadow = true, double borderRadius = 14, bool withShadow = true, Color? backgroundColor, Color borderColor = Colors.transparent, double padding = 16, EdgeInsets? paddingObject}) => + {bool showShadow = true, double borderRadius = 14, bool withShadow = true, Color? backgroundColor, Color borderColor = Colors.transparent, double padding = 16, EdgeInsets? paddingObject, EdgeInsets? margin,}) => withShadow ? Container( padding: paddingObject ?? EdgeInsets.all(padding), + margin: margin, width: double.infinity, decoration: ShapeDecoration( color: backgroundColor ?? AppColor.background(context), @@ -125,7 +127,8 @@ extension WidgetExtensions on Widget { clipBehavior: Clip.antiAlias, margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), decoration: BoxDecoration( - color: AppColor.background(context), + // color: AppColor.background(context), + color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.only(topRight: Radius.circular(20), topLeft: Radius.circular(20)), ), padding: padding ?? EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight), diff --git a/lib/models/generic_attachment_model.dart b/lib/models/generic_attachment_model.dart new file mode 100644 index 00000000..1d3cd5ea --- /dev/null +++ b/lib/models/generic_attachment_model.dart @@ -0,0 +1,26 @@ +import 'dart:io'; + +class GenericAttachmentModel { + GenericAttachmentModel({this.id, this.name,this.originalName,this.createdBy}); + + int? id; + String? name; + String ?createdBy; + String? originalName; + GenericAttachmentModel.fromJson(Map json) { + print('created by here is ${json['createdBy']}'); + id = json['id']; + name = json['name']; + createdBy = json['createdBy']; + originalName = json['originalName']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['name'] = name; + data['createdBy'] = createdBy; + data['originalName'] = originalName; + return data; + } +} \ No newline at end of file diff --git a/lib/models/helper_data_models/workorder/work_order_helper_models.dart b/lib/models/helper_data_models/workorder/work_order_helper_models.dart index cd302791..b15924d6 100644 --- a/lib/models/helper_data_models/workorder/work_order_helper_models.dart +++ b/lib/models/helper_data_models/workorder/work_order_helper_models.dart @@ -53,7 +53,7 @@ class WorkOrderHelperModel { } class WorkOrderAttachments { - WorkOrderAttachments({this.id, this.name}); + WorkOrderAttachments({this.id, this.name,this.createdBy}); int? id; String? name; @@ -170,10 +170,12 @@ class WorkOrderCostModel { num? qAmount; String? prNo; String? poNo; + String? mrNo; + num? exchangeCost; - WorkOrderCostModel({this.workOrderId, this.sparePartCost, this.labourCost, this.travelCost, this.qAmount, this.poNo, this.prNo}); + WorkOrderCostModel({this.workOrderId, this.sparePartCost, this.labourCost, this.travelCost, this.qAmount, this.poNo, this.prNo,this.mrNo,this.exchangeCost}); Map toJson() { - return {'workOrderId': workOrderId, 'sparePartCost': sparePartCost, 'laborCost': labourCost, 'travelCost': travelCost, 'qAmount': qAmount, 'prNo': prNo, 'poNo': poNo}; + return {'workOrderId': workOrderId, 'sparePartCost': sparePartCost, 'laborCost': labourCost, 'travelCost': travelCost, 'qAmount': qAmount, 'prNo': prNo, 'poNo': poNo,'mrNo':mrNo,'exchangeCost':exchangeCost}; } } diff --git a/lib/models/new_models/work_order_detail_model.dart b/lib/models/new_models/work_order_detail_model.dart index 18041173..7f44edad 100644 --- a/lib/models/new_models/work_order_detail_model.dart +++ b/lib/models/new_models/work_order_detail_model.dart @@ -106,6 +106,8 @@ class WorkOrderData { this.qAmount, this.prNo, this.poNo, + this.mrNo, + this.exchangeCost, required this.workOrderHistory, required this.activities, required this.activityAssetToBeRetireds, @@ -171,6 +173,8 @@ class WorkOrderData { num? qAmount; String? prNo; String? poNo; + String? mrNo; + num? exchangeCost; List workOrderHistory; List activities; List activityAssetToBeRetireds; @@ -207,6 +211,8 @@ class WorkOrderData { qAmount: json['qAmount'], prNo: json['prNo'], poNo: json['poNo'], + mrNo: json['mrNo'], + exchangeCost: json['exchangeCost'], assetType: json["assetType"] == null ? null : Lookup.fromJson(json["assetType"]), assignedEmployee: json["assignedEmployee"] == null ? null : WorkOrderAssignedEmployee.fromJson(json["assignedEmployee"]), lastActivityStatus: json["lastActivityStatus"] != null ? Lookup.fromJson(json["lastActivityStatus"]) : null, @@ -278,6 +284,8 @@ class WorkOrderData { "comments": comments, "voiceNote": voiceNote, "edd": edd, + 'mrNo': mrNo, + 'exchangeCost': exchangeCost, "workOrderAttachments": workOrderAttachments.map((e) => e.toJson()).toList(), "returnToService": returnToService, "serviceType": serviceType?.toJson(), @@ -828,20 +836,19 @@ class ActivityMaintenanceAssistantEmployees { double? workingHours; String? technicalComment; AssignedEmployee? user; - AssistantEmployees ?employee; + AssistantEmployees? employee; - ActivityMaintenanceAssistantEmployees({this.startDate, this.endDate, this.workingHours, this.technicalComment, this.user,this.employee}); + ActivityMaintenanceAssistantEmployees({this.startDate, this.endDate, this.workingHours, this.technicalComment, this.user, this.employee}); ActivityMaintenanceAssistantEmployees.fromJson(Map json) { - Map assistEmpData={}; - + Map assistEmpData = {}; startDate = json['startDate'] != null ? DateTime.parse(json['startDate']) : null; endDate = json['endDate'] != null ? DateTime.parse(json['endDate']) : null; workingHours = json['workingHours']; technicalComment = json['technicalComment']; user = json['user'] != null ? AssignedEmployee.fromJson(json['user']) : null; - if(json['user']!=null) { + if (json['user'] != null) { assistEmpData = { 'id': null, 'user': { @@ -866,7 +873,6 @@ class ActivityMaintenanceAssistantEmployees { } } - // class ActivityMaintenanceAssistantEmployees { // DateTime? startDate; // DateTime? endDate; @@ -923,27 +929,25 @@ class ActivityMaintenanceTimers { } } - class AssistantEmployeesModel { DateTime? startDate; DateTime? endDate; double? workingHours; String? technicalComment; AssignedEmployee? user; - AssistantEmployees ?employee; + AssistantEmployees? employee; - AssistantEmployeesModel({this.startDate, this.endDate, this.workingHours, this.technicalComment, this.user,this.employee}); + AssistantEmployeesModel({this.startDate, this.endDate, this.workingHours, this.technicalComment, this.user, this.employee}); AssistantEmployeesModel.fromJson(Map json) { - Map assistEmpData={}; - + Map assistEmpData = {}; startDate = json['startDate'] != null ? DateTime.parse(json['startDate']) : null; endDate = json['endDate'] != null ? DateTime.parse(json['endDate']) : null; workingHours = json['workingHours']; technicalComment = json['technicalComment']; user = json['user'] != null ? AssignedEmployee.fromJson(json['user']) : null; - if(json['user']!=null) { + if (json['user'] != null) { assistEmpData = { 'id': null, 'user': { diff --git a/lib/modules/cm_module/service_request_detail_provider.dart b/lib/modules/cm_module/service_request_detail_provider.dart index 743dad6a..50636738 100644 --- a/lib/modules/cm_module/service_request_detail_provider.dart +++ b/lib/modules/cm_module/service_request_detail_provider.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:http/src/response.dart'; import 'package:test_sa/controllers/api_routes/api_manager.dart'; import 'package:test_sa/controllers/api_routes/urls.dart'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/helper_data_models/asset_retired/asset_retired_model.dart'; import 'package:test_sa/models/helper_data_models/maintenance_request/activity_maintenance_model.dart'; import 'package:test_sa/models/helper_data_models/spare_part/activity_spare_part_model.dart'; @@ -257,15 +258,15 @@ class ServiceRequestDetailProvider extends ChangeNotifier { } //upload workorder attachment by engineer.. - Future addWorkOrderAttachment({required int woId, required List attachments, required List otherAttachment}) async { + Future addWorkOrderAttachment({required int woId, required List attachments, required List otherAttachment}) async { try { List woAttachments = []; if (otherAttachment.isNotEmpty) { woAttachments.addAll(otherAttachment); } for (var file in attachments) { - String fileName = ServiceRequestUtils.isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(File(file.path).readAsBytesSync())}") : file.path; - woAttachments.add(WorkOrderAttachments(id: 0, name: fileName)); + String fileName = ServiceRequestUtils.isLocalUrl(file.name ?? '') ? ("${file.name ?? ''.split("/").last}|${base64Encode(File(file.name ?? '').readAsBytesSync())}") : file.name ?? ''; + woAttachments.add(WorkOrderAttachments(id: file.id, name: fileName, createdBy: file.createdBy)); } isLoading = true; diff --git a/lib/modules/cm_module/views/components/action_button/footer_action_button.dart b/lib/modules/cm_module/views/components/action_button/footer_action_button.dart index 22083d37..e6e8de75 100644 --- a/lib/modules/cm_module/views/components/action_button/footer_action_button.dart +++ b/lib/modules/cm_module/views/components/action_button/footer_action_button.dart @@ -23,11 +23,11 @@ import 'package:test_sa/new_views/swipe_module/dialoge/acknowledge_work_dialog.d import 'package:test_sa/providers/service_request_providers/reject_reason_provider.dart'; class FooterActionButton { - static Widget footerContainer({required Widget child}) { + static Widget footerContainer({required Widget child,required BuildContext context}) { return Container( alignment: Alignment.bottomCenter, padding: const EdgeInsets.only(left: 16, right: 16, top: 12,bottom: 8), - color: AppColor.white10, + color: AppColor.background(context), child: SafeArea(child: child), ); } @@ -49,6 +49,7 @@ class FooterActionButton { switch (workOrderNextStepStatus) { case WorkOrderNextStepEnum.assignToMe: return footerContainer( + context: context, child: AppFilledButton( label: 'Assign To Me', // maxWidth: true, @@ -64,9 +65,11 @@ class FooterActionButton { case WorkOrderNextStepEnum.endWorkFlow: if (requestDetailProvider.isReadOnlyRequest) { return footerContainer( + context: context, child: AppFilledButton( label: context.translation.activities, buttonColor: AppColor.neutral50, + textColor: context.isDark ? AppColor.neutral30 : Colors.white, onPressed: () async { Navigator.push(context, MaterialPageRoute(builder: (context) => const ActivitiesListView())); }, @@ -74,6 +77,7 @@ class FooterActionButton { ); } return footerContainer( + context: context, child: AppFilledButton( label: context.translation.close, // maxWidth: true, @@ -85,9 +89,11 @@ class FooterActionButton { case WorkOrderNextStepEnum.nTakeAction: if (requestDetailProvider.isReadOnlyRequest) { return footerContainer( + context: context, child: AppFilledButton( label: context.translation.activities, - buttonColor: AppColor.neutral50, + buttonColor: context.isDark? AppColor.primary10:AppColor.neutral50, + textColor: context.isDark ? AppColor.black10 : Colors.white, onPressed: () async { Navigator.push(context, MaterialPageRoute(builder: (context) => const ActivitiesListView())); }, @@ -95,6 +101,7 @@ class FooterActionButton { ); } return footerContainer( + context: context, child: AppFilledButton( label: context.translation.close, // maxWidth: true, @@ -105,6 +112,7 @@ class FooterActionButton { )); case WorkOrderNextStepEnum.eRejectAccept: return footerContainer( + context: context, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.min, @@ -112,7 +120,8 @@ class FooterActionButton { AppFilledButton( label: context.translation.reject, maxWidth: true, - buttonColor: Colors.white54, + buttonColor:AppColor.background(context), + // textColor: context.isDark ? AppColor.neutral30 : Colors.white, textColor: AppColor.red30, showBorder: true, onPressed: () async { @@ -140,6 +149,7 @@ class FooterActionButton { )); case WorkOrderNextStepEnum.eFixRemotelyNeedVisit: return footerContainer( + context: context, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.min, @@ -169,6 +179,7 @@ class FooterActionButton { )); case WorkOrderNextStepEnum.eArrived: return footerContainer( + context: context, child: AppFilledButton( label: context.translation.iHaveArrived, showIcon: true, @@ -180,6 +191,7 @@ class FooterActionButton { )); case WorkOrderNextStepEnum.verifyAssetDetail: return footerContainer( + context: context, child: AppFilledButton( label: context.translation.updateAssetDetails, // maxWidth: true, @@ -190,12 +202,13 @@ class FooterActionButton { )); case WorkOrderNextStepEnum.activity: return footerContainer( + context: context, child: Column( children: [ AppFilledButton( label: context.translation.activities, - // maxWidth: true, - buttonColor: AppColor.neutral50, + textColor: context.isDark ? AppColor.black10 : Colors.white, + buttonColor: context.isDark? AppColor.primary10:AppColor.neutral50, onPressed: () async { // ServiceRequestBottomSheet.activityTypeBottomSheet(context: context); Navigator.push(context, MaterialPageRoute(builder: (context) => const ActivitiesListView())); @@ -237,22 +250,26 @@ class FooterActionButton { case WorkOrderNextStepEnum.assetRetirementManagementApproval: return footerContainer( + context: context, child: AppFilledButton( label: context.translation.assetRetiredPendingOpManagementApproval, - buttonColor: AppColor.neutral140, - textColor: AppColor.neutral150, + buttonColor: AppColor.background(context), + textColor: context.isDark ? Colors.white: AppColor.neutral150, fontSize: 12.toScreenWidth, )); case WorkOrderNextStepEnum.waitingForRequesterToConfirm: return footerContainer( + context: context, child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ AppFilledButton( label: 'Waiting for requester to verify', - buttonColor: AppColor.neutral140, - textColor: AppColor.neutral150, + buttonColor: AppColor.background(context), + textColor: context.isDark ? Colors.white: AppColor.neutral150, + // buttonColor: AppColor.neutral140, + // textColor: AppColor.neutral150, fontSize: 12.toScreenWidth, ), 12.height, @@ -288,6 +305,7 @@ class FooterActionButton { )); case WorkOrderNextStepEnum.eFixRemotely: return footerContainer( + context: context, child: AppFilledButton( label: context.translation.fixedRemotely, maxWidth: true, @@ -300,9 +318,11 @@ class FooterActionButton { ); case WorkOrderNextStepEnum.eNeedVisit: return footerContainer( + context: context, child: AppFilledButton( label: context.translation.needAVisit, maxWidth: true, + textColor: context.isDark ? AppColor.neutral30 : Colors.white, buttonColor: AppColor.neutral50, onPressed: () async { requestDetailProvider.needVisitHelperModel = NeedVisitHelperModel(); @@ -313,6 +333,7 @@ class FooterActionButton { } else { if (workOrderNextStepStatus == WorkOrderNextStepEnum.nTakeAction) { return footerContainer( + context: context, child: AppFilledButton( label: context.translation.takeAction, // maxWidth: true, @@ -324,6 +345,7 @@ class FooterActionButton { } if (workOrderNextStepStatus == WorkOrderNextStepEnum.waitingForRequesterToConfirm) { return footerContainer( + context: context, child: AppFilledButton( label: context.translation.takeAction, // maxWidth: true, diff --git a/lib/modules/cm_module/views/components/activities_list_view.dart b/lib/modules/cm_module/views/components/activities_list_view.dart index c40f5c81..883f7782 100644 --- a/lib/modules/cm_module/views/components/activities_list_view.dart +++ b/lib/modules/cm_module/views/components/activities_list_view.dart @@ -94,6 +94,7 @@ class _ActivitiesListViewState extends State { if (userProvider.user!.type == UsersTypes.engineer && (requestDetailProvider.currentWorkOrder?.data?.status?.value != 5 && requestDetailProvider.currentWorkOrder?.data?.status?.value != 3)) FooterActionButton.footerContainer( + context: context, child: AppFilledButton( label: context.translation.createNewActivity, maxWidth: true, diff --git a/lib/modules/cm_module/views/components/asset_detail_card.dart b/lib/modules/cm_module/views/components/asset_detail_card.dart index c8ac1c3b..239bfd42 100644 --- a/lib/modules/cm_module/views/components/asset_detail_card.dart +++ b/lib/modules/cm_module/views/components/asset_detail_card.dart @@ -17,95 +17,89 @@ class AssetDetailCard extends StatelessWidget { @override Widget build(BuildContext context) { return Consumer(builder: (context, ServiceRequestDetailProvider requestDetailProvider, snapshot) { - return Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(14), - color: AppColor.white10, - ), - padding: EdgeInsets.symmetric(horizontal: 12.toScreenWidth, vertical: 14.toScreenHeight), - margin: EdgeInsets.only(top: 10.toScreenHeight), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Row( - children: [ - StatusLabel( - label: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.equipmentStatus?.name, - id: requestDetailProvider.engineerUpdateWorkOrderHelperModel!.equipmentStatus!.id ?? 0, - radius: 4, - textColor: AppColor.white10, - backgroundColor: AppColor.getEquipmentStatusColor(context, requestDetailProvider.engineerUpdateWorkOrderHelperModel!.equipmentStatus!.id ?? 0), - ), - if(requestDetailProvider.engineerUpdateWorkOrderHelperModel?.cmFrameId!=null)...[ - 6.width, - StatusLabel( - label: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.cmFrameId?.name, - id: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.cmFrameId?.id ?? 0, - radius: 4, - textColor: AppColor.getActivityTypeTextColor(requestDetailProvider.engineerUpdateWorkOrderHelperModel!.cmFrameId?.name ?? ''), - backgroundColor: AppColor.getActivityTypeBgColor(requestDetailProvider.engineerUpdateWorkOrderHelperModel!.cmFrameId?.name ?? ''), - ), - ], + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Row( + children: [ + StatusLabel( + label: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.equipmentStatus?.name, + id: requestDetailProvider.engineerUpdateWorkOrderHelperModel!.equipmentStatus!.id ?? 0, + radius: 4, + textColor: AppColor.white10, + backgroundColor: AppColor.getEquipmentStatusColor(context, requestDetailProvider.engineerUpdateWorkOrderHelperModel!.equipmentStatus!.id ?? 0), + ), + if (requestDetailProvider.engineerUpdateWorkOrderHelperModel?.cmFrameId != null) ...[ 6.width, StatusLabel( - label: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.serviceType?.name, - id: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.serviceType?.id ?? 0, + label: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.cmFrameId?.name, + id: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.cmFrameId?.id ?? 0, radius: 4, - textColor: AppColor.getActivityTypeTextColor(requestDetailProvider.engineerUpdateWorkOrderHelperModel!.serviceType?.name ?? ''), - backgroundColor: AppColor.getActivityTypeBgColor(requestDetailProvider.engineerUpdateWorkOrderHelperModel!.serviceType?.name ?? ''), + textColor: AppColor.getActivityTypeTextColor(requestDetailProvider.engineerUpdateWorkOrderHelperModel!.cmFrameId?.name ?? ''), + backgroundColor: AppColor.getActivityTypeBgColor(requestDetailProvider.engineerUpdateWorkOrderHelperModel!.cmFrameId?.name ?? ''), ), ], - ), - //hide if status is closed or complete . - if (!requestDetailProvider.isReadOnlyRequest) - "edit_icon".toSvgAsset(height: 21, width: 21).onPress(() async { - requestDetailProvider.refreshTimer = false; - await Navigator.push(context, MaterialPageRoute(builder: (context) => VerifyAssetDetails(isEdit: true))); - requestDetailProvider.refreshTimer = true; - }), - ]), - 6.height, - Text( - "Work Order Details", - style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), - ), - Text( - '${context.translation.returnToService}: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.returnToService?.toAssetDetailsFormat ?? '-'}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - ), - Text( - 'EDD: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.edd?.toAssetDetailsFormat ?? '-'}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - ), - Text( - '${context.translation.loanAvailability}: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.loanAvailability?.name ?? '-'}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - ), - Text( - '${context.translation.failureReason}: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.failureReason?.name ?? '-'}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + 6.width, + StatusLabel( + label: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.serviceType?.name, + id: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.serviceType?.id ?? 0, + radius: 4, + textColor: AppColor.getActivityTypeTextColor(requestDetailProvider.engineerUpdateWorkOrderHelperModel!.serviceType?.name ?? ''), + backgroundColor: AppColor.getActivityTypeBgColor(requestDetailProvider.engineerUpdateWorkOrderHelperModel!.serviceType?.name ?? ''), + ), + ], ), + //hide if status is closed or complete . + if (!requestDetailProvider.isReadOnlyRequest) + "edit_icon".toSvgAsset(height: 21, width: 21, color: context.isDark ? AppColor.primary10 : null).onPress(() async { + requestDetailProvider.refreshTimer = false; + await Navigator.push(context, MaterialPageRoute(builder: (context) => VerifyAssetDetails(isEdit: true))); + requestDetailProvider.refreshTimer = true; + }), + ]), + 6.height, + Text( + "Work Order Details", + style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), + ), + Text( + '${context.translation.returnToService}: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.returnToService?.toAssetDetailsFormat ?? '-'}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + Text( + 'EDD: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.edd?.toAssetDetailsFormat ?? '-'}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + Text( + '${context.translation.loanAvailability}: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.loanAvailability?.name ?? '-'}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + Text( + '${context.translation.failureReason}: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.failureReason?.name ?? '-'}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + Text( + '${context.translation.faultDescription}: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.faultDescription?.name ?? '-'}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + Text( + '${context.translation.solutions}: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.solution ?? '-'}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + if (Provider.of(context, listen: false).isUserFMS) ...[ Text( - '${context.translation.faultDescription}: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.faultDescription?.name ?? '-'}', + 'Description of Finding: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.descriptionOfFinding ?? '-'}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), ), Text( - '${context.translation.solutions}: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.solution ?? '-'}', + 'Action Taken: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.actionTaken ?? '-'}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), ), - if (Provider.of(context, listen: false).isUserFMS) ...[ - Text( - 'Description of Finding: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.descriptionOfFinding ?? '-'}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - ), - Text( - 'Action Taken: ${requestDetailProvider.engineerUpdateWorkOrderHelperModel?.actionTaken ?? '-'}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - ), - ] - ], - ), + ] + ], + ).toShadowContainer( + context, ); }); } diff --git a/lib/modules/cm_module/views/components/bottom_sheets/service_request_bottomsheet.dart b/lib/modules/cm_module/views/components/bottom_sheets/service_request_bottomsheet.dart index 24835b82..76b93894 100644 --- a/lib/modules/cm_module/views/components/bottom_sheets/service_request_bottomsheet.dart +++ b/lib/modules/cm_module/views/components/bottom_sheets/service_request_bottomsheet.dart @@ -385,7 +385,7 @@ class ServiceRequestBottomSheet { ], ); }, - ).toShimmer(isShow: snapshot.loading); + ).toShimmer(isShow: snapshot.loading,context: context); }); } @@ -644,7 +644,8 @@ class ServiceRequestBottomSheet { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(14), // Circular border radius ), - color: AppColor.neutral80, + // color: AppColor.neutral80, + color: AppColor.background(context), child: Row( crossAxisAlignment: CrossAxisAlignment.start, // Align items at the top children: [ @@ -657,7 +658,7 @@ class ServiceRequestBottomSheet { children: [ Text( heading, - style: AppTextStyles.heading6.copyWith(color: AppColor.neutral50), + style: AppTextStyles.heading6.copyWith(color: AppColor.textColor(context)), ), 7.height, Text( diff --git a/lib/modules/cm_module/views/components/history_log_view.dart b/lib/modules/cm_module/views/components/history_log_view.dart index 4d1073be..ddcf5c0d 100644 --- a/lib/modules/cm_module/views/components/history_log_view.dart +++ b/lib/modules/cm_module/views/components/history_log_view.dart @@ -136,8 +136,8 @@ class HistoryLogView extends StatelessWidget { ); }), ], - title.bodyText(context).custom(color: AppColor.black10), - object.timeDifference.isNotEmpty ? object.timeDifference.tinyFont(context).custom(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120) : const SizedBox(), + title.bodyText(context).custom(color: AppColor.textColor(context)), + object.timeDifference.isNotEmpty ? object.timeDifference.tinyFont(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120) : const SizedBox(), ], ), diff --git a/lib/modules/cm_module/views/components/initial_visit_card.dart b/lib/modules/cm_module/views/components/initial_visit_card.dart index 898e44a9..f957ca46 100644 --- a/lib/modules/cm_module/views/components/initial_visit_card.dart +++ b/lib/modules/cm_module/views/components/initial_visit_card.dart @@ -27,44 +27,36 @@ class _InitialVisitCardState extends State { @override Widget build(BuildContext context) { return Consumer(builder: (context, ServiceRequestDetailProvider requestDetailProvider, snapshot) { - return Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(14), - color: AppColor.white10, - ), - padding: EdgeInsets.symmetric(horizontal: 12.toScreenWidth, vertical: 14.toScreenHeight), - margin: EdgeInsets.only(top: 10.toScreenHeight), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - requestDetailProvider.needVisitHelperModel!.visitDate != null ? requestDetailProvider.needVisitHelperModel!.visitDate.toString().toInitialVisitCardFormat : '', - textAlign: TextAlign.end, - style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), - ), - Row( - children: [ - "reminder_icon".toSvgAsset(height: 21, width: 21).onPress(() { - ServiceRequestBottomSheet.getReminderTimeList(context: context); - ServiceRequestBottomSheet.initialVisitReminderBottomSheet(context: context, reminder: requestDetailProvider.currentWorkOrder?.data?.setReminder); - }), - 24.width, - "edit_icon".toSvgAsset(height: 21, width: 21).onPress(() { - ServiceRequestBottomSheet.initialVisitBottomSheet(context: context); - }), - ], - ), - ]), - 2.height, - context.translation.visitDateAndTime.bodyText2(context).custom(color: AppColor.neutral120), - 12.height, - if (requestDetailProvider.needVisitHelperModel?.comment != null) ...[ - requestDetailProvider.needVisitHelperModel!.comment!.bodyText2(context).custom(color: AppColor.neutral120), - ] - ], - ), - ); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + requestDetailProvider.needVisitHelperModel!.visitDate != null ? requestDetailProvider.needVisitHelperModel!.visitDate.toString().toInitialVisitCardFormat : '', + textAlign: TextAlign.end, + style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), + ), + Row( + children: [ + "reminder_icon".toSvgAsset(height: 21, width: 21).onPress(() { + ServiceRequestBottomSheet.getReminderTimeList(context: context); + ServiceRequestBottomSheet.initialVisitReminderBottomSheet(context: context, reminder: requestDetailProvider.currentWorkOrder?.data?.setReminder); + }), + 24.width, + "edit_icon".toSvgAsset(height: 21, width: 21).onPress(() { + ServiceRequestBottomSheet.initialVisitBottomSheet(context: context); + }), + ], + ), + ]), + 2.height, + context.translation.visitDateAndTime.bodyText2(context).custom(color: AppColor.neutral120), + 12.height, + if (requestDetailProvider.needVisitHelperModel?.comment != null) ...[ + requestDetailProvider.needVisitHelperModel!.comment!.bodyText2(context).custom(color: AppColor.neutral120), + ] + ], + ).toShadowContainer(context,margin:const EdgeInsets.only(top: 12)); }); } } 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 30926f2c..9b68d982 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 @@ -12,6 +12,7 @@ import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/enums/user_types.dart'; import 'package:test_sa/models/enums/work_order_next_step.dart'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/helper_data_models/workorder/work_order_helper_models.dart'; import 'package:test_sa/models/new_models/work_order_detail_model.dart'; import 'package:test_sa/modules/cm_module/service_request_detail_provider.dart'; @@ -37,7 +38,7 @@ class ServiceRequestDetailView extends StatefulWidget { } class _ServiceRequestDetailViewState extends State { - List _userAttachments = []; + List _userAttachments = []; List _attachments = []; @override @@ -47,10 +48,20 @@ class _ServiceRequestDetailViewState extends State { @override Widget build(BuildContext context) { + //GenericAttachmentModel( + // id: e.id, + // name: e.name, + // createdBy: e.createdBy, + // // originalName: , + // localFile: File(e.name ?? ''), + // + // ) UserProvider _userProvider = Provider.of(context, listen: false); return Consumer(builder: (pContext, requestProvider, _) { if (_userProvider.user?.type == UsersTypes.engineer) { - _userAttachments = requestProvider.currentWorkOrder?.data?.workOrderAttachments.where((e) => e.createdBy == _userProvider.user?.userID).map((e) => File(e.name ?? '')).toList() ?? []; + // _userAttachments = requestProvider.currentWorkOrder?.data?.workOrderAttachments.where((e) => e.createdBy == _userProvider.user?.userID).map((e) => File(e.name ?? '')).toList() ?? []; + _userAttachments = + requestProvider.currentWorkOrder?.data?.workOrderAttachments.where((e) => e.createdBy == _userProvider.user?.userID).map((e) => GenericAttachmentModel.fromJson(e.toJson())).toList() ?? []; _attachments = requestProvider.currentWorkOrder?.data?.workOrderAttachments.where((e) => e.createdBy != _userProvider.user?.userID).toList() ?? []; } else { //show only nurse attachments @@ -73,6 +84,7 @@ class _ServiceRequestDetailViewState extends State { children: [ workOrderDetailCard(context, requestProvider.currentWorkOrder!.data!, _userProvider, requestProvider), initialVisitCard(requestDetailProvider: requestProvider, userProvider: _userProvider), + 12.height, assetDetailCard(requestDetailProvider: requestProvider, userProvider: _userProvider), 12.height, if (context.userProvider.user!.type == UsersTypes.engineer && @@ -336,20 +348,20 @@ class _ServiceRequestDetailViewState extends State { "Attachments".addTranslation, style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), ), - FilesList(images: _attachments.map((toElement) => URLs.getFileUrl(toElement.name!)!).toList()), + FilesList(images: _attachments.map((toElement) => URLs.getFileUrl(toElement.name!) ?? '').toList()), ], if (!requestProvider.isReadOnlyRequest && workOrder.nextStep?.workOrderNextStepEnum == WorkOrderNextStepEnum.activity) ...[ 8.height, const Divider().defaultStyle(context), - MultiFilesPicker( + AttachmentPicker( label: context.translation.attachments, - files: _userAttachments, + attachment: _userAttachments, buttonColor: AppColor.primary10, onlyImages: false, // showAsGrid: true, buttonIcon: 'quotation_icon'.toSvgAsset(color: AppColor.primary10), - onChange: () { - requestProvider.addWorkOrderAttachment(woId: workOrder.requestId!, attachments: _userAttachments, otherAttachment: _attachments); + onChange: (attachment) { + requestProvider.addWorkOrderAttachment(woId: workOrder.requestId!, attachments: attachment, otherAttachment: _attachments); }, ), ], @@ -496,7 +508,9 @@ 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).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; @@ -531,6 +545,14 @@ class _ServiceRequestDetailViewState extends State { 'PO No: ${provider.currentWorkOrder!.data?.poNo ?? '-'}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), ), + Text( + 'MR No: ${provider.currentWorkOrder!.data?.mrNo ?? '-'}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + Text( + 'Exchange Cost: ${provider.currentWorkOrder!.data?.exchangeCost ?? '-'}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), ], ), ], diff --git a/lib/modules/cm_module/views/components/verify_arrival_view.dart b/lib/modules/cm_module/views/components/verify_arrival_view.dart index 73d171a2..aedb85d4 100644 --- a/lib/modules/cm_module/views/components/verify_arrival_view.dart +++ b/lib/modules/cm_module/views/components/verify_arrival_view.dart @@ -80,7 +80,7 @@ class _VerifyArrivalViewState extends State { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(14), // Circular border radius ), - color: Colors.white, + color: AppColor.background(context), child: Row( crossAxisAlignment: CrossAxisAlignment.center, // Align items at the top children: [ @@ -93,7 +93,7 @@ class _VerifyArrivalViewState extends State { children: [ Text( heading, - style: AppTextStyles.heading6.copyWith(color: AppColor.neutral50), + style: AppTextStyles.heading6.copyWith(color: AppColor.textColor(context)), ), 6.height, Text( diff --git a/lib/modules/cm_module/views/forms/asset_retired/asset_retired.dart b/lib/modules/cm_module/views/forms/asset_retired/asset_retired.dart index 2d70995a..9341f72f 100644 --- a/lib/modules/cm_module/views/forms/asset_retired/asset_retired.dart +++ b/lib/modules/cm_module/views/forms/asset_retired/asset_retired.dart @@ -7,9 +7,11 @@ 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'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/helper_data_models/asset_retired/asset_retired_model.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/modules/cm_module/service_request_detail_provider.dart'; +import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart'; import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; @@ -52,7 +54,7 @@ class _AssetRetiredState extends State with TickerProviderStateMix @override Widget build(BuildContext context) { - final List _files = []; + final List attachments = []; return Scaffold( key: _scaffoldKey, @@ -75,7 +77,7 @@ class _AssetRetiredState extends State with TickerProviderStateMix SingleItemDropDownMenu( context: context, title: context.translation.retirementType, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showAsBottomSheet: true, height: 56.toScreenHeight, showShadow: false, @@ -103,9 +105,9 @@ class _AssetRetiredState extends State with TickerProviderStateMix }, ), 23.height, - MultiFilesPicker( + AttachmentPicker( label: context.translation.attachFiles, - files: _files, + attachment: attachments, buttonIcon: 'image-plus'.toSvgAsset(), ), ], @@ -113,15 +115,17 @@ class _AssetRetiredState extends State with TickerProviderStateMix ).paddingAll(16), ).expanded, FooterActionButton.footerContainer( + context: context, child: AppFilledButton( label: context.translation.submit, buttonColor: AppColor.primary10, loading: requestDetailProvider.isLoading, onPressed: () async { requestDetailProvider.assetRetiredHelperModel?.activityAssetToBeRetiredAttachments = []; - for (var file in _files) { + for (var attachment in attachments) { + String fileName = ServiceRequestUtils.isLocalUrl(attachment.name??'') ? ("${attachment.name??''.split("/").last}|${base64Encode(File(attachment.name??'').readAsBytesSync())}") :attachment.name??''; requestDetailProvider.assetRetiredHelperModel?.activityAssetToBeRetiredAttachments - ?.add(ActivityAssetToBeRetiredAttachments(id: 0, name: "${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}")); + ?.add(ActivityAssetToBeRetiredAttachments(id: attachment.id, name: fileName)); } int status = await requestDetailProvider.createActivityAssetToBeRetired(); if (status == 200) { diff --git a/lib/modules/cm_module/views/forms/asset_retired/verify_asset_detail.dart b/lib/modules/cm_module/views/forms/asset_retired/verify_asset_detail.dart index 5c69f936..de5372cf 100644 --- a/lib/modules/cm_module/views/forms/asset_retired/verify_asset_detail.dart +++ b/lib/modules/cm_module/views/forms/asset_retired/verify_asset_detail.dart @@ -61,11 +61,14 @@ class _VerifyAssetDetailsState extends State with TickerProv }); } + EngineerUpdateWorkOrderHelperModel? updateAssetModel; + late WorkOrderData currentWorkOrderData; + void assignValues() { // ServiceRequestDetailProvider requestDetailProvider = Provider.of(context, listen: false); // _requestDetailProvider = Provider.of(context, listen: false); - WorkOrderData currentWorkOrderData = _requestDetailProvider!.currentWorkOrder!.data!; - _requestDetailProvider!.engineerUpdateWorkOrderHelperModel = EngineerUpdateWorkOrderHelperModel( + currentWorkOrderData = _requestDetailProvider!.currentWorkOrder!.data!; + updateAssetModel = EngineerUpdateWorkOrderHelperModel( workOrderId: currentWorkOrderData.requestId, equipmentStatus: currentWorkOrderData.equipmentStatus, loanAvailability: currentWorkOrderData.loanAvailablity, @@ -91,7 +94,7 @@ class _VerifyAssetDetailsState extends State with TickerProv ); setState(() {}); } - getFaultDescription(assetId: _requestDetailProvider!.currentWorkOrder?.data?.asset?.id); + getFaultDescription(assetId: currentWorkOrderData.asset?.id); } @override @@ -126,15 +129,15 @@ class _VerifyAssetDetailsState extends State with TickerProv crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - assetStatusWidget(context: context, workOrderData: requestDetailProvider.engineerUpdateWorkOrderHelperModel!), + assetStatusWidget(context: context, workOrderData: updateAssetModel!), 12.height, ADatePicker( label: context.translation.returnToService, hideShadow: true, - backgroundColor: AppColor.neutral100, - // initialDate: DateTime.tryParse(requestDetailProvider.engineerUpdateWorkOrderHelperModel?.returnToService ?? ""), + backgroundColor: AppColor.fieldBgColor(context), + // initialDate: DateTime.tryParse(updateAssetModel?.returnToService ?? ""), from: requestDetailProvider.currentWorkOrder?.data?.requestedDate, - date: DateTime.tryParse(requestDetailProvider.engineerUpdateWorkOrderHelperModel?.returnToService ?? ""), + date: DateTime.tryParse(updateAssetModel?.returnToService ?? ""), formatDateWithTime: true, onDatePicker: (selectedDate) { showTimePicker( @@ -150,30 +153,29 @@ class _VerifyAssetDetailsState extends State with TickerProv selectedTime.hour, selectedTime.minute, ); - // if (requestDetailProvider.engineerUpdateWorkOrderHelperModel?.returnToService != null && - // selectedDateTime.isBefore(DateTime.parse(requestDetailProvider.engineerUpdateWorkOrderHelperModel!.returnToService!))) { + // if (updateAssetModel?.returnToService != null && + // selectedDateTime.isBefore(DateTime.parse(updateAssetModel!.returnToService!))) { // "Return To Service Date time must be greater then previous date".showToast; // return; // } setState(() { - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.returnToService = selectedDateTime.toIso8601String(); + updateAssetModel?.returnToService = selectedDateTime.toIso8601String(); }); } }); }, ), - 12.height, SingleItemDropDownMenu( context: context, title: "WO Frame", - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), height: 56.toScreenHeight, showShadow: false, - initialValue: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.cmFrameId, + initialValue: updateAssetModel?.cmFrameId, onSelect: (value) { if (value != null) { - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.cmFrameId = value; + updateAssetModel?.cmFrameId = value; } }, ), @@ -181,13 +183,13 @@ class _VerifyAssetDetailsState extends State with TickerProv SingleItemDropDownMenu( context: context, title: context.translation.failureReason, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), height: 56.toScreenHeight, showShadow: false, - initialValue: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.failureReason, + initialValue: updateAssetModel?.failureReason, onSelect: (value) { if (value != null) { - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.failureReason = value; + updateAssetModel?.failureReason = value; } }, ), @@ -195,52 +197,50 @@ class _VerifyAssetDetailsState extends State with TickerProv SingleItemDropDownMenu( context: context, title: context.translation.faultDescription, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), staticData: _faults, showShadow: false, - initialValue: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.faultDescription, + initialValue: updateAssetModel?.faultDescription, onSelect: (fault) { if (fault != null) { - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.faultDescription = fault; - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.solution = fault.workPerformed; + updateAssetModel?.faultDescription = fault; + updateAssetModel?.solution = fault.workPerformed; setState(() {}); } }, ), - if (requestDetailProvider.engineerUpdateWorkOrderHelperModel?.solution != null) ...[ + if (updateAssetModel?.solution != null) ...[ 12.height, context.translation.solutions.heading6(context).custom(color: AppColor.neutral50), 8.height, - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.solution != null - ? requestDetailProvider.engineerUpdateWorkOrderHelperModel!.solution!.bodyText2(context).custom(color: AppColor.neutral120, align: TextAlign.justify) - : const SizedBox(), + updateAssetModel?.solution != null ? updateAssetModel!.solution!.bodyText2(context).custom(color: AppColor.neutral120, align: TextAlign.justify) : const SizedBox(), ], 12.height, SingleItemDropDownMenu( context: context, title: context.translation.loanAvailability, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), height: 56.toScreenHeight, showShadow: false, - initialValue: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.loanAvailability, + initialValue: updateAssetModel?.loanAvailability, onSelect: (status) { if (status != null) { - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.loanAvailability = status; + updateAssetModel?.loanAvailability = status; if (status.value != 1) { loanAvailabilityAsset = null; - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.loanAssetId = null; + updateAssetModel?.loanAssetId = null; } setState(() {}); } }, ), - if (requestDetailProvider.engineerUpdateWorkOrderHelperModel?.loanAvailability?.value == 1) 8.height, - if (requestDetailProvider.engineerUpdateWorkOrderHelperModel?.loanAvailability?.value == 1) + if (updateAssetModel?.loanAvailability?.value == 1) 8.height, + if (updateAssetModel?.loanAvailability?.value == 1) PickAsset( device: loanAvailabilityAsset, // ?? _serviceReport.device, cardColor: AppColor.neutral100, onPickAsset: (asset) { - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.loanAssetId = asset.id; + updateAssetModel?.loanAssetId = asset.id; setState(() { loanAvailabilityAsset = asset; }); @@ -250,10 +250,10 @@ class _VerifyAssetDetailsState extends State with TickerProv ADatePicker( label: "EDD", hideShadow: true, - backgroundColor: AppColor.neutral100, - // initialDate: DateTime.tryParse(requestDetailProvider.engineerUpdateWorkOrderHelperModel?.edd ?? ""), + backgroundColor: AppColor.fieldBgColor(context), + // initialDate: DateTime.tryParse(updateAssetModel?.edd ?? ""), from: requestDetailProvider.currentWorkOrder?.data?.requestedDate, - date: DateTime.tryParse(requestDetailProvider.engineerUpdateWorkOrderHelperModel?.edd ?? ""), + date: DateTime.tryParse(updateAssetModel?.edd ?? ""), formatDateWithTime: true, onDatePicker: (selectedDate) { showTimePicker( @@ -269,13 +269,13 @@ class _VerifyAssetDetailsState extends State with TickerProv selectedTime.hour, selectedTime.minute, ); - // if (requestDetailProvider.engineerUpdateWorkOrderHelperModel?.edd != null && - // selectedDateTime.isBefore(DateTime.parse(requestDetailProvider.engineerUpdateWorkOrderHelperModel!.edd!))) { + // if (updateAssetModel?.edd != null && + // selectedDateTime.isBefore(DateTime.parse(updateAssetModel!.edd!))) { // "Return To Service Date time must be greater then previous date".showToast; // return; // } setState(() { - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.edd = selectedDateTime.toIso8601String(); + updateAssetModel?.edd = selectedDateTime.toIso8601String(); }); } }); @@ -284,13 +284,13 @@ class _VerifyAssetDetailsState extends State with TickerProv 12.height, AppTextFormField( labelText: context.translation.callResponse, - backgroundColor: AppColor.neutral100, - initialValue: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.callResponse, + backgroundColor: AppColor.fieldBgColor(context), + initialValue: updateAssetModel?.callResponse, textAlign: TextAlign.center, - labelStyle: AppTextStyles.textFieldLabelStyle, + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), showShadow: false, onChange: (value) { - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.callResponse = value; + updateAssetModel?.callResponse = value; }, style: Theme.of(context).textTheme.titleMedium, ), @@ -299,12 +299,12 @@ class _VerifyAssetDetailsState extends State with TickerProv AppTextFormField( labelText: "Description of Finding", backgroundColor: AppColor.neutral100, - initialValue: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.descriptionOfFinding, + initialValue: updateAssetModel?.descriptionOfFinding, textAlign: TextAlign.center, labelStyle: AppTextStyles.textFieldLabelStyle, showShadow: false, onChange: (value) { - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.descriptionOfFinding = value; + updateAssetModel?.descriptionOfFinding = value; }, style: Theme.of(context).textTheme.titleMedium, ), @@ -312,12 +312,12 @@ class _VerifyAssetDetailsState extends State with TickerProv AppTextFormField( labelText: "Action Taken", backgroundColor: AppColor.neutral100, - initialValue: requestDetailProvider.engineerUpdateWorkOrderHelperModel?.actionTaken, + initialValue: updateAssetModel?.actionTaken, textAlign: TextAlign.center, labelStyle: AppTextStyles.textFieldLabelStyle, showShadow: false, onChange: (value) { - requestDetailProvider.engineerUpdateWorkOrderHelperModel?.actionTaken = value; + updateAssetModel?.actionTaken = value; }, style: Theme.of(context).textTheme.titleMedium, ), @@ -326,24 +326,24 @@ class _VerifyAssetDetailsState extends State with TickerProv ).toShadowContainer(context).paddingAll(16), ).expanded, ] else ...[ - assetStatusWidget(context: context, workOrderData: requestDetailProvider.engineerUpdateWorkOrderHelperModel!).toShadowContainer(context).paddingAll(16), + assetStatusWidget(context: context, workOrderData: updateAssetModel!).toShadowContainer(context).paddingAll(16), ], Container( padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 16.toScreenHeight), - color: AppColor.white10, + color: AppColor.background(context), child: AppFilledButton( label: context.translation.updateAssetDetails, buttonColor: AppColor.primary10, onPressed: () async { if (validateForm(requestDetailProvider: requestDetailProvider)) { showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); - await requestDetailProvider.engineerUpdateWorkOrder().then((success){ + requestDetailProvider.engineerUpdateWorkOrderHelperModel = updateAssetModel; + await requestDetailProvider.engineerUpdateWorkOrder().then((success) { Navigator.pop(context); - if(success){ + if (success) { Navigator.pop(context); } }); - } }, ), @@ -359,9 +359,9 @@ class _VerifyAssetDetailsState extends State with TickerProv if (!widget.isEdit) { return true; } - // if (requestDetailProvider.engineerUpdateWorkOrderHelperModel!.equipmentStatus != null) { - // if (requestDetailProvider.engineerUpdateWorkOrderHelperModel!.equipmentStatus!.value == 1 || requestDetailProvider.engineerUpdateWorkOrderHelperModel!.equipmentStatus!.value == 2) { - // if (requestDetailProvider.engineerUpdateWorkOrderHelperModel!.returnToService == null) { + // if (updateAssetModel!.equipmentStatus != null) { + // if (updateAssetModel!.equipmentStatus!.value == 1 || updateAssetModel!.equipmentStatus!.value == 2) { + // if (updateAssetModel!.returnToService == null) { // Fluttertoast.showToast(msg: "Return to service is required ", toastLength: Toast.LENGTH_LONG); // return false; // } @@ -376,7 +376,7 @@ class _VerifyAssetDetailsState extends State with TickerProv crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - context.translation.assetStatus.bodyText(context).custom(color: AppColor.black20), + context.translation.assetStatus.bodyText(context).custom(color: AppColor.textColor(context)), 8.height, Wrap( runSpacing: 8, @@ -408,7 +408,7 @@ class _VerifyAssetDetailsState extends State with TickerProv ], ) ], - ).toShimmer(isShow: snapshot.loading), + ).toShimmer(isShow: snapshot.loading,context: context), ], ); }); diff --git a/lib/modules/cm_module/views/forms/cost/cost_detail_form_screen.dart b/lib/modules/cm_module/views/forms/cost/cost_detail_form_screen.dart index c8f99451..50080d8d 100644 --- a/lib/modules/cm_module/views/forms/cost/cost_detail_form_screen.dart +++ b/lib/modules/cm_module/views/forms/cost/cost_detail_form_screen.dart @@ -46,6 +46,8 @@ class _CostDetailFormScreenState extends State with Ticker qAmount: currentWorkOrderData.qAmount, prNo: currentWorkOrderData.prNo, poNo: currentWorkOrderData.poNo, + mrNo: currentWorkOrderData.mrNo, + exchangeCost: currentWorkOrderData.exchangeCost, ); } @@ -84,11 +86,11 @@ class _CostDetailFormScreenState extends State with Ticker // ), // 8.height, AppTextFormField( - labelText: "Labor Cost", - backgroundColor: AppColor.neutral100, initialValue: requestDetailProvider.workOrderCostModel?.labourCost?.toString(), textAlign: TextAlign.center, - labelStyle: AppTextStyles.textFieldLabelStyle, + labelText: "Labor Cost", + backgroundColor: AppColor.fieldBgColor(context), + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), textInputType: const TextInputType.numberWithOptions(decimal: true), showShadow: false, onChange: (value) { @@ -99,10 +101,10 @@ class _CostDetailFormScreenState extends State with Ticker 8.height, AppTextFormField( labelText: "Travel Cost", - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), initialValue: requestDetailProvider.workOrderCostModel?.travelCost?.toString(), textAlign: TextAlign.center, - labelStyle: AppTextStyles.textFieldLabelStyle, textInputType: const TextInputType.numberWithOptions(decimal: true), showShadow: false, onChange: (value) { @@ -113,10 +115,10 @@ class _CostDetailFormScreenState extends State with Ticker 8.height, AppTextFormField( labelText: "Quot Amount", - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), initialValue: requestDetailProvider.workOrderCostModel?.qAmount?.toString(), textAlign: TextAlign.center, - labelStyle: AppTextStyles.textFieldLabelStyle, textInputType: const TextInputType.numberWithOptions(decimal: true), showShadow: false, onChange: (value) { @@ -127,10 +129,10 @@ class _CostDetailFormScreenState extends State with Ticker 8.height, AppTextFormField( labelText: "PR No", - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), initialValue: requestDetailProvider.workOrderCostModel?.prNo, textAlign: TextAlign.center, - labelStyle: AppTextStyles.textFieldLabelStyle, textInputType: const TextInputType.numberWithOptions(decimal: true), showShadow: false, onChange: (value) { @@ -141,10 +143,10 @@ class _CostDetailFormScreenState extends State with Ticker 8.height, AppTextFormField( labelText: "PO No", - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), initialValue: requestDetailProvider.workOrderCostModel?.poNo, textAlign: TextAlign.center, - labelStyle: AppTextStyles.textFieldLabelStyle, textInputType: const TextInputType.numberWithOptions(decimal: true), showShadow: false, onChange: (value) { @@ -152,12 +154,40 @@ class _CostDetailFormScreenState extends State with Ticker }, style: Theme.of(context).textTheme.titleMedium, ), + 8.height, + AppTextFormField( + labelText: "MR No", + backgroundColor: AppColor.fieldBgColor(context), + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), + initialValue: requestDetailProvider.workOrderCostModel?.mrNo, + textAlign: TextAlign.center, + textInputType: const TextInputType.numberWithOptions(decimal: true), + showShadow: false, + onChange: (value) { + requestDetailProvider.workOrderCostModel?.mrNo = value; + }, + style: Theme.of(context).textTheme.titleMedium, + ), + 8.height, + AppTextFormField( + labelText: "Exchange Cost", + backgroundColor: AppColor.fieldBgColor(context), + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), + initialValue: requestDetailProvider.workOrderCostModel?.exchangeCost != null ? requestDetailProvider.workOrderCostModel?.exchangeCost.toString() : '', + textAlign: TextAlign.center, + textInputType: const TextInputType.numberWithOptions(decimal: true), + showShadow: false, + onChange: (value) { + requestDetailProvider.workOrderCostModel?.exchangeCost = num.parse(value); + }, + style: Theme.of(context).textTheme.titleMedium, + ), ], ).toShadowContainer(context).paddingAll(16), ).expanded, Container( padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 16.toScreenHeight), - color: AppColor.white10, + color: AppColor.background(context), child: AppFilledButton( label: "Update Cost Details", buttonColor: AppColor.primary10, @@ -234,7 +264,7 @@ class _CostDetailFormScreenState extends State with Ticker ], ) ], - ).toShimmer(isShow: snapshot.loading), + ).toShimmer(isShow: snapshot.loading, context: context), ], ); }); diff --git a/lib/modules/cm_module/views/forms/maintenance_request/components/assistant_employee_list.dart b/lib/modules/cm_module/views/forms/maintenance_request/components/assistant_employee_list.dart index 3c09f7bd..1cbedee1 100644 --- a/lib/modules/cm_module/views/forms/maintenance_request/components/assistant_employee_list.dart +++ b/lib/modules/cm_module/views/forms/maintenance_request/components/assistant_employee_list.dart @@ -14,13 +14,13 @@ import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart'; import 'package:test_sa/views/widgets/date_and_time/date_picker.dart'; import 'package:test_sa/views/widgets/status/report/service_report_assistant_employee_menu.dart'; -class AssistantEmployeeList extends StatefulWidget { +class ServiceRequestAssistantEmployeeList extends StatefulWidget { final List? assistantEmployeeList; final ValueChanged>? onListChanged; final double? cardPadding; final dynamic assetId; - const AssistantEmployeeList({ + const ServiceRequestAssistantEmployeeList({ super.key, this.assistantEmployeeList, this.onListChanged, @@ -29,10 +29,10 @@ class AssistantEmployeeList extends StatefulWidget { }); @override - State createState() => _AssistantEmployeeListState(); + State createState() => _ServiceRequestAssistantEmployeeListState(); } -class _AssistantEmployeeListState extends State { +class _ServiceRequestAssistantEmployeeListState extends State { late List _list; late List _controllers; @@ -80,7 +80,7 @@ class _AssistantEmployeeListState extends State { child: AppFilledButton( label: "Add Assistant Employee".addTranslation, maxWidth: true, - textColor: AppColor.black10, + textColor: AppColor.textColor(context), buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10, icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)), showIcon: true, @@ -132,7 +132,7 @@ class EmployeeCard extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - context.translation.assistantEmployee.bodyText(context).custom(color: AppColor.black20), + context.translation.assistantEmployee.bodyText(context).custom(color: AppColor.textColor(context)), if (!isReadOnly) Container( height: 32, @@ -148,7 +148,7 @@ class EmployeeCard extends StatelessWidget { children: [ ServiceReportAssistantEmployeeMenu( title: context.translation.select, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), assetId: assetId, initialValue: model.employee, onSelect: (employee) { @@ -170,7 +170,7 @@ class EmployeeCard extends StatelessWidget { ADatePicker( label: context.translation.startTime, hideShadow: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), date: model.startDate, formatDateWithTime: true, from: requestedDate, @@ -215,7 +215,7 @@ class EmployeeCard extends StatelessWidget { ADatePicker( label: context.translation.endTime, hideShadow: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), date: model.endDate, formatDateWithTime: true, from: requestedDate, @@ -261,20 +261,21 @@ class EmployeeCard extends StatelessWidget { 8.height, AppTextFormField( labelText: context.translation.workingHours, - backgroundColor: AppColor.neutral80, + backgroundColor: AppColor.fieldBgColor(context), + // backgroundColor: AppColor.neutral80, controller: workingHoursController, suffixIcon: "clock".toSvgAsset(width: 20, color: context.isDark ? AppColor.neutral10 : null).paddingOnly(end: 16), textAlign: TextAlign.center, enable: false, showShadow: false, - labelStyle: AppTextStyles.textFieldLabelStyle, + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), style: Theme.of(context).textTheme.titleMedium, ), 8.height, AppTextFormField( initialValue: model.technicalComment, labelText: context.translation.technicalComment, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, labelStyle: AppTextStyles.textFieldLabelStyle, alignLabelWithHint: true, diff --git a/lib/modules/cm_module/views/forms/maintenance_request/components/external_request.dart b/lib/modules/cm_module/views/forms/maintenance_request/components/external_request.dart index b6843244..e6cb952d 100644 --- a/lib/modules/cm_module/views/forms/maintenance_request/components/external_request.dart +++ b/lib/modules/cm_module/views/forms/maintenance_request/components/external_request.dart @@ -60,7 +60,7 @@ class _ExternalMaintenanceRequestState extends State SingleItemDropDownMenu( context: context, title: context.translation.supplier, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), initialValue: requestDetailProvider.activityMaintenanceHelperModel?.supplier, showAsBottomSheet: true, showShadow: false, @@ -76,7 +76,7 @@ class _ExternalMaintenanceRequestState extends State children: [ SingleItemDropDownMenu( context: context, - backgroundColor: requestDetailProvider.activityMaintenanceHelperModel?.supplier?.suppliername == null ? AppColor.neutral40 : AppColor.neutral100, + backgroundColor: requestDetailProvider.activityMaintenanceHelperModel?.supplier?.suppliername == null ? context.isDark ? AppColor.neutral20 : AppColor.neutral40 : AppColor.fieldBgColor(context), title: context.translation.supplierEngineer, showShadow: false, enabled: requestDetailProvider.activityMaintenanceHelperModel?.supplier?.suppPersons?.isNotEmpty ?? false, @@ -106,7 +106,8 @@ class _ExternalMaintenanceRequestState extends State height: 56.toScreenHeight, width: 60.toScreenWidth, decoration: BoxDecoration( - color: requestDetailProvider.activityMaintenanceHelperModel?.supplier?.suppliername == null ? AppColor.neutral40 : AppColor.neutral100, + // color: requestDetailProvider.activityMaintenanceHelperModel?.supplier?.suppliername == null ? AppColor.neutral40 : AppColor.neutral100, + color: requestDetailProvider.activityMaintenanceHelperModel?.supplier?.suppliername == null ? context.isDark ? AppColor.neutral20 : AppColor.neutral40 : AppColor.fieldBgColor(context), borderRadius: BorderRadius.circular(10), //boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], ), @@ -135,7 +136,7 @@ class _ExternalMaintenanceRequestState extends State ADatePicker( label: context.translation.startTime, hideShadow: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), date: requestDetailProvider.activityMaintenanceHelperModel?.supplierStartTime, from: requestDetailProvider.currentWorkOrder?.data?.requestedDate, formatDateWithTime: true, @@ -177,7 +178,7 @@ class _ExternalMaintenanceRequestState extends State ADatePicker( label: context.translation.endTime, hideShadow: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), from: requestDetailProvider.currentWorkOrder?.data?.requestedDate, to: DateTime.now(), enable: requestDetailProvider.activityMaintenanceHelperModel?.supplierStartTime != null, @@ -240,13 +241,13 @@ class _ExternalMaintenanceRequestState extends State 8.height, AppTextFormField( labelText: context.translation.workingHours, - backgroundColor: AppColor.neutral80, + backgroundColor: AppColor.fieldBgColor(context), controller: _workingHoursController, suffixIcon: "clock".toSvgAsset(width: 20, color: context.isDark ? AppColor.neutral10 : null).paddingOnly(end: 16), initialValue: requestDetailProvider.activityMaintenanceHelperModel?.supplierWorkingHour != null ? requestDetailProvider.activityMaintenanceHelperModel?.supplierWorkingHour.toString() : '', textAlign: TextAlign.center, - labelStyle: AppTextStyles.textFieldLabelStyle, + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), enable: false, showShadow: false, style: Theme.of(context).textTheme.titleMedium, diff --git a/lib/modules/cm_module/views/forms/maintenance_request/components/internal_request.dart b/lib/modules/cm_module/views/forms/maintenance_request/components/internal_request.dart index a214591d..d65026e6 100644 --- a/lib/modules/cm_module/views/forms/maintenance_request/components/internal_request.dart +++ b/lib/modules/cm_module/views/forms/maintenance_request/components/internal_request.dart @@ -88,7 +88,8 @@ class _InternalMaintenanceRequestState extends State height: 56.toScreenHeight, title: context.translation.activityStatus, showShadow: false, - backgroundColor: AppColor.neutral100, + // backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showAsBottomSheet: true, initialValue: requestDetailProvider.activityMaintenanceHelperModel?.activityStatus, onSelect: (status) { @@ -210,7 +211,7 @@ class _InternalMaintenanceRequestState extends State padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), alignment: Alignment.centerLeft, decoration: BoxDecoration( - color: context.isDark ? AppColor.neutral40 : AppColor.background(context), + color: AppColor.fieldBgColor(context), borderRadius: BorderRadius.circular(10), boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], ), @@ -249,7 +250,7 @@ class _InternalMaintenanceRequestState extends State AppTextFormField( labelText: context.translation.travelingHours, controller: _travellingHoursController, - backgroundColor: AppColor.neutral100, + backgroundColor:AppColor.fieldBgColor(context), showShadow: false, labelStyle: AppTextStyles.textFieldLabelStyle, suffixIcon: "clock".toSvgAsset(width: 20, color: context.isDark ? AppColor.neutral10 : null).paddingOnly(end: 16), @@ -268,7 +269,7 @@ class _InternalMaintenanceRequestState extends State 16.height, AppTextFormField( labelText: context.translation.assignedEmployee, - backgroundColor: AppColor.neutral80, + backgroundColor: AppColor.fieldBgColor(context), initialValue: requestDetailProvider.activityMaintenanceHelperModel?.assignedEmployee?.userName, textAlign: TextAlign.center, labelStyle: AppTextStyles.textFieldLabelStyle, @@ -280,7 +281,7 @@ class _InternalMaintenanceRequestState extends State AppTextFormField( initialValue: requestDetailProvider.activityMaintenanceHelperModel?.technicalComment, labelText: context.translation.technicalComment, - backgroundColor: AppColor.neutral100, + backgroundColor:AppColor.fieldBgColor(context), showShadow: false, labelStyle: AppTextStyles.textFieldLabelStyle, alignLabelWithHint: true, @@ -295,7 +296,7 @@ class _InternalMaintenanceRequestState extends State ], ), ).toShadowContainer(context).paddingOnly(start: 13, end: 14, top: 12), - AssistantEmployeeList( + ServiceRequestAssistantEmployeeList( assetId: requestDetailProvider.currentWorkOrder?.data?.asset?.id, assistantEmployeeList: requestDetailProvider.activityMaintenanceHelperModel?.assistantEmployList, onListChanged: (updatedList) { @@ -325,7 +326,7 @@ class _InternalMaintenanceRequestState extends State crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - context.translation.repairLocation.bodyText(context).custom(color: AppColor.black20), + context.translation.repairLocation.bodyText(context).custom(color: AppColor.textColor(context)), 8.height, Wrap( runSpacing: 8, @@ -357,7 +358,7 @@ class _InternalMaintenanceRequestState extends State ], ) ], - ).toShimmer(isShow: snapshot.isLoading), + ).toShimmer(isShow: snapshot.isLoading,context: context), ], ); }); diff --git a/lib/modules/cm_module/views/forms/maintenance_request/maintenance_request_main.dart b/lib/modules/cm_module/views/forms/maintenance_request/maintenance_request_main.dart index 379279bc..11aeccb2 100644 --- a/lib/modules/cm_module/views/forms/maintenance_request/maintenance_request_main.dart +++ b/lib/modules/cm_module/views/forms/maintenance_request/maintenance_request_main.dart @@ -51,7 +51,7 @@ class _MaintenanceRequestFormState extends State with Si return Consumer(builder: (context, ServiceRequestDetailProvider requestDetailProvider, child) { bool isUpdate = requestDetailProvider.activityMaintenanceHelperModel?.id != 0; return Scaffold( - backgroundColor: AppColor.neutral110, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, appBar: DefaultAppBar( title: "CM Activity", onWillPopScope: requestDetailProvider.isReadOnlyRequest @@ -104,6 +104,7 @@ class _MaintenanceRequestFormState extends State with Si ).expanded, if (!requestDetailProvider.isReadOnlyRequest) FooterActionButton.footerContainer( + context: context, child: AppFilledButton( label: requestDetailProvider.activityMaintenanceHelperModel?.id != 0 ? context.translation.update : context.translation.addActivity, // Use the dynamic label buttonColor: AppColor.primary10, diff --git a/lib/modules/cm_module/views/forms/spare_part/spare_part_request.dart b/lib/modules/cm_module/views/forms/spare_part/spare_part_request.dart index 19726391..ccfc76b2 100644 --- a/lib/modules/cm_module/views/forms/spare_part/spare_part_request.dart +++ b/lib/modules/cm_module/views/forms/spare_part/spare_part_request.dart @@ -11,11 +11,13 @@ 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/generic_attachment_model.dart'; import 'package:test_sa/models/helper_data_models/spare_part/activity_spare_part_model.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/service_request/spare_parts.dart'; import 'package:test_sa/models/size_config.dart'; import 'package:test_sa/modules/cm_module/service_request_detail_provider.dart'; +import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart'; import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/modules/cm_module/views/components/bottom_sheets/service_request_bottomsheet.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; @@ -25,7 +27,7 @@ import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart'; import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart'; import 'package:test_sa/providers/loading_list_notifier.dart'; -import 'package:test_sa/views/widgets/images/new_multi_image_picker.dart'; +import 'package:test_sa/views/widgets/images/multi_image_picker.dart'; import 'package:test_sa/views/widgets/loaders/no_data_found.dart'; class SparePartRequest extends StatefulWidget { @@ -43,7 +45,7 @@ class _SparePartRequestState extends State with TickerProvider bool _isLoading = false; List _spareParts = []; - List _files = []; + List attachments = []; final GlobalKey _formKey = GlobalKey(); final GlobalKey _scaffoldKey = GlobalKey(); final TextEditingController _partQtyController = TextEditingController(); @@ -80,7 +82,7 @@ class _SparePartRequestState extends State with TickerProvider activityStatus = _requestDetailProvider?.sparePartHelperModel?.activityStatus?.value; scheduleMicrotask(() async { _isLoading = true; - _files = _requestDetailProvider?.sparePartHelperModel?.sparePartAttachments?.map((e) => MultiFilesPickerModel(e.id!, File(e.name!))).toList() ?? []; + attachments = _requestDetailProvider?.sparePartHelperModel?.sparePartAttachments?.map((e) => GenericAttachmentModel(id: e.id!, name: e.name ?? '')).toList() ?? []; setState(() {}); _spareParts = await _partsProvider!.getPartsListByDisplayName(assetId: _requestDetailProvider?.currentWorkOrder?.data?.asset?.id); _isLoading = false; @@ -95,7 +97,7 @@ class _SparePartRequestState extends State with TickerProvider _returnQtyController.clear(); _oracleNoController.clear(); _descriptionController.clear(); - _files = []; + attachments = []; } @override @@ -291,9 +293,9 @@ class _SparePartRequestState extends State with TickerProvider }, ), 12.height, - NewMultiFilesPicker( + AttachmentPicker( label: context.translation.attachQuotation, - files: _files, + attachment: attachments, buttonIcon: 'quotation_icon'.toSvgAsset(), buttonColor: AppColor.primary10, ), @@ -307,6 +309,7 @@ class _SparePartRequestState extends State with TickerProvider ).expanded, if (!requestDetailProvider.isReadOnlyRequest) FooterActionButton.footerContainer( + context: context, child: AppFilledButton( label: _requestDetailProvider?.sparePartHelperModel?.id == 0 ? context.translation.addSparePartActivity : context.translation.updateSparePartActivity, buttonColor: AppColor.green70, @@ -332,10 +335,10 @@ class _SparePartRequestState extends State with TickerProvider requestDetailProvider.sparePartHelperModel?.sparePartAttachments?.clear(); - for (var pickerObject in _files) { - String fileData = _isLocalUrl(pickerObject.file.path) ? "${pickerObject.file.path.split("/").last}|${base64Encode(File(pickerObject.file.path).readAsBytesSync())}" : pickerObject.file.path; + for (var item in attachments) { + String fileName = ServiceRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? ''; requestDetailProvider.sparePartHelperModel?.sparePartAttachments?.add( - SparePartAttachments(id: pickerObject.id, name: fileData), + SparePartAttachments(id: item.id, name: fileName), ); } diff --git a/lib/modules/cm_module/views/nurse/create_new_request_view.dart b/lib/modules/cm_module/views/nurse/create_new_request_view.dart index d4f90f68..6535c2e1 100644 --- a/lib/modules/cm_module/views/nurse/create_new_request_view.dart +++ b/lib/modules/cm_module/views/nurse/create_new_request_view.dart @@ -13,11 +13,13 @@ import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/enums/user_types.dart'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/helper_data_models/workorder/work_order_helper_models.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/service_request/pending_service_request_model.dart'; import 'package:test_sa/models/service_request/service_request.dart'; import 'package:test_sa/modules/cm_module/service_request_detail_provider.dart'; +import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart'; import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; @@ -52,7 +54,7 @@ class _CreateNewRequestState extends State with TickerProvider late ServiceRequestsProvider _serviceRequestsProvider; late ServiceRequestDetailProvider _requestDetailProvider; late ServiceRequest _serviceRequest; - final List _deviceImages = []; + final List _deviceImages = []; final bool _isLoading = false; final GlobalKey _formKey = GlobalKey(); final GlobalKey _scaffoldKey = GlobalKey(); @@ -72,7 +74,7 @@ class _CreateNewRequestState extends State with TickerProvider getInitialData(); if (_serviceRequestsProvider.currentSelectedRequest != null) { _serviceRequest = _serviceRequestsProvider.currentSelectedRequest!; - _deviceImages.addAll(_serviceRequest.devicePhotos!.map((e) => File(e)).toList()); + _deviceImages.addAll(_serviceRequest.devicePhotos!.map((e) => GenericAttachmentModel(name: e)).toList()); _showDatePicker = _serviceRequest.firstAction != null && _serviceRequest.firstAction?.name == "Need a visit"; if (_showDatePicker && _serviceRequest.visitDate != null) { _dateTime = DateTime.tryParse(_serviceRequest.visitDate!); @@ -154,9 +156,9 @@ class _CreateNewRequestState extends State with TickerProvider 16.height, assetStatusWidget(context), 24.height, - MultiFilesPicker( + AttachmentPicker( label: context.translation.attachImage, - files: _deviceImages, + attachment: _deviceImages, buttonColor: AppColor.black10, onlyImages: false, buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), @@ -169,6 +171,7 @@ class _CreateNewRequestState extends State with TickerProvider ), ).expanded, FooterActionButton.footerContainer( + context: context, child: AppFilledButton( // label: context.translation.submitRequest, buttonColor: AppColor.primary10, @@ -235,7 +238,7 @@ class _CreateNewRequestState extends State with TickerProvider ], ) ], - ).toShimmer(isShow: snapshot.loading), + ).toShimmer(isShow: snapshot.loading,context: context), ], ); }); @@ -277,7 +280,7 @@ class _CreateNewRequestState extends State with TickerProvider _serviceRequest.priority = snapshot.items.firstWhere((element) => element.value == 0, orElse: null); } setState(() {}); - }).toShimmer(isShow: snapshot.loading); + }).toShimmer(isShow: snapshot.loading,context: context); }), ], ); @@ -351,7 +354,8 @@ class _CreateNewRequestState extends State with TickerProvider } List attachement = []; for (var item in _deviceImages) { - attachement.add(WorkOrderAttachments(id: 0, name: "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}")); + String fileName = ServiceRequestUtils.isLocalUrl(item.name??'') ? ("${item.name??''.split("/").last}|${base64Encode(File(item.name??'').readAsBytesSync())}") :item.name??''; + attachement.add(WorkOrderAttachments(id: 0, name: fileName)); } _requestDetailProvider.workOrderHelperModel = WorkOrderHelperModel( assetId: _serviceRequest.device?.id, diff --git a/lib/modules/cm_module/views/service_request_detail_main_view.dart b/lib/modules/cm_module/views/service_request_detail_main_view.dart index 294c284b..bd89910c 100644 --- a/lib/modules/cm_module/views/service_request_detail_main_view.dart +++ b/lib/modules/cm_module/views/service_request_detail_main_view.dart @@ -73,7 +73,7 @@ class _ServiceRequestDetailMainState extends State { return true; }, child: Scaffold( - backgroundColor: AppColor.neutral100, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, appBar: DefaultAppBar( title: context.translation.cmDetails, onBackPress: () { diff --git a/lib/modules/pm_module/ppm_wo/update_ppm/ppm_calibration_tools_form.dart b/lib/modules/pm_module/ppm_wo/update_ppm/ppm_calibration_tools_form.dart index fd3d3913..ad460de5 100644 --- a/lib/modules/pm_module/ppm_wo/update_ppm/ppm_calibration_tools_form.dart +++ b/lib/modules/pm_module/ppm_wo/update_ppm/ppm_calibration_tools_form.dart @@ -43,7 +43,7 @@ class _PpmCalibrationToolsFormState extends State { child: AppFilledButton( label: "Add More Calibration Tools".addTranslation, maxWidth: true, - textColor: AppColor.black10, + textColor: AppColor.headingTextColor(context), buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10, icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)), showIcon: true, @@ -106,8 +106,8 @@ class _PpmCalibrationToolsFormState extends State { ADatePicker( label: context.translation.calibrationDate, date: DateTime.tryParse(model.calibrationDateOfTesters ?? ""), - from: DateTime.now().subtract(const Duration(days: 90)), - backgroundColor: context.isDark ? AppColor.neutral50 : AppColor.neutral100, + from: DateTime.now().subtract(const Duration(days: 10*365)), + backgroundColor: AppColor.fieldBgColor(context), withBorder: false, hideShadow: true, onDatePicker: (date) { diff --git a/lib/modules/pm_module/ppm_wo/update_ppm/ppm_external_details_form.dart b/lib/modules/pm_module/ppm_wo/update_ppm/ppm_external_details_form.dart index b689b26a..8b1be526 100644 --- a/lib/modules/pm_module/ppm_wo/update_ppm/ppm_external_details_form.dart +++ b/lib/modules/pm_module/ppm_wo/update_ppm/ppm_external_details_form.dart @@ -66,7 +66,7 @@ class _PpmExternalDetailsFormState extends State { child: AppFilledButton( label: "Add More External Details".addTranslation, maxWidth: true, - textColor: AppColor.black10, + textColor: AppColor.headingTextColor(context), buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10, icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)), showIcon: true, @@ -150,7 +150,7 @@ class _ExternalDetailItemState extends State { context: context, title: context.translation.supplier, initialValue: widget.model.supplier, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showAsBottomSheet: true, showShadow: false, showCancel: true, @@ -168,7 +168,7 @@ class _ExternalDetailItemState extends State { context: context, title: context.translation.supplierEngineer, enabled: widget.model.supplier != null, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), initialValue: widget.model.suppPerson, staticData: widget.model.supplier?.suppPersons, showAsBottomSheet: true, @@ -184,7 +184,7 @@ class _ExternalDetailItemState extends State { height: 56.toScreenHeight, width: 60.toScreenWidth, decoration: BoxDecoration( - color: AppColor.neutral100, + color: AppColor.fieldBgColor(context), borderRadius: BorderRadius.circular(10), //boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], ), @@ -217,7 +217,7 @@ class _ExternalDetailItemState extends State { ADatePicker( label: context.translation.startTime, hideShadow: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), date: widget.model.startDateTime, formatDateWithTime: true, from: DateTime.tryParse(_ppmProvider?.planPreventiveVisit?.createdDate ?? ''), @@ -260,7 +260,7 @@ class _ExternalDetailItemState extends State { ADatePicker( label: context.translation.endTime, hideShadow: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), date: widget.model.endDateTime, enable: widget.model.startDateTime != null, formatDateWithTime: true, @@ -303,7 +303,7 @@ class _ExternalDetailItemState extends State { 8.height, AppTextFormField( labelText: context.translation.workingHours, - backgroundColor: AppColor.neutral80, + backgroundColor: AppColor.fieldBgColor(context), controller: controller, textAlign: TextAlign.center, enable: false, diff --git a/lib/modules/pm_module/ppm_wo/update_ppm/ppm_pm_check_list_form.dart b/lib/modules/pm_module/ppm_wo/update_ppm/ppm_pm_check_list_form.dart index 7d6e727e..9f5b0e63 100644 --- a/lib/modules/pm_module/ppm_wo/update_ppm/ppm_pm_check_list_form.dart +++ b/lib/modules/pm_module/ppm_wo/update_ppm/ppm_pm_check_list_form.dart @@ -55,6 +55,7 @@ class _PpmPmChecklistFormState extends State { ], AppTextFormField( labelText: "Task".addTranslation, + labelStyle: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120, fontWeight: FontWeight.w500), initialValue: list[index].instructionText?.text ?? "", enable: false, diff --git a/lib/modules/pm_module/ppm_wo/update_ppm/ppm_pm_kits_form.dart b/lib/modules/pm_module/ppm_wo/update_ppm/ppm_pm_kits_form.dart index e7ca9f0d..a25e4d4a 100644 --- a/lib/modules/pm_module/ppm_wo/update_ppm/ppm_pm_kits_form.dart +++ b/lib/modules/pm_module/ppm_wo/update_ppm/ppm_pm_kits_form.dart @@ -40,7 +40,7 @@ class _PpmPMKitsFormState extends State { child: AppFilledButton( label: "Add More PM Kits".addTranslation, maxWidth: true, - textColor: AppColor.black10, + textColor: AppColor.headingTextColor(context), buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10, icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)), showIcon: true, diff --git a/lib/modules/pm_module/ppm_wo/update_ppm/update_ppm.dart b/lib/modules/pm_module/ppm_wo/update_ppm/update_ppm.dart index 9750998d..6f5224a5 100644 --- a/lib/modules/pm_module/ppm_wo/update_ppm/update_ppm.dart +++ b/lib/modules/pm_module/ppm_wo/update_ppm/update_ppm.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:io'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -47,8 +48,9 @@ class _UpdatePpmState extends State with TickerProviderStateMixin { showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); ppmProvider.planPreventiveVisit?.preventiveVisitAttachments = []; for (var item in ppmProvider.ppmPlanAttachments) { + String fileName = ServiceRequestUtils.isLocalUrl(item.name??'') ? ("${item.name??''.split("/").last}|${base64Encode(File(item.name??'').readAsBytesSync())}") :item.name??''; ppmProvider.planPreventiveVisit?.preventiveVisitAttachments - ?.add(PreventiveVisitAttachments(id: 0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path)); + ?.add(PreventiveVisitAttachments(id: item.id, attachmentName: fileName)); } ppmProvider.planPreventiveVisit?.preventiveVisitTimers = ppmProvider.planPreventiveVisit?.preventiveVisitTimers ?? []; @@ -123,7 +125,7 @@ class _UpdatePpmState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: AppColor.neutral110, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, appBar: DefaultAppBar( title: context.translation.preventiveMaintenance, onWillPopScope: ppmProvider.isReadOnly @@ -205,6 +207,7 @@ class _UpdatePpmState extends State with TickerProviderStateMixin { if (tabIndex == 1) ...[ AppFilledButton( buttonColor: _tabController!.index == 0 ? null : AppColor.background(context), + // buttonColor: _tabController!.index == 0 ? null : AppColor.background(context), textColor: _tabController!.index == 0 ? null : AppColor.blueStatus(context), showBorder: true, disableButton: _tabController!.index == 0, @@ -222,8 +225,10 @@ class _UpdatePpmState extends State with TickerProviderStateMixin { ], if (!ppmProvider.isReadOnly) ...[ AppFilledButton( - buttonColor: AppColor.white60, - textColor: AppColor.neutral50, + // buttonColor: AppColor.white60, + // textColor: AppColor.neutral50, + buttonColor: context.isDark?AppColor.neutral50:AppColor.white60, + textColor: context.isDark ? Colors.white: AppColor.neutral150, onPressed: () { _onSubmit(status: 0); }, diff --git a/lib/modules/pm_module/ppm_wo/update_ppm/wo_info_form.dart b/lib/modules/pm_module/ppm_wo/update_ppm/wo_info_form.dart index 0e12c5dc..75a7ed6b 100644 --- a/lib/modules/pm_module/ppm_wo/update_ppm/wo_info_form.dart +++ b/lib/modules/pm_module/ppm_wo/update_ppm/wo_info_form.dart @@ -12,6 +12,7 @@ import 'package:test_sa/helper/utils.dart'; import 'package:test_sa/models/device/asset.dart'; import 'package:test_sa/models/device/model_definition.dart'; import 'package:test_sa/models/device/supplier.dart'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/new_models/building.dart'; import 'package:test_sa/models/new_models/department.dart'; @@ -51,7 +52,7 @@ class _WoInfoFormState extends State { PpmProvider ppmProvider = Provider.of(context, listen: false); if (widget.planPreventiveVisit.preventiveVisitAttachments != null && widget.planPreventiveVisit.preventiveVisitAttachments!.isNotEmpty) { ppmProvider.ppmPlanAttachments = []; - ppmProvider.ppmPlanAttachments.addAll(widget.planPreventiveVisit.preventiveVisitAttachments!.map((e) => File(e.attachmentName!)).toList()); + ppmProvider.ppmPlanAttachments.addAll(widget.planPreventiveVisit.preventiveVisitAttachments!.map((e) => GenericAttachmentModel(id:e.id,name:e.attachmentName!)).toList()); } }); @@ -82,7 +83,7 @@ class _WoInfoFormState extends State { backgroundColor: AppColor.getRequestStatusColorByName(context, widget.planPreventiveVisit.visitStatus?.name), ), 8.height, - widget.planPreventiveVisit.planName!.bodyText(context).custom(color: AppColor.black10), + widget.planPreventiveVisit.planName!.bodyText(context).custom(color: AppColor.headingTextColor(context)), 2.height, '${context.translation.pmPlanNo}: ${widget.planPreventiveVisit.planNo}'.bodyText2(context).custom(color: AppColor.neutral120), //need to add in translation it's suggestion from ahmed.. @@ -107,7 +108,7 @@ class _WoInfoFormState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - widget.planPreventiveVisit.assetName!.bodyText(context).custom(color: AppColor.black10).expanded, + widget.planPreventiveVisit.assetName!.bodyText(context).custom(color: AppColor.headingTextColor(context)).expanded, "info_icon".toSvgAsset(height: 17, width: 17).onPress( () { // There is only limited information for asset is returned from backend to show all info need to return the whole model from backend... @@ -127,8 +128,8 @@ class _WoInfoFormState extends State { ], ), 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), + '${context.translation.assetNo}: ${widget.planPreventiveVisit.asset?.assetNumber}'.bodyText2(context).custom(color: AppColor.lightTextColor(context)), + '${context.translation.model}: ${widget.planPreventiveVisit.model}'.bodyText2(context).custom(color: AppColor.lightTextColor(context)), ], ).toShadowContainer(context), @@ -172,7 +173,7 @@ class _WoInfoFormState extends State { initialValue: widget.planPreventiveVisit.taskStatus == null ? null : Lookup(name: widget.planPreventiveVisit.taskStatus?.name ?? "", id: widget.planPreventiveVisit.taskStatus?.id), title: context.translation.pmTestResult, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), onSelect: (value) { if (value != null) { widget.planPreventiveVisit.taskStatus = value; @@ -183,7 +184,7 @@ class _WoInfoFormState extends State { ADatePicker( label: context.translation.actualVisit, hideShadow: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), date: widget.planPreventiveVisit.acutalDateOfVisit, from: DateTime.tryParse(widget.planPreventiveVisit.creationDate ?? ''), formatDateWithTime: true, @@ -230,7 +231,7 @@ class _WoInfoFormState extends State { 8.height, SingleItemDropDownMenu( context: context, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, initialValue: widget.planPreventiveVisit.safety?.id == null ? null : Lookup(name: widget.planPreventiveVisit.safety?.name ?? "", id: widget.planPreventiveVisit.safety?.id), title: "Electrical Safety", @@ -243,7 +244,7 @@ class _WoInfoFormState extends State { 8.height, SingleItemDropDownMenu( context: context, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, initialValue: widget.planPreventiveVisit.assetAvailability == null ? null @@ -258,7 +259,7 @@ class _WoInfoFormState extends State { 8.height, SingleItemDropDownMenu( context: context, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, initialValue: widget.planPreventiveVisit.typeOfService == null ? null @@ -281,7 +282,7 @@ class _WoInfoFormState extends State { 8.height, AppTextFormField( labelText: context.translation.comment, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, initialValue: (widget.planPreventiveVisit.comments ?? "").toString(), textAlign: TextAlign.center, @@ -291,9 +292,9 @@ class _WoInfoFormState extends State { }, ), 16.height, - MultiFilesPicker( + AttachmentPicker( label: context.translation.attachments, - files: ppmProvider.ppmPlanAttachments, + attachment: ppmProvider.ppmPlanAttachments, buttonColor: AppColor.black10, onlyImages: false, buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), @@ -359,7 +360,7 @@ class _WoInfoFormState extends State { children: [ AppTimer( label: context.translation.workingHours, - decoration: BoxDecoration(color: AppColor.neutral100, borderRadius: BorderRadius.circular(10)), + decoration: BoxDecoration(color: AppColor.fieldBgColor(context), borderRadius: BorderRadius.circular(10)), width: double.infinity, timer: widget.planPreventiveVisit.tbsTimer, pickerTimer: widget.planPreventiveVisit.ppMTimePicker, diff --git a/lib/modules/pm_module/recurrent_wo/components/room_inspection_card.dart b/lib/modules/pm_module/recurrent_wo/components/room_inspection_card.dart index 295eff91..1bd12455 100644 --- a/lib/modules/pm_module/recurrent_wo/components/room_inspection_card.dart +++ b/lib/modules/pm_module/recurrent_wo/components/room_inspection_card.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:test_sa/controllers/providers/api/gas_refill_comments.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'; @@ -28,10 +30,10 @@ class _RoomInspectionCardState extends State { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - widget.inspectionModel!.tabName!.bodyText(context).custom(color: AppColor.neutral50, fontWeight: FontWeight.w600), + widget.inspectionModel!.tabName!.bodyText(context).custom(color:AppColor.textColor(context), fontWeight: FontWeight.w600), 8.height, Container( - color: Colors.white10, + color: context.isDark?null: Colors.white10, child: Column( children: widget.inspectionModel!.planRecurrentMedicalTaskRoomTabAttributes?.asMap().entries.map((entry) { final model = entry.value; @@ -66,7 +68,7 @@ class _RoomInspectionCardState extends State { model.attribute?.name ?? '', overflow: TextOverflow.ellipsis, maxLines: 1, - style: AppTextStyles.bodyText2.copyWith(color: AppColor.white936), + style: AppTextStyles.bodyText2.copyWith(color: context.isDark?Colors.white:AppColor.white936), ), (status ? 'Pass' : 'Fail').bodyText2(context).custom(color: AppColor.neutral120, fontWeight: FontWeight.w500), ], @@ -83,7 +85,7 @@ class _RoomInspectionCardState extends State { height: 30.toScreenHeight, padding: EdgeInsetsDirectional.all(4.toScreenHeight), decoration: BoxDecoration( - color: AppColor.white80, + color: AppColor.fieldBgColor(context), borderRadius: BorderRadius.circular(5), ), child: Row( @@ -94,14 +96,14 @@ class _RoomInspectionCardState extends State { isActive: status, activeColor: AppColor.green20, inactiveColor: Colors.transparent, - textColor: status ? AppColor.green50 : AppColor.black20, + textColor: status ? AppColor.green50 : context.isDark?Colors.white: AppColor.black20, ), buildToggleOption( label: "FAIL", isActive: !status, activeColor: AppColor.red20, inactiveColor: Colors.transparent, - textColor: status ? AppColor.black20 : AppColor.red30, + textColor: status ? context.isDark?Colors.white: AppColor.black20 : AppColor.red30, ), ], ), @@ -188,14 +190,14 @@ class _RoomInspectionCardState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ - model.attribute!.name!.bodyText2(context).custom(color: AppColor.white936, fontWeight: FontWeight.w500), + model.attribute!.name!.bodyText2(context).custom(color: context.isDark?Colors.white:AppColor.white936, fontWeight: FontWeight.w500), TextFormField( keyboardType: TextInputType.number, initialValue: model.attributeValue ?? '', decoration: InputDecoration( contentPadding: EdgeInsets.symmetric(horizontal: 5.toScreenWidth), filled: true, - fillColor: AppColor.neutral100, + fillColor: AppColor.fieldBgColor(context), constraints: BoxConstraints( maxWidth: 99.toScreenWidth, maxHeight: 30.toScreenHeight, diff --git a/lib/modules/pm_module/recurrent_wo/components/room_tabs_widget.dart b/lib/modules/pm_module/recurrent_wo/components/room_tabs_widget.dart index c40db559..23fe99d8 100644 --- a/lib/modules/pm_module/recurrent_wo/components/room_tabs_widget.dart +++ b/lib/modules/pm_module/recurrent_wo/components/room_tabs_widget.dart @@ -68,7 +68,7 @@ class _RoomTabsWidgetState extends State { color: selectedIndex == index ? (context.isDark ? AppColor.neutral60 : AppColor.neutral110) : Colors.transparent, borderRadius: BorderRadius.circular(7), ), - child: label.bodyText(context).custom(color: AppColor.white936), + child: label.bodyText(context).custom(color:context.isDark?Colors.white: AppColor.white936), ), ); }).toList(), diff --git a/lib/modules/pm_module/recurrent_wo/components/task_info_widget.dart b/lib/modules/pm_module/recurrent_wo/components/task_info_widget.dart index 0264d52f..1871dc61 100644 --- a/lib/modules/pm_module/recurrent_wo/components/task_info_widget.dart +++ b/lib/modules/pm_module/recurrent_wo/components/task_info_widget.dart @@ -35,7 +35,7 @@ class RecurrentTaskInfoWidget extends StatelessWidget { backgroundColor: AppColor.getRequestStatusColorByName(context, model?.status?.name), ), 8.height, - model!.title!.bodyText(context).custom(color: AppColor.black10), + model!.title!.bodyText(context).custom(color: AppColor.textColor(context)), 2.height, '${context.translation.taskNo}: ${model!.taskNo!}'.bodyText2(context).custom(color: AppColor.neutral120), '${context.translation.site}: ${model!.site!.siteName!}'.bodyText2(context).custom(color: AppColor.neutral120), @@ -79,7 +79,7 @@ class RecurrentTaskInfoWidget extends StatelessWidget { width: double.infinity, enabled: snapshot.recurrentWoData?.status?.value != 1, decoration: BoxDecoration( - color: AppColor.neutral100, + color: AppColor.fieldBgColor(context), borderRadius: BorderRadius.circular(10), ), pickerTimer: model?.recurrentWoTimePicker, @@ -103,7 +103,7 @@ class RecurrentTaskInfoWidget extends StatelessWidget { 8.width, Text( ServiceRequestUtils.formatTimerDuration(totalWorkingHours.round()), - style: AppTextStyles.bodyText.copyWith(color: AppColor.neutral50, fontWeight: FontWeight.w600), + style: AppTextStyles.bodyText.copyWith(color: AppColor.textColor(context), fontWeight: FontWeight.w600), ), ], ), @@ -117,9 +117,10 @@ class RecurrentTaskInfoWidget extends StatelessWidget { return AppTextFormField( initialValue: model?.comment, labelText: context.translation.comment, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, - labelStyle: AppTextStyles.textFieldLabelStyle, + hintStyle: TextStyle(color: context.isDark?AppColor.white10:AppColor.black10), + labelStyle: TextStyle(color: context.isDark?AppColor.white10:AppColor.black10), alignLabelWithHint: true, textInputType: TextInputType.multiline, onChange: (value) { @@ -145,8 +146,8 @@ Widget buildingInfoWidget({required String label, required String? value, requir 3.height, Text( value ?? '', - style: AppTextStyles.bodyText2.copyWith(color: AppColor.black10), + style: AppTextStyles.bodyText2.copyWith(color: AppColor.textColor(context)), ) ], - ).toShadowContainer(context, backgroundColor: AppColor.neutral100, borderRadius: 10, paddingObject: EdgeInsets.all(12.toScreenHeight), showShadow: false); + ).toShadowContainer(context, backgroundColor: AppColor.background(context), borderRadius: 10, paddingObject: EdgeInsets.all(12.toScreenHeight), showShadow: false); } diff --git a/lib/modules/pm_module/recurrent_wo/recurrent_work_order_view.dart b/lib/modules/pm_module/recurrent_wo/recurrent_work_order_view.dart index a453473a..28d88fdd 100644 --- a/lib/modules/pm_module/recurrent_wo/recurrent_work_order_view.dart +++ b/lib/modules/pm_module/recurrent_wo/recurrent_work_order_view.dart @@ -80,19 +80,22 @@ class _RecurrentWorkOrderViewState extends State { ).expanded, if (requestProvider.recurrentWoData?.status?.value != 1) ...[ FooterActionButton.footerContainer( + context: context, + child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ AppFilledButton( label: context.translation.save, - buttonColor: AppColor.white60, - textColor: AppColor.black10, + buttonColor: context.isDark?AppColor.neutral20: AppColor.white60, + textColor: context.isDark?Colors.white: AppColor.black10, onPressed: () => _updateTask(context: context, status: 0), ).expanded, 12.width, AppFilledButton( label: context.translation.complete, buttonColor: AppColor.primary10, + // textColor: context.isDark?Colors.white: AppColor.black10, onPressed: () => _updateTask(context: context, status: 1), ).expanded, ], diff --git a/lib/modules/tm_module/tasks_wo/create_task_view.dart b/lib/modules/tm_module/tasks_wo/create_task_view.dart index 95b9d17a..f042f489 100644 --- a/lib/modules/tm_module/tasks_wo/create_task_view.dart +++ b/lib/modules/tm_module/tasks_wo/create_task_view.dart @@ -10,12 +10,14 @@ import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/device/asset.dart'; import 'package:test_sa/models/enums/user_types.dart'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/new_models/mapped_sites.dart'; import 'package:test_sa/models/new_models/room_model.dart'; import 'package:test_sa/models/new_models/task_request/task_request_model.dart'; import 'package:test_sa/models/new_models/task_request/task_type_model.dart'; import 'package:test_sa/models/service_request/pending_service_request_model.dart'; +import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart'; import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; @@ -41,7 +43,7 @@ class CreateTaskView extends StatefulWidget { } class _CreateTaskViewState extends State with TickerProviderStateMixin { - final List _deviceImages = []; + final List attachments = []; final GlobalKey _formKey = GlobalKey(); final GlobalKey _scaffoldKey = GlobalKey(); List _deviceList = []; @@ -111,17 +113,23 @@ class _CreateTaskViewState extends State with TickerProviderStat }, ), 23.height, - MultiFilesPicker( + AttachmentPicker( label: context.translation.attachImage, - files: _deviceImages, + attachment: attachments, buttonColor: AppColor.black10, onlyImages: false, buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), + //verify this if not required delete this .. + onChange: (attachments) { + attachments = attachments; + setState(() {}); + }, ), ], ).toShadowContainer(context).paddingAll(16), ).expanded, FooterActionButton.footerContainer( + context: context, child: AppFilledButton( buttonColor: AppColor.primary10, label: context.translation.submitRequest, @@ -444,8 +452,9 @@ class _CreateTaskViewState extends State with TickerProviderStat _addTaskModel!.assetIds?.add(int.parse(device!.id.toString())); } } - for (var item in _deviceImages) { - _addTaskModel?.attachments?.add(TaskJobAttachment(id: 0, name: "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}")); + for (var item in attachments) { + String fileName = ServiceRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? ''; + _addTaskModel?.attachments?.add(TaskJobAttachment(id: item.id, name: fileName)); } TaskRequestProvider taskRequestProvider = Provider.of(context, listen: false); await taskRequestProvider.addTask(context: context, task: _addTaskModel!); diff --git a/lib/modules/tm_module/tasks_wo/update_task_request_view.dart b/lib/modules/tm_module/tasks_wo/update_task_request_view.dart index 26223427..4eae87dc 100644 --- a/lib/modules/tm_module/tasks_wo/update_task_request_view.dart +++ b/lib/modules/tm_module/tasks_wo/update_task_request_view.dart @@ -12,6 +12,7 @@ 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/generic_attachment_model.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/new_models/building.dart'; import 'package:test_sa/models/new_models/department.dart'; @@ -54,7 +55,7 @@ class _UpdateTaskRequestState extends State { final TextEditingController _requestedQuantityController = TextEditingController(); final GlobalKey _formKey = GlobalKey(); final GlobalKey _scaffoldKey = GlobalKey(); - List _files = []; + List attachments = []; bool installationType = true; String comments = ''; List _userAttachments = []; @@ -78,6 +79,12 @@ class _UpdateTaskRequestState extends State { _readOnlyAttachments = _taskProvider?.taskRequestModel?.taskJobAttachments?.where((e) => e.createdBy != _userProvider.user?.userID).toList() ?? []; _taskProvider?.updateTaskModel(taskModel); + if (taskModel != null) { + attachments.addAll(taskModel.taskJobAttachments!.map((e) => GenericAttachmentModel(id:e.id,name:e.name ?? '')).toList()); + // if (taskModel.taskType?.isInstallation == true) { + // await _taskProvider!.getSiteData(siteId: taskModel.asset?.siteId); + // } + } } @override @@ -101,76 +108,78 @@ class _UpdateTaskRequestState extends State { ? const ALoading() : taskProvider.taskRequestModel != null ? Form( - key: _formKey, - child: Column( - children: [ - SingleChildScrollView( - padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)), - child: Column( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _timerWidget(context, true, taskProvider), - 8.height, - if (taskProvider.taskRequestModel?.taskType?.isInstallation == true) ...[installationWidget(taskModel: taskProvider.taskRequestModel!)], - if (taskProvider.taskRequestModel?.taskType?.isRecallAndAlert == true) ...[ - recallAlertTypeWidget(taskModel: taskProvider.taskRequestModel!), + key: _formKey, + child: Column( + children: [ + SingleChildScrollView( + padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)), + child: Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _timerWidget(context, true, taskProvider), + 8.height, + if (taskProvider.taskRequestModel?.taskType?.isInstallation == true) ...[installationWidget(taskModel: taskProvider.taskRequestModel!)], + if (taskProvider.taskRequestModel?.taskType?.isRecallAndAlert == true) ...[ + recallAlertTypeWidget(taskModel: taskProvider.taskRequestModel!), + ], + // if (previousComments.isNotEmpty) ...[ + // 'Previous Comments'.bodyText2(context).custom(color: AppColor.neutral50), + // 8.height, + buildPreviousComments(taskProvider: taskProvider), + // 8.height, + // ], + AppTextFormField( + initialValue: "", + labelText: context.translation.technicalComment, + textInputType: TextInputType.multiline, + backgroundColor: AppColor.fieldBgColor(context), + labelStyle: TextStyle(color: AppColor.textColor(context)), + showShadow: false, + alignLabelWithHint: true, + onChange: (value) { + comments = value; + setState(() {}); + }, + onSaved: (value) {}, + ), + 20.height, + AttachmentPicker( + label: context.translation.attachFiles, + attachment: attachments, + buttonColor: AppColor.black10, + onlyImages: false, + buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), + ), ], - // if (previousComments.isNotEmpty) ...[ - // 'Previous Comments'.bodyText2(context).custom(color: AppColor.neutral50), - // 8.height, - buildPreviousComments(taskProvider: taskProvider), - // 8.height, - // ], - AppTextFormField( - initialValue: "", - labelText: context.translation.technicalComment, - textInputType: TextInputType.multiline, - backgroundColor: AppColor.neutral90, - showShadow: false, - alignLabelWithHint: true, - onChange: (value) { - comments = value; - setState(() {}); - }, - onSaved: (value) {}, - ), - 20.height, - MultiFilesPicker( - label: context.translation.attachFiles, - files: _userAttachments, - buttonColor: AppColor.black10, - onlyImages: false, - buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), - ), - ], - ).toShadowContainer(context), - 16.height, - const AssistantEmployeeCard().toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16)), - ], - ), - ).expanded, - FooterActionButton.footerContainer( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - AppFilledButton( - label: context.translation.save, - buttonColor: AppColor.white60, - textColor: AppColor.black10, - onPressed: () => _updateTask(context: context, status: 0), - ).expanded, - 12.width, - AppFilledButton( - label: context.translation.complete, - buttonColor: AppColor.primary10, - onPressed: () => _updateTask(context: context, status: 1), - ).expanded, - ], + ).toShadowContainer(context), + 16.height, + const AssistantEmployeeCard().toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16)), + ], + ), + ).expanded, + FooterActionButton.footerContainer( + context: context, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + AppFilledButton( + label: context.translation.save, + buttonColor: AppColor.white60, + textColor: AppColor.black10, + onPressed: () => _updateTask(context: context, status: 0), + ).expanded, + 12.width, + AppFilledButton( + label: context.translation.complete, + buttonColor: AppColor.primary10, + onPressed: () => _updateTask(context: context, status: 1), + ).expanded, + ], + ), ), - ), - ], + ], ), ) : NoDataFound(message: context.translation.noDataFound).center, @@ -189,12 +198,9 @@ class _UpdateTaskRequestState extends State { if (validate(model: taskModel)) { showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); List attachment = []; - if (_readOnlyAttachments.isNotEmpty) { - attachment.addAll(_readOnlyAttachments); - } - for (var file in _userAttachments) { - String fileName = ServiceRequestUtils.isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(File(file.path).readAsBytesSync())}") : file.path; - attachment.add(TaskJobAttachment(id: 0, name: fileName)); + for (var item in attachments) { + String fileName = ServiceRequestUtils.isLocalUrl(item.name??'') ? ("${item.name??''.split("/").last}|${base64Encode(File(item.name??'').readAsBytesSync())}") :item.name??''; + attachment.add(TaskJobAttachment(id: item.id, name: fileName)); } taskModel?.taskJobAttachments = attachment; if (taskModel?.taskTimePicker != null) { @@ -268,7 +274,7 @@ class _UpdateTaskRequestState extends State { ADatePicker( label: context.translation.installationDate, hideShadow: true, - backgroundColor: AppColor.neutral90, + backgroundColor: AppColor.fieldBgColor(context), date: DateTime.tryParse(taskModel.installationDate ?? ""), formatDateWithTime: false, onDatePicker: (selectedDate) { @@ -294,7 +300,7 @@ class _UpdateTaskRequestState extends State { 8.height, AppTextFormField( labelText: context.translation.serialNo, - backgroundColor: AppColor.neutral90, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, labelStyle: AppTextStyles.textFieldLabelStyle, initialValue: taskModel.serialNo ?? '', @@ -310,7 +316,7 @@ class _UpdateTaskRequestState extends State { initialValue: taskModel.site, loading: _taskProvider?.isSiteLoading, showAsBottomSheet: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, enabled: false, onSelect: (value) { @@ -328,7 +334,7 @@ class _UpdateTaskRequestState extends State { SingleItemDropDownMenu( context: context, title: 'Installation Building', - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showAsBottomSheet: true, loading: _taskProvider?.isSiteLoading, showShadow: false, @@ -349,7 +355,7 @@ class _UpdateTaskRequestState extends State { SingleItemDropDownMenu( context: context, showAsBottomSheet: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), loading: _taskProvider?.isSiteLoading, showShadow: false, title: 'Installation Floor', @@ -369,7 +375,7 @@ class _UpdateTaskRequestState extends State { SingleItemDropDownMenu( context: context, title: 'Installation Department', - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), loading: _taskProvider?.isSiteLoading, showAsBottomSheet: true, showShadow: false, @@ -429,7 +435,7 @@ class _UpdateTaskRequestState extends State { height: 56.toScreenHeight, title: context.translation.completedActions, showShadow: false, - backgroundColor: AppColor.neutral90, + backgroundColor: AppColor.fieldBgColor(context), enabled: false, showAsBottomSheet: true, initialValue: taskModel.actionNeeded, @@ -444,7 +450,7 @@ class _UpdateTaskRequestState extends State { height: 56.toScreenHeight, title: context.translation.impactStatus, showShadow: false, - backgroundColor: AppColor.neutral90, + backgroundColor: AppColor.fieldBgColor(context), showAsBottomSheet: true, initialValue: taskModel.impactStatus, onSelect: (status) { @@ -468,7 +474,7 @@ class _UpdateTaskRequestState extends State { height: 56.toScreenHeight, title: context.translation.completedActions, showShadow: false, - backgroundColor: AppColor.neutral90, + backgroundColor: AppColor.fieldBgColor(context), enabled: false, showAsBottomSheet: true, initialValue: taskModel.actionNeeded, @@ -483,7 +489,7 @@ class _UpdateTaskRequestState extends State { height: 56.toScreenHeight, title: context.translation.impactStatus, showShadow: false, - backgroundColor: AppColor.neutral90, + backgroundColor: AppColor.fieldBgColor(context), showAsBottomSheet: true, initialValue: taskModel.impactStatus, onSelect: (status) { @@ -515,7 +521,7 @@ class _UpdateTaskRequestState extends State { width: double.infinity, enabled: isTimerEnable, decoration: BoxDecoration( - color: AppColor.neutral90, + color: AppColor.fieldBgColor(context), borderRadius: BorderRadius.circular(10), ), pickerTimer: taskProvider.taskRequestModel?.taskTimePicker, @@ -534,11 +540,11 @@ class _UpdateTaskRequestState extends State { crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: [ - 'Total Working Time:'.bodyText2(context).custom(color: AppColor.neutral50), + 'Total Working Time:'.bodyText2(context).custom(color: AppColor.textColor(context)), 8.width, Text( ServiceRequestUtils.formatTimerDuration(totalWorkingHours.round()), - style: AppTextStyles.bodyText.copyWith(color: AppColor.neutral50, fontWeight: FontWeight.w600), + style: AppTextStyles.bodyText.copyWith(color: AppColor.textColor(context), fontWeight: FontWeight.w600), ), ], ), @@ -655,7 +661,7 @@ class _AssistantEmployeeCardState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - context.translation.assistantEmployee.heading6(context).custom(color: AppColor.black10), + context.translation.assistantEmployee.heading6(context).custom(color: AppColor.textColor(context)), Icon(isExpanded ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded), ], ), @@ -670,7 +676,7 @@ class _AssistantEmployeeCardState extends State { children: [ ServiceReportAssistantEmployeeMenu( title: context.translation.select, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), initialValue: (taskModel?.assistantEmployees?.isNotEmpty ?? false) ? taskModel?.assistantEmployees?.first : null, onSelect: (employee) { if (employee == null) { @@ -688,7 +694,7 @@ class _AssistantEmployeeCardState extends State { ADatePicker( label: context.translation.startTime, hideShadow: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), date: taskModel?.modelAssistantEmployees?.startDate, // from: taskModel?.d, formatDateWithTime: true, @@ -728,7 +734,7 @@ class _AssistantEmployeeCardState extends State { ADatePicker( label: context.translation.endTime, hideShadow: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), date: taskModel?.modelAssistantEmployees?.endDate, enable: taskModel?.modelAssistantEmployees?.startDate != null, formatDateWithTime: true, @@ -782,12 +788,12 @@ class _AssistantEmployeeCardState extends State { 8.height, AppTextFormField( labelText: context.translation.workingHours, - backgroundColor: AppColor.neutral80, + backgroundColor: AppColor.fieldBgColor(context), controller: _workingHoursController, suffixIcon: "clock".toSvgAsset(width: 20, color: context.isDark ? AppColor.neutral10 : null).paddingOnly(end: 16), initialValue: taskModel?.modelAssistantEmployees?.workingHours != null ? taskModel!.modelAssistantEmployees!.workingHours?.toStringAsFixed(2) : '', textAlign: TextAlign.center, - labelStyle: AppTextStyles.textFieldLabelStyle, + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), enable: false, showShadow: false, style: Theme.of(context).textTheme.titleMedium, @@ -796,9 +802,9 @@ class _AssistantEmployeeCardState extends State { AppTextFormField( initialValue: taskModel?.modelAssistantEmployees?.comment, labelText: context.translation.comment, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, - labelStyle: AppTextStyles.textFieldLabelStyle, + labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)), alignLabelWithHint: true, textInputType: TextInputType.multiline, onChange: (value) { diff --git a/lib/new_views/app_style/app_color.dart b/lib/new_views/app_style/app_color.dart index 847b6b59..22a12370 100644 --- a/lib/new_views/app_style/app_color.dart +++ b/lib/new_views/app_style/app_color.dart @@ -96,6 +96,11 @@ class AppColor { static Color yellowIcon(BuildContext context) => context.isDark ? const Color(0xffFFC945) : orange70; static Color background(BuildContext context) => context.isDark ? neutral60 : Colors.white; + static Color textColor(BuildContext context) =>context.isDark ? AppColor.neutral30 : AppColor.neutral50; + static Color headingTextColor(BuildContext context) =>context.isDark ? AppColor.neutral30 : AppColor.black10; + static Color lightTextColor(BuildContext context) =>AppColor.neutral120; + static Color iconColor(BuildContext context) =>context.isDark ? AppColor.neutral30 : AppColor.neutral50; + static Color fieldBgColor(BuildContext context) => context.isDark ? AppColor.neutral20 : AppColor.neutral100; static Color selectedButtonColor(BuildContext context) => context.isDark ? neutral60 : neutral30; @@ -180,6 +185,8 @@ static Color getActivityTypeTextColor(String type) { return red30; case "canceled": return red30; + case "returned": + return red30; default: return Colors.white; } diff --git a/lib/new_views/common_widgets/app_bottom_nav_bar.dart b/lib/new_views/common_widgets/app_bottom_nav_bar.dart index d0587226..5de1cec8 100644 --- a/lib/new_views/common_widgets/app_bottom_nav_bar.dart +++ b/lib/new_views/common_widgets/app_bottom_nav_bar.dart @@ -34,7 +34,8 @@ class AppBottomNavigationBar extends StatelessWidget { boxShadow: [boxShadowR14], ), child: BottomNavigationBar( - backgroundColor: Colors.white, + // backgroundColor: Colors.white, + backgroundColor: AppColor.background(context), items: [ for (int i = 0; i < navItems.length; i++) navBarItem(context, index: navItems[i].index, iconName: navItems[i].iconName, label: navItems[i].label, showLabel: navItems[i].showLabel), ], diff --git a/lib/new_views/common_widgets/app_filled_button.dart b/lib/new_views/common_widgets/app_filled_button.dart index 87376c27..8e1e67f2 100644 --- a/lib/new_views/common_widgets/app_filled_button.dart +++ b/lib/new_views/common_widgets/app_filled_button.dart @@ -1,7 +1,9 @@ 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/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; +import 'package:test_sa/models/new_models/gas_refill_model.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; class AppFilledButton extends StatelessWidget { @@ -43,7 +45,7 @@ class AppFilledButton extends StatelessWidget { alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - color: disableButton ? AppColor.neutral140 : (buttonColor ?? AppColor.blueStatus(context)), + color: disableButton ?context.isDark ?AppColor.neutral20 :AppColor.neutral140 : (buttonColor ?? AppColor.blueStatus(context)), border: showBorder ? Border.all(color: textColor ?? AppColor.background(context)) : null, ), child: loading diff --git a/lib/new_views/common_widgets/app_text_form_field.dart b/lib/new_views/common_widgets/app_text_form_field.dart index e607c105..2434230c 100644 --- a/lib/new_views/common_widgets/app_text_form_field.dart +++ b/lib/new_views/common_widgets/app_text_form_field.dart @@ -188,7 +188,7 @@ class _AppTextFormFieldState extends State { controller: widget.controller, textInputAction: widget.textInputType == TextInputType.multiline ? null : widget.textInputAction ?? TextInputAction.next, onEditingComplete: widget.onAction ?? () => FocusScope.of(context).nextFocus(), - style: widget.style ?? AppTextStyle.body1.copyWith(fontWeight: FontWeight.w500,color: AppColor.black10), + style: widget.style ?? AppTextStyle.body1.copyWith(fontWeight: FontWeight.w500,color:context.isDark?AppColor.white10: AppColor.black10), onTap: widget.onTap, decoration: InputDecoration( alignLabelWithHint: widget.alignLabelWithHint, @@ -208,7 +208,7 @@ class _AppTextFormFieldState extends State { ? (widget.enableColor ?? AppColor.neutral40) : AppColor.background(context)), errorStyle: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60), - floatingLabelStyle: AppTextStyle.body1.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? null : AppColor.neutral20), + floatingLabelStyle: AppTextStyle.body1.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.white10 : AppColor.neutral20), hintText: widget.hintText ?? "", labelText: (widget.showSpeechToText && _speechToText.isListening) ? "Listening..." : widget.labelText ?? "", labelStyle: widget.labelStyle, 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 8fd75aff..49e75c0f 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 @@ -112,7 +112,7 @@ class _SingleItemDropDownMenuState { Lookup? _requestedQuantity; final TextEditingController _commentController = TextEditingController(); GasRefillProvider? _gasRefillProvider; - List _files = []; + List attachments = []; static List gasQuantity = [ Lookup(name: "1", id: 1, value: 1), @@ -80,7 +81,7 @@ class _GasRefillRequestFormState extends State { context: context, title: context.translation.gasType, initialValue: _currentDetails.gasType, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, showAsBottomSheet: true, onSelect: (value) { @@ -92,7 +93,7 @@ class _GasRefillRequestFormState extends State { context: context, title: context.translation.cylinderType, initialValue: _currentDetails.cylinderType, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, onSelect: (value) { _currentDetails.cylinderType = value; @@ -104,7 +105,7 @@ class _GasRefillRequestFormState extends State { title: context.translation.cylinderSize, initialValue: _currentDetails.cylinderSize, showAsBottomSheet: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, onSelect: (value) { _currentDetails.cylinderSize = value; @@ -117,7 +118,7 @@ class _GasRefillRequestFormState extends State { showAsBottomSheet: true, initialValue: _requestedQuantity, staticData: gasQuantity, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, onSelect: (value) { _requestedQuantity = value; @@ -132,7 +133,7 @@ class _GasRefillRequestFormState extends State { title: context.translation.site, initialValue: _gasModel.mapSite, showAsBottomSheet: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, onSelect: (value) { setState(() { @@ -151,7 +152,7 @@ class _GasRefillRequestFormState extends State { enabled: _gasModel.mapSite?.buildings?.isNotEmpty ?? false, staticData: _gasModel.mapSite?.buildings ?? [], showAsBottomSheet: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, onSelect: (value) { setState(() { @@ -173,7 +174,7 @@ class _GasRefillRequestFormState extends State { enabled: _gasModel.mappedBuilding?.floors?.isNotEmpty ?? false, staticData: _gasModel.mappedBuilding?.floors ?? [], showAsBottomSheet: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, onSelect: (value) { setState(() { @@ -190,7 +191,7 @@ class _GasRefillRequestFormState extends State { enabled: _gasModel.mappedFloor?.departments?.isNotEmpty ?? false, staticData: _gasModel.mappedFloor?.departments ?? [], showAsBottomSheet: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, onSelect: (value) { _gasModel.mappedDepartment = value; @@ -201,10 +202,10 @@ class _GasRefillRequestFormState extends State { 8.height, AppTextFormField( labelText: context.translation.callComments, - labelStyle: AppTextStyles.tinyFont.copyWith(color: AppColor.neutral120), + labelStyle: AppTextStyles.tinyFont.copyWith(color: AppColor.textColor(context)), textInputType: TextInputType.multiline, alignLabelWithHint: true, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, controller: _commentController, onChange: (value) { @@ -213,9 +214,9 @@ class _GasRefillRequestFormState extends State { onSaved: (value) {}, ), 8.height, - MultiFilesPicker( + AttachmentPicker( label: context.translation.attachFiles, - files: _files, + attachment: attachments, buttonColor: AppColor.black10, onlyImages: false, buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), @@ -224,7 +225,7 @@ class _GasRefillRequestFormState extends State { ).toShadowContainer(context, padding: 10).paddingOnly(start: 16, end: 16, top: 16), ).expanded, 16.height, - FooterActionButton.footerContainer(child: AppFilledButton(label: context.translation.submitRequest, maxWidth: true, onPressed: _submit)), + FooterActionButton.footerContainer(context: context, child: AppFilledButton(label: context.translation.submitRequest, maxWidth: true, onPressed: _submit)), ], ), ); @@ -235,9 +236,10 @@ class _GasRefillRequestFormState extends State { _gasModel.gasRefillDetails = []; _gasModel.gasRefillDetails?.add(_currentDetails); _gasModel.gasRefillAttachments = []; - for (var item in _files) { + for (var item in attachments) { + String fileName = ServiceRequestUtils.isLocalUrl(item.name??'') ? ("${item.name??''.split("/").last}|${base64Encode(File(item.name??'').readAsBytesSync())}") :item.name??''; _gasModel.gasRefillAttachments?.add(GasRefillAttachments( - id: 0, gasRefillId: _gasModel.id ?? 0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path)); + id: item.id, gasRefillId: _gasModel.id ?? 0, attachmentName: fileName)); } await _gasRefillProvider?.addGasRefillRequest( context: context, @@ -380,7 +382,7 @@ class _GasRefillRequestFormState extends State { // Lookup? _requestedQuantity; // final TextEditingController _commentController = TextEditingController(); // GasRefillProvider? _gasRefillProvider; -// List _files = []; +// List attachments = []; // // static List gasQuantity = [ // Lookup(name: "1", id: 1, value: 1), @@ -397,7 +399,7 @@ class _GasRefillRequestFormState extends State { // _currentDetails = widget.gasRefillDetails ?? GasRefillDetails(); // _gasModel = widget.gasModel ?? GasRefillModel(gasRefillDetails: []); // if (_gasModel.gasRefillAttachments != null && _gasModel.gasRefillAttachments!.isNotEmpty) { -// _files.addAll(_gasModel.gasRefillAttachments!.map((e) => File(e.attachmentName!)).toList()); +// attachments.addAll(_gasModel.gasRefillAttachments!.map((e) => File(e.attachmentName!)).toList()); // } // if (widget.gasRefillDetails != null && widget.gasRefillDetails?.requestedQty != null) { // _requestedQuantity = Lookup(name: "1", id: 1, value: int.parse(widget.gasRefillDetails!.requestedQty!.toStringAsFixed(0))); @@ -561,7 +563,7 @@ class _GasRefillRequestFormState extends State { // 8.height, // MultiFilesPicker( // label: context.translation.attachFiles, -// files: _files, +// files: attachments, // buttonColor: AppColor.black10, // onlyImages: false, // buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), @@ -582,7 +584,7 @@ class _GasRefillRequestFormState extends State { // _gasModel.gasRefillDetails = []; // _gasModel.gasRefillDetails?.add(_currentDetails); // _gasModel.gasRefillAttachments = []; -// for (var item in _files) { +// for (var item in attachments) { // _gasModel.gasRefillAttachments?.add(GasRefillAttachments( // id: 0, gasRefillId: _gasModel.id ?? 0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path)); // } diff --git a/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart b/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart index d30c90c1..a65bf77b 100644 --- a/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart +++ b/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart @@ -76,10 +76,10 @@ class _MonthlyFragmentState extends State { day: day, fill: snapshot.calendarRequests?.requestsDetails?.firstWhere( (element) => (element.date != null) && (DateTime.tryParse(element.date!)?.difference(dateTime).inDays == 0), - orElse: null, + orElse: null, ) != null, - ).toShimmer(isShow: snapshot.isCalendarLoading); + ).toShimmer(isShow: snapshot.isCalendarLoading, context: context); }, ), daysOfWeekHeight: 35.toScreenHeight, diff --git a/lib/new_views/pages/land_page/create_request-type_bottomsheet.dart b/lib/new_views/pages/land_page/create_request-type_bottomsheet.dart index 7c412338..971ce78b 100644 --- a/lib/new_views/pages/land_page/create_request-type_bottomsheet.dart +++ b/lib/new_views/pages/land_page/create_request-type_bottomsheet.dart @@ -23,6 +23,7 @@ class CreateRequestTypeBottomSheet extends StatelessWidget { return Container( padding: const EdgeInsets.all(16.0), width: double.infinity, + color: AppColor.background(context), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -63,13 +64,13 @@ class CreateRequestTypeBottomSheet extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Icon( + Icon( Icons.add_circle, - color: AppColor.neutral120, + color: AppColor.iconColor(context), size: 32, ), //24.height, - label.bodyText2(context).custom(color: AppColor.black20), + label.bodyText2(context).custom(color:context.isDark?Colors.white: AppColor.black20), ], ), ), diff --git a/lib/new_views/pages/login_page.dart b/lib/new_views/pages/login_page.dart index 53ac8d78..304daf92 100644 --- a/lib/new_views/pages/login_page.dart +++ b/lib/new_views/pages/login_page.dart @@ -107,11 +107,11 @@ class _LoginPageState extends State { AppTextFormField( initialValue: _user.userName ?? "", controller: userNameController, - backgroundColor: AppColor.white20, + backgroundColor: AppColor.fieldBgColor(context), validator: (value) => Validator.hasValue(value!) ? null : context.translation.requiredField, labelText: context.translation.username, - style: TextStyle(fontWeight: FontWeight.w500, fontSize: 12, color: Color(0xff3B3D4A)), - labelStyle: TextStyle(fontWeight: FontWeight.w500, fontSize: 11, color: Color(0xff767676)), + style: TextStyle(fontWeight: FontWeight.w500, fontSize: 12, color:context .isDark?Colors.white: const Color(0xff3B3D4A)), + labelStyle: TextStyle(fontWeight: FontWeight.w500, fontSize: 11, color:context .isDark?Colors.white:const Color(0xff767676)), textInputType: TextInputType.text, showWithoutDecoration: true, contentPadding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 12.toScreenHeight), @@ -124,9 +124,9 @@ class _LoginPageState extends State { initialValue: _user.password ?? "", showWithoutDecoration: true, labelText: context.translation.password, - backgroundColor: AppColor.white20, - style: TextStyle(fontWeight: FontWeight.w500, fontSize: 12, color: Color(0xff3B3D4A)), - labelStyle: TextStyle(fontWeight: FontWeight.w500, fontSize: 11, color: Color(0xff767676)), + backgroundColor: AppColor.fieldBgColor(context), + style: TextStyle(fontWeight: FontWeight.w500, fontSize: 12, color: context .isDark?Colors.white: const Color(0xff3B3D4A)), + labelStyle: TextStyle(fontWeight: FontWeight.w500, fontSize: 11, color: context .isDark?Colors.white: const Color(0xff767676)), contentPadding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 12.toScreenHeight), obscureText: !_passwordVisible, suffixIcon: Icon( diff --git a/lib/new_views/swipe_module/dialoge/acknowledge_work_dialog.dart b/lib/new_views/swipe_module/dialoge/acknowledge_work_dialog.dart index b89f22af..916d1b06 100644 --- a/lib/new_views/swipe_module/dialoge/acknowledge_work_dialog.dart +++ b/lib/new_views/swipe_module/dialoge/acknowledge_work_dialog.dart @@ -21,7 +21,7 @@ class AcknowledgeWorkDialog extends StatelessWidget { @override Widget build(BuildContext context) { return Dialog( - backgroundColor: Colors.white, + backgroundColor: AppColor.background(context), shape: const RoundedRectangleBorder(), insetPadding: const EdgeInsets.only(left: 21, right: 21), child: Padding( @@ -30,11 +30,11 @@ class AcknowledgeWorkDialog extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - const Text( + Text( "Confirm", - style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: Colors.black87, height: 35 / 24, letterSpacing: -0.96), + style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: AppColor.headingTextColor(context), height: 35 / 24, letterSpacing: -0.96), ).paddingOnly(top: 16, bottom: 8), - message != null ? message!.heading5(context).custom(color: AppColor.neutral50) : const SizedBox(), + message != null ? message!.heading5(context).custom(color: AppColor.textColor(context)) : const SizedBox(), 28.height, Row( children: [ 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 a605cfd0..33085f32 100644 --- a/lib/views/pages/device_transfer/create__device_transfer_request.dart +++ b/lib/views/pages/device_transfer/create__device_transfer_request.dart @@ -14,9 +14,11 @@ import 'package:test_sa/models/device/asset.dart'; import 'package:test_sa/models/device/asset_transfer_attachment.dart'; import 'package:test_sa/models/device/device_transfer.dart'; import 'package:test_sa/models/enums/user_types.dart'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/new_models/department.dart'; import 'package:test_sa/models/new_models/floor.dart'; import 'package:test_sa/models/service_request/pending_service_request_model.dart'; +import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart'; import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.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'; @@ -49,7 +51,7 @@ class _CreateDeviceTransferRequestState extends State _scaffoldKey = GlobalKey(); Asset _assetDestination = Asset(); Asset? _pickedAsset; - final List _deviceImages = []; + final List attachments = []; bool isInternal = true; PendingAssetServiceRequest? pendingAssetServiceRequest; @@ -77,8 +79,9 @@ class _CreateDeviceTransferRequestState extends State attachement = []; - for (var item in _deviceImages) { - attachement.add(AssetTransferAttachment(id: 0, attachmentName: "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}")); + for (var item in attachments) { + 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; @@ -144,7 +147,7 @@ class _CreateDeviceTransferRequestState extends State { // ? (!(_model?.senderMachineStatusName?.toLowerCase()?.contains("close") ?? false) && !(_model?.senderMachineStatusName?.toLowerCase()?.contains("complete") ?? false)) // : (!(_model?.receiverMachineStatusName?.toLowerCase()?.contains("close") ?? false) && !(_model?.receiverMachineStatusName?.toLowerCase()?.contains("complete") ?? false))) // - "edit".toSvgAsset(height: 48, width: 48).onPress(() async { + "edit".toSvgAsset(height: 48, width: 48).onPress(() async { bool isReload = (await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdateDeviceTransfer(model: _model!, isSender: isSender)))) as bool; if (isReload ?? false) { setState(() {}); diff --git a/lib/views/pages/device_transfer/update_device_transfer.dart b/lib/views/pages/device_transfer/update_device_transfer.dart index 3f491f86..7e93a34a 100644 --- a/lib/views/pages/device_transfer/update_device_transfer.dart +++ b/lib/views/pages/device_transfer/update_device_transfer.dart @@ -13,6 +13,7 @@ import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/helper/utils.dart'; import 'package:test_sa/models/device/asset_transfer_attachment.dart'; import 'package:test_sa/models/device/device_transfer.dart'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/new_models/assigned_employee.dart'; import 'package:test_sa/models/new_models/assistant_employee.dart'; import 'package:test_sa/models/timer_model.dart'; @@ -53,7 +54,7 @@ class _UpdateDeviceTransferState extends State { final GlobalKey _formKey = GlobalKey(); final GlobalKey _scaffoldKey = GlobalKey(); - List _files = []; + List attachments = []; _update({required int status}) async { _formKey.currentState!.save(); @@ -110,13 +111,9 @@ class _UpdateDeviceTransferState extends State { _formModel.assetTransferEngineerTimers = _formModel.receiverVisitTimers; } try { - for (var file in _files) { - String attachmentName = file.path; - if (attachmentName.contains("/")) { - attachmentName = file.path.split("/").last; - attachmentName = "$attachmentName|${base64Encode(file.readAsBytesSync())}"; - } - _formModel.assetTransferAttachments!.add(AssetTransferAttachment(id: 0, attachmentName: attachmentName)); + for (var item in attachments) { + String fileName = ServiceRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? ''; + _formModel.assetTransferAttachments!.add(AssetTransferAttachment(id: item.id, attachmentName: fileName)); _formModel.attachments = _formModel.assetTransferAttachments; } } catch (error) { @@ -202,7 +199,7 @@ class _UpdateDeviceTransferState extends State { @override void initState() { _formModel.fromDetails(widget.model); - _files = widget.model.assetTransferAttachments?.map((e) => File(e.attachmentName!)).toList() ?? []; + attachments = widget.model.assetTransferAttachments?.map((e) => GenericAttachmentModel(id: e.id?.toInt()??0, name: e.attachmentName!)).toList() ?? []; super.initState(); } @@ -251,9 +248,10 @@ class _UpdateDeviceTransferState extends State { AppTextFormField( initialValue: widget.isSender ? _formModel.senderComment ?? "" : _formModel.receiverComment ?? "", labelText: context.translation.technicalComment, - labelStyle: AppTextStyles.tinyFont.copyWith(color: AppColor.neutral20), + hintStyle: AppTextStyles.tinyFont.copyWith(color: context.isDark?AppColor.white10:AppColor.black10), + labelStyle: AppTextStyles.tinyFont.copyWith(color: context.isDark?AppColor.white10:AppColor.black10), textInputType: TextInputType.multiline, - backgroundColor: AppColor.neutral100, + backgroundColor: AppColor.fieldBgColor(context), showShadow: false, alignLabelWithHint: true, onSaved: (value) { @@ -261,9 +259,9 @@ class _UpdateDeviceTransferState extends State { }, ), 8.height, - MultiFilesPicker( + AttachmentPicker( label: context.translation.attachFiles, - files: _files, + attachment: attachments, buttonColor: AppColor.black10, onlyImages: false, buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), @@ -274,9 +272,9 @@ class _UpdateDeviceTransferState extends State { 16.height, DeviceTransferAssistantEmployeeList( assetId: _formModel.assetId, - createdDate: _formModel.createdDate??'', - assistantEmployeeList: widget.isSender?_formModel.assetTransferAssistantEmployeesSender:_formModel.assetTransferAssistantEmployeesReceiver, - cardPadding: 0, + createdDate: _formModel.createdDate ?? '', + assistantEmployeeList: widget.isSender ? _formModel.assetTransferAssistantEmployeesSender : _formModel.assetTransferAssistantEmployeesReceiver, + cardPadding: 0, onListChanged: (updatedList) { setState(() { _formModel.assistantEmployList = updatedList; @@ -287,13 +285,14 @@ class _UpdateDeviceTransferState extends State { ), ).expanded, FooterActionButton.footerContainer( + context: context, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ AppFilledButton( label: context.translation.save, - buttonColor: AppColor.white60, - textColor: AppColor.black10, + buttonColor: context.isDark?AppColor.neutral70:AppColor.white60, + textColor: context.isDark?AppColor.white10:AppColor.black10, onPressed: () => _update(status: 0), ).expanded, 12.width, @@ -343,7 +342,7 @@ class _UpdateDeviceTransferState extends State { width: double.infinity, enabled: isTimerEnable, decoration: BoxDecoration( - color: AppColor.neutral100, + color: AppColor.fieldBgColor(context), borderRadius: BorderRadius.circular(10), ), pickerTimer: _formModel.deviceTimePicker, @@ -370,7 +369,7 @@ class _UpdateDeviceTransferState extends State { 8.width, Text( ServiceRequestUtils.formatTimerDuration(totalWorkingHours.round()), - style: AppTextStyles.bodyText.copyWith(color: AppColor.neutral50, fontWeight: FontWeight.w600), + style: AppTextStyles.bodyText.copyWith(color: context.isDark?AppColor.white10: AppColor.neutral50, fontWeight: FontWeight.w600), ), ], ), @@ -380,16 +379,12 @@ class _UpdateDeviceTransferState extends State { } } - - - - class DeviceTransferAssistantEmployeeList extends StatefulWidget { final List? assistantEmployeeList; final ValueChanged>? onListChanged; - final double ?cardPadding; - final dynamic assetId; - final String createdDate; + final double? cardPadding; + final dynamic assetId; + final String createdDate; const DeviceTransferAssistantEmployeeList({ super.key, @@ -443,13 +438,13 @@ class _DeviceTransferAssistantEmployeeListState extends State onUpdate((model) => model.techComment = value), @@ -664,8 +659,7 @@ class EmployeeCard extends StatelessWidget { ], ) ], - ).toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16, vertical: 12)) - .paddingOnly(bottom: 12); + ).toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16, vertical: 12)).paddingOnly(bottom: 12); } } diff --git a/lib/views/pages/user/gas_refill/update_gas_refill_request.dart b/lib/views/pages/user/gas_refill/update_gas_refill_request.dart index 46bbf265..b4d21ab8 100644 --- a/lib/views/pages/user/gas_refill/update_gas_refill_request.dart +++ b/lib/views/pages/user/gas_refill/update_gas_refill_request.dart @@ -11,6 +11,7 @@ import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/timer_model.dart'; import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart'; @@ -56,7 +57,7 @@ class _UpdateGasRefillRequestState extends State { bool _firstTime = true; Lookup? _deliveredQuantity; - List _attachments = []; + List _attachments = []; static List deliveredQuantity = [ Lookup(name: "1", id: 1, value: 1), @@ -82,7 +83,7 @@ class _UpdateGasRefillRequestState extends State { } catch (ex) {} } if (_formModel.gasRefillAttachments != null && _formModel.gasRefillAttachments!.isNotEmpty) { - _attachments.addAll(_formModel.gasRefillAttachments!.map((e) => File(e.attachmentName!)).toList()); + _attachments.addAll(_formModel.gasRefillAttachments!.map((e) => GenericAttachmentModel(id:e.id,name:e.attachmentName!)).toList()); } } @@ -153,8 +154,9 @@ class _UpdateGasRefillRequestState extends State { }); _formModel.gasRefillAttachments = []; for (var item in _attachments) { + String fileName = ServiceRequestUtils.isLocalUrl(item.name??'') ? ("${item.name??''.split("/").last}|${base64Encode(File(item.name??'').readAsBytesSync())}") :item.name??''; _formModel.gasRefillAttachments?.add(GasRefillAttachments( - id: 0, gasRefillId: _formModel.id ?? 0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path)); + id: item.id, gasRefillId: _formModel.id ?? 0, attachmentName: fileName)); } await _gasRefillProvider?.updateGasRefill(status: status, model: _formModel).then((success) { @@ -214,81 +216,85 @@ class _UpdateGasRefillRequestState extends State { key: _scaffoldKey, body: Form( key: _formKey, - child: LoadingManager( - isLoading: _isLoading, - isFailedLoading: false, - stateCode: 200, - onRefresh: () async {}, - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - 8.height, - SingleItemDropDownMenu( - context: context, - title: context.translation.quantity, - backgroundColor: AppColor.neutral100, - showShadow: false, - showAsBottomSheet: true, - initialValue: _deliveredQuantity, - staticData: deliveredQuantity, - onSelect: (value) { - _deliveredQuantity = value; - _currentDetails.deliverdQty = value!.value; - }, - ), - 8.height, - _timerWidget(context, totalWorkingHours), - 8.height, - AppTextFormField( - labelText: context.translation.technicalComment, - textInputType: TextInputType.multiline, - alignLabelWithHint: true, - backgroundColor: AppColor.neutral100, - showShadow: false, - controller: _commentController, - onChange: (value) { - _formModel.techComment = value; - }, - onSaved: (value) {}, - ), - 16.height, - MultiFilesPicker( - label: context.translation.attachFiles, - files: _attachments, - buttonColor: AppColor.black10, - onlyImages: false, - buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), - ), - 8.height, - ], - ).toShadowContainer(context), - ).expanded, - FooterActionButton.footerContainer( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - AppFilledButton( - label: context.translation.save, - buttonColor: AppColor.white60, - textColor: AppColor.black10, - onPressed: () => _onSubmit(context, 0), - ).expanded, - 12.width, - AppFilledButton( - label: context.translation.complete, - buttonColor: AppColor.primary10, - onPressed: () => _onSubmit(context, 1), - ).expanded, - ], + child: LoadingManager( + isLoading: _isLoading, + isFailedLoading: false, + stateCode: 200, + onRefresh: () async {}, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + 8.height, + SingleItemDropDownMenu( + context: context, + title: context.translation.quantity, + backgroundColor: AppColor.fieldBgColor(context), + showShadow: false, + showAsBottomSheet: true, + initialValue: _deliveredQuantity, + staticData: deliveredQuantity, + onSelect: (value) { + _deliveredQuantity = value; + _currentDetails.deliverdQty = value!.value; + }, + ), + 8.height, + _timerWidget(context, totalWorkingHours), + 8.height, + AppTextFormField( + labelText: context.translation.technicalComment, + textInputType: TextInputType.multiline, + hintStyle: TextStyle(color: context.isDark?AppColor.white10:AppColor.black10), + labelStyle: TextStyle(color: context.isDark?AppColor.white10:AppColor.black10), + alignLabelWithHint: true, + backgroundColor: AppColor.fieldBgColor(context), + showShadow: false, + controller: _commentController, + onChange: (value) { + _formModel.techComment = value; + }, + onSaved: (value) {}, + ), + 16.height, + AttachmentPicker( + label: context.translation.attachFiles, + attachment: _attachments, + buttonColor: AppColor.black10, + onlyImages: false, + buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), + ), + 8.height, + ], + ).toShadowContainer(context), + ).expanded, + FooterActionButton.footerContainer( + context: context, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + AppFilledButton( + label: context.translation.save, + buttonColor: context.isDark?AppColor.neutral70:AppColor.white60, + textColor: context.isDark?AppColor.white10:AppColor.black10, + onPressed: () => _onSubmit(context, 0), + ).expanded, + 12.width, + AppFilledButton( + label: context.translation.complete, + buttonColor: AppColor.primary10, + onPressed: () => _onSubmit(context, 1), + ).expanded, + ], + ), ), - ), - ], - )), + ], + )), + ), ).handlePopScope( cxt: context, @@ -311,7 +317,8 @@ class _UpdateGasRefillRequestState extends State { }, width: double.infinity, decoration: BoxDecoration( - color: AppColor.neutral100, + color: AppColor.fieldBgColor(context), + // color: AppColor.neutral100, borderRadius: BorderRadius.circular(10), ), timerProgress: (isRunning) {}, @@ -330,7 +337,7 @@ class _UpdateGasRefillRequestState extends State { 8.width, Text( ServiceRequestUtils.formatTimerDuration(totalWorkingHours.round()), - style: AppTextStyles.bodyText.copyWith(color: AppColor.neutral50, fontWeight: FontWeight.w600), + style: AppTextStyles.bodyText.copyWith(color:context.isDark?AppColor.white10: AppColor.neutral50, fontWeight: FontWeight.w600), ), ], ), diff --git a/lib/views/pages/user/profile_page.dart b/lib/views/pages/user/profile_page.dart index af0a89fb..22082ca1 100644 --- a/lib/views/pages/user/profile_page.dart +++ b/lib/views/pages/user/profile_page.dart @@ -175,7 +175,7 @@ class _ProfilePageState extends State { 16.height, AppFilledButton( label: "Update Information", - buttonColor: AppColor.neutral50, + buttonColor: context.isDark? AppColor.primary10:AppColor.neutral50, onPressed: () { context.showBottomSheet( UpdateUserContactInfoBottomSheet( diff --git a/lib/views/pages/user/requests/create_service_request_page.dart b/lib/views/pages/user/requests/create_service_request_page.dart index cf538e42..9eb6c32b 100644 --- a/lib/views/pages/user/requests/create_service_request_page.dart +++ b/lib/views/pages/user/requests/create_service_request_page.dart @@ -10,8 +10,10 @@ import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/service_request/pending_service_request_model.dart'; import 'package:test_sa/models/service_request/service_request.dart'; +import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/providers/service_request_providers/equipment_status_provider.dart'; import 'package:test_sa/providers/service_request_providers/requested_through_provider.dart'; @@ -45,7 +47,7 @@ class CreateServiceRequestPageState extends State { late SettingProvider _settingProvider; late ServiceRequestsProvider _serviceRequestsProvider; late ServiceRequest _serviceRequest; - final List _deviceImages = []; + final List attachments = []; final bool _isLoading = false; bool _showDatePicker = false; final GlobalKey _formKey = GlobalKey(); @@ -59,7 +61,7 @@ class CreateServiceRequestPageState extends State { _commentController = TextEditingController(); if (widget.serviceRequest != null) { _serviceRequest = widget.serviceRequest!; - _deviceImages.addAll(_serviceRequest.devicePhotos!.map((e) => File(e)).toList()); + attachments.addAll(_serviceRequest.devicePhotos!.map((e) => GenericAttachmentModel(name: e)).toList()); _showDatePicker = _serviceRequest.firstAction != null && _serviceRequest.firstAction?.name == "Need a visit"; if (_showDatePicker && _serviceRequest.visitDate != null) { _dateTime = DateTime.tryParse(_serviceRequest.visitDate!); @@ -77,7 +79,7 @@ class CreateServiceRequestPageState extends State { // ServiceRequest request = await _serviceRequestsProvider.getServiceRequestObjectById(requestId: id) ?? ""; // _serviceRequest = request; // _device = _serviceRequest.device; - // _deviceImages.addAll(_serviceRequest.devicePhotos.map((e) { + // attachments.addAll(_serviceRequest.devicePhotos.map((e) { // return File(e); // }).toList()); // _showDatePicker = _serviceRequest.firstAction != null && _serviceRequest.firstAction.name == "Need a visit"; @@ -190,7 +192,7 @@ class CreateServiceRequestPageState extends State { _serviceRequest.priority = snapshot.items.firstWhere((element) => element.value == 0, orElse: null); } setState(() {}); - }).toShimmer(isShow: snapshot.loading), + }).toShimmer(isShow: snapshot.loading,context: context), ); }), ], @@ -239,12 +241,12 @@ class CreateServiceRequestPageState extends State { ], ) ], - ).toShimmer(isShow: snapshot.loading), + ).toShimmer(isShow: snapshot.loading,context: context), ], ); }), 16.height, - MultiFilesPicker(label: context.translation.attachImage, files: _deviceImages, showAsGrid: true), + AttachmentPicker(label: context.translation.attachImage, attachment: attachments, showAsGrid: true), ], ).toShadowContainer(context), @@ -386,7 +388,8 @@ class CreateServiceRequestPageState extends State { // return; // } - _serviceRequest.devicePhotos = _deviceImages.map((e) => _isLocalUrl(e.path) ? "${e.path.split("/").last}|${base64Encode(e.readAsBytesSync())}" : e.path).toList(); + + _serviceRequest.devicePhotos = attachments.map((item) => ServiceRequestUtils.isLocalUrl(item.name??'') ? "${item.name?.split("/").last}|${base64Encode(File(item.name??'').readAsBytesSync())}" : item.name??'').toList(); if (_serviceRequest.audio != null) { if (_isLocalUrl(_serviceRequest.audio!)) { final File file = File(_serviceRequest.audio!); diff --git a/lib/views/pages/user/requests/work_order/create_service_report.dart b/lib/views/pages/user/requests/work_order/create_service_report.dart index 2c7e7fc9..f1ec7b49 100644 --- a/lib/views/pages/user/requests/work_order/create_service_report.dart +++ b/lib/views/pages/user/requests/work_order/create_service_report.dart @@ -14,8 +14,10 @@ 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/device/asset.dart'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/models/service_request/service_report.dart'; import 'package:test_sa/models/service_request/service_request.dart'; +import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/providers/service_request_providers/equipment_status_provider.dart'; import 'package:test_sa/providers/service_request_providers/loan_availability_provider.dart'; @@ -61,7 +63,7 @@ class _CreateServiceReportState extends State with TickerPr bool _isLoading = false; List _spareParts = []; - final List _files = []; + final List attachments = []; final GlobalKey _formKey = GlobalKey(); final GlobalKey _scaffoldKey = GlobalKey(); final TextEditingController _faultController = TextEditingController(); @@ -363,7 +365,7 @@ class _CreateServiceReportState extends State with TickerPr }, ), 8.height, - MultiFilesPicker(label: context.translation.attachImage, files: _files), + AttachmentPicker(label: context.translation.attachImage, attachment: attachments), 8.height, ESignature( title: context.translation.engSign, @@ -407,9 +409,10 @@ class _CreateServiceReportState extends State with TickerPr } _formKey.currentState!.save(); _serviceReport.attachmentsWorkOrder ??= []; - if (_files.isEmpty) _serviceReport.attachmentsWorkOrder = []; - for (var file in _files) { - _serviceReport.attachmentsWorkOrder!.add(Attachment(id: 0, name: "${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}")); + if (attachments.isEmpty) _serviceReport.attachmentsWorkOrder = []; + for (var item in attachments) { + String fileName = ServiceRequestUtils.isLocalUrl(item.name??'') ? ("${item.name??''.split("/").last}|${base64Encode(File(item.name??'').readAsBytesSync())}") :item.name??''; + _serviceReport.attachmentsWorkOrder!.add(Attachment(id: item.id, name: fileName)); } final user = Provider.of(context, listen: false).user!; await _serviceRequestsProvider.createServiceReport(context, report: _serviceReport, request: widget.request, user: user); diff --git a/lib/views/pages/user/update_user_contact_info_bottomsheet.dart b/lib/views/pages/user/update_user_contact_info_bottomsheet.dart index 2330a385..c6ba203b 100644 --- a/lib/views/pages/user/update_user_contact_info_bottomsheet.dart +++ b/lib/views/pages/user/update_user_contact_info_bottomsheet.dart @@ -50,7 +50,7 @@ class _UpdateUserContactInfoBottomSheetState extends State extends State> { Widget build(BuildContext context) { return Container( height: MediaQuery.of(context).size.height * .7, + color: Theme.of(context).scaffoldBackgroundColor, padding: const EdgeInsets.all(21), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -94,6 +95,9 @@ class _SelectionBottomSheetState extends State> { decoration: InputDecoration( hintText: 'Search by name', labelText: 'Search', + labelStyle: TextStyle(color: AppColor.textColor(context)), + filled: true, + fillColor: AppColor.fieldBgColor(context), hintStyle: const TextStyle(fontSize: 14), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: AppColor.blueStatus(context), width: 2.0), @@ -112,21 +116,33 @@ class _SelectionBottomSheetState extends State> { child: ListView.builder( itemCount: filteredList?.length, padding: const EdgeInsets.only(top: 8), - itemBuilder: (cxt, index) => RadioListTile( - // Specify type for RadioListTile - value: filteredList![index], - dense: true, - contentPadding: EdgeInsets.zero, - groupValue: _selectedValue, - activeColor: Colors.black87, - onChanged: (value) { - _selectedValue = value; - searchFocusNode.unfocus(); - setState(() {}); - }, - title: Text( - widget.builderString(filteredList![index]).cleanupWhitespace.capitalizeFirstOfEach ?? "", - style: Theme.of(context).textTheme.bodyLarge, + itemBuilder: (cxt, index) => Theme( + data: Theme.of(context).copyWith( + radioTheme: RadioThemeData( + fillColor: MaterialStateColor.resolveWith((states) { + if (states.contains(MaterialState.selected)) { + return AppColor.textColor(context); // Active color + } + return Colors.grey; // Inactive color + }), + ), + ), + child: RadioListTile( + // Specify type for RadioListTile + value: filteredList![index], + dense: true, + contentPadding: EdgeInsets.zero, + groupValue: _selectedValue, + activeColor: AppColor.textColor(context), + onChanged: (value) { + _selectedValue = value; + searchFocusNode.unfocus(); + setState(() {}); + }, + title: Text( + widget.builderString(filteredList![index]).cleanupWhitespace.capitalizeFirstOfEach ?? "", + style: Theme.of(context).textTheme.bodyLarge, + ), ), ), ), diff --git a/lib/views/widgets/equipment/asset_picker.dart b/lib/views/widgets/equipment/asset_picker.dart index 8a3b35e2..a9d8e5f0 100644 --- a/lib/views/widgets/equipment/asset_picker.dart +++ b/lib/views/widgets/equipment/asset_picker.dart @@ -164,7 +164,7 @@ class AssetPicker extends StatelessWidget { color: Colors.black87, decoration: TextDecoration.none, ), - ).toShimmer(isShow: showLoading).expanded, + ).toShimmer(isShow: showLoading,context: context).expanded, const Icon( Icons.info, color: Color(0xff7D859A), @@ -195,10 +195,10 @@ class AssetPicker extends StatelessWidget { ], ), 8.height, - "${context.translation.assetNo}: ${device!.assetNumber}".bodyText2(context).toShimmer(isShow: showLoading), + "${context.translation.assetNo}: ${device!.assetNumber}".bodyText2(context).toShimmer(isShow: showLoading,context: context), 2.height, // "${context.translation.manufacture}: ${device.modelDefinition?.manufacturerName}".bodyText(context), - "${context.translation.model}: ${device!.modelDefinition?.modelName}".bodyText2(context).toShimmer(isShow: showLoading), + "${context.translation.model}: ${device!.modelDefinition?.modelName}".bodyText2(context).toShimmer(isShow: showLoading,context: context), // "${context.translation.serialNumber}: ${device.assetNumber}".bodyText(context), // const Divider().defaultStyle(context), // "${context.translation.department}: ${device.department?.departmentName}".bodyText(context), diff --git a/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart b/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart index 466c3238..dbfe8022 100644 --- a/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart +++ b/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart @@ -84,12 +84,15 @@ class _SelectionBottomSheetState extends State> SearchBar( focusNode: searchFocusNode, elevation: WidgetStateProperty.all(0), - leading: const Icon(Icons.search, color: AppColor.neutral50), + backgroundColor: WidgetStateProperty.all( + AppColor.fieldBgColor(context), // Your custom background color + ), + leading: Icon(Icons.search, color: AppColor.iconColor(context)), textStyle: WidgetStateProperty.all( - const TextStyle(color: AppColor.neutral50, fontSize: 16.0), + TextStyle(color: AppColor.textColor(context), fontSize: 16.0), ), hintStyle: WidgetStateProperty.all( - const TextStyle(color: AppColor.neutral20, fontSize: 14.0), + TextStyle(color: AppColor.textColor(context), fontSize: 14.0), ), hintText: 'Search by name', onChanged: (queryString) { @@ -102,22 +105,34 @@ class _SelectionBottomSheetState extends State> child: ListView.builder( itemCount: filteredList?.length, padding: EdgeInsets.zero, - itemBuilder: (cxt, index) => RadioListTile( - // Specify type for RadioListTile - value: filteredList![index], - dense: true, - contentPadding: const EdgeInsets.only(left: 16, right: 16), - groupValue: _selectedValue, - activeColor: Colors.black87, - hoverColor: Colors.transparent, - onChanged: (value) { - _selectedValue = value; - searchFocusNode.unfocus(); - setState(() {}); - }, - title: Text( - widget.builderString(filteredList![index]).cleanupWhitespace.capitalizeFirstOfEach ?? "", - style: Theme.of(context).textTheme.bodyLarge, + 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, + ), ), ), ), diff --git a/lib/views/widgets/images/multi_image_picker.dart b/lib/views/widgets/images/multi_image_picker.dart index ee34e2fc..60035bd9 100644 --- a/lib/views/widgets/images/multi_image_picker.dart +++ b/lib/views/widgets/images/multi_image_picker.dart @@ -8,6 +8,7 @@ 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'; +import 'package:test_sa/models/generic_attachment_model.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import '../../../new_views/common_widgets/app_dashed_button.dart'; @@ -17,7 +18,7 @@ class MultiFilesPicker extends StatefulWidget { final String label; final bool error; final List files; - final List attachment; + final List attachment; final bool enabled, onlyImages; double? buttonHeight; @@ -29,7 +30,7 @@ class MultiFilesPicker extends StatefulWidget { MultiFilesPicker( {Key? key, this.files = const [], - this.attachment = const [], + this.attachment = const [], required this.label, this.error = false, this.buttonHeight, @@ -248,271 +249,272 @@ class AttachmentModel { } Map toJson() { - return {'id': id, 'file': file?.path}; + return { + 'id': id, + 'file': file?.path, + }; } } -// class AttachmentPicker extends StatefulWidget { -// final String label; -// final bool error; -// final List attachment; -// -// final bool enabled, onlyImages; -// double? buttonHeight; -// Widget? buttonIcon; -// Color? buttonColor; -// final Function(List)? onChange; -// final bool showAsGrid; -// -// AttachmentPicker( -// {Key? key, -// this.attachment = const [], -// required this.label, -// this.error = false, -// this.buttonHeight, -// this.buttonIcon, -// this.enabled = true, -// this.onlyImages = false, -// this.onChange, -// this.showAsGrid = false, -// this.buttonColor}) -// : super(key: key); -// -// @override -// State createState() => _AttachmentPickerState(); -// } -// -// class _AttachmentPickerState extends State { -// @override -// Widget build(BuildContext context) { -// return Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// AppDashedButton( -// title: widget.label, -// height: widget.buttonHeight, -// buttonColor: widget.buttonColor, -// icon: widget.buttonIcon, -// onPressed: (widget.enabled == false) -// ? () {} -// : widget.showAsGrid -// ? showFileSourceSheet -// : onFilePicker), -// 16.height, -// if (widget.attachment.isNotEmpty) -// Wrap( -// spacing: 8.toScreenWidth, -// children: List.generate( -// widget.attachment.length, -// (index) { -// File image = widget.attachment[index].file!; -// return MultiFilesPickerItem( -// file: image, -// enabled: widget.enabled, -// onRemoveTap: (image) { -// if (!widget.enabled) { -// return; -// } -// widget.attachment.remove(image); -// if (widget.onChange != null) { -// widget.onChange!(widget.attachment); -// } -// setState(() {}); -// }, -// ); -// }, -// ), -// ), -// ], -// ); -// } -// -// fromFilePicker() async { -// FilePickerResult? result = await FilePicker.platform.pickFiles( -// type: FileType.custom, -// allowMultiple: true, -// allowedExtensions: widget.onlyImages ? ['jpg', 'jpeg', 'png'] : ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xlsx', 'pptx'], -// ); -// if (result != null) { -// for (var path in result.paths) { -// widget.attachment.add(AttachmentModel(0, File(path!))); -// } -// setState(() {}); -// } -// } -// -// void showFileSourceSheet() async { -// if (widget.attachment.length >= 5) { -// Fluttertoast.showToast(msg: context.translation.maxImagesNumberIs5); -// return; -// } -// -// ImageSource source = (await showModalBottomSheet( -// context: context, -// shape: const RoundedRectangleBorder( -// borderRadius: BorderRadius.vertical( -// top: Radius.circular(20), -// ), -// ), -// clipBehavior: Clip.antiAliasWithSaveLayer, -// builder: (BuildContext context) => Column( -// mainAxisSize: MainAxisSize.min, -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// "Attach File".heading4(context), -// 12.height, -// GridView( -// padding: const EdgeInsets.all(0), -// shrinkWrap: true, -// physics: const NeverScrollableScrollPhysics(), -// gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1, crossAxisSpacing: 12, mainAxisSpacing: 12), -// children: [ -// gridItem(Icons.camera_enhance_rounded, context.translation.pickFromCamera).onPress(() => Navigator.of(context).pop(ImageSource.camera)), -// gridItem(Icons.image_rounded, context.translation.pickFromGallery).onPress(() => Navigator.of(context).pop(ImageSource.gallery)), -// gridItem(Icons.file_present_rounded, context.translation.pickFromFiles).onPress(() async { -// await fromFilePicker(); -// Navigator.pop(context); -// }), -// ], -// ), -// 12.height, -// ], -// ).paddingAll(21), -// )) as ImageSource; -// -// final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800); -// -// if (pickedFile != null) { -// File fileImage = File(pickedFile.path); -// widget.attachment.add(AttachmentModel(0, fileImage)); -// if (widget.onChange != null) { -// widget.onChange!(widget.attachment); -// } -// setState(() {}); -// } -// } -// -// Widget gridItem(IconData iconData, String title) { -// return Container( -// padding: const EdgeInsets.all(12), -// decoration: BoxDecoration( -// color: Colors.white, -// borderRadius: BorderRadius.circular(12), -// border: Border.all(color: const Color(0xffF1F1F1), width: 1), -// ), -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisAlignment: MainAxisAlignment.spaceBetween, -// children: [ -// Icon(iconData, color: const Color(0xff7D859A), size: 36), -// Text( -// title, -// style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w500), -// ), -// ], -// ), -// ); -// } -// -// onFilePicker() async { -// if (widget.attachment.length >= 5) { -// Fluttertoast.showToast(msg: context.translation.maxImagesNumberIs5); -// return; -// } -// ImageSource? source = await showModalBottomSheet( -// context: context, -// builder: (BuildContext context) { -// Widget listCard({required String icon, required String label, required VoidCallback onTap}) { -// return GestureDetector( -// onTap: onTap, -// child: Container( -// constraints: BoxConstraints(minWidth: 111.toScreenWidth, minHeight: 111.toScreenHeight), -// padding: EdgeInsets.symmetric(horizontal: 12.toScreenWidth, vertical: 12.toScreenHeight), -// decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), border: Border.all(width: 1, color: AppColor.white70)), -// child: Column( -// mainAxisSize: MainAxisSize.min, -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// icon.toSvgAsset(), -// 24.height, -// label.bodyText2(context).custom(color: AppColor.black20), -// ], -// ), -// ), -// ); -// } -// -// return Container( -// padding: const EdgeInsets.all(16.0), -// child: Row( -// mainAxisAlignment: MainAxisAlignment.spaceBetween, -// children: [ -// listCard( -// icon: 'camera_icon', -// label: '${context.translation.open}\n${context.translation.camera}', -// onTap: () { -// Navigator.of(context).pop(ImageSource.camera); -// }, -// ), -// listCard( -// icon: 'gallery_icon', -// label: '${context.translation.open}\n${context.translation.gallery}', -// onTap: () { -// Navigator.of(context).pop(ImageSource.gallery); -// }, -// ), -// listCard( -// icon: 'file_icon', -// label: '${context.translation.open}\n${context.translation.files}', -// onTap: () async { -// await fromFilePicker(); -// Navigator.pop(context); -// }, -// ), -// ], -// ), -// ); -// }, -// ); -// // ImageSource source = await showDialog( -// // context: context, -// // builder: (dialogContext) => CupertinoAlertDialog( -// // actions: [ -// // TextButton( -// // child: Text(context.translation.pickFromCamera), -// // onPressed: () { -// // Navigator.of(dialogContext).pop(ImageSource.camera); -// // }, -// // ), -// // TextButton( -// // child: Text(context.translation.pickFromGallery), -// // onPressed: () { -// // Navigator.of(dialogContext).pop(ImageSource.gallery); -// // }, -// // ), -// // TextButton( -// // child: Text(context.translation.pickFromFiles), -// // onPressed: () async { -// // await fromFilePicker(); -// // Navigator.pop(context); -// // }, -// // ), -// // ], -// // ), -// // ); -// if (source == null) return; -// -// final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800); -// -// if (pickedFile != null) { -// File fileImage = File(pickedFile.path); -// widget.attachment.add(AttachmentModel(0, fileImage)); -// if (widget.onChange != null) { -// widget.onChange!(widget.attachment); -// } -// setState(() {}); -// } -// -// setState(() {}); -// } -// } +class AttachmentPicker extends StatefulWidget { + final String label; + final bool error; + final List attachment; + + final bool enabled, onlyImages; + double? buttonHeight; + Widget? buttonIcon; + Color? buttonColor; + final Function(List)? onChange; + final bool showAsGrid; + + AttachmentPicker( + {Key? key, + this.attachment = const [], + required this.label, + this.error = false, + this.buttonHeight, + this.buttonIcon, + this.enabled = true, + this.onlyImages = false, + this.onChange, + this.showAsGrid = false, + this.buttonColor}) + : super(key: key); + + @override + State createState() => _AttachmentPickerState(); +} + +class _AttachmentPickerState extends State { + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppDashedButton( + title: widget.label, + height: widget.buttonHeight, + buttonColor: widget.buttonColor, + icon: widget.buttonIcon, + onPressed: (widget.enabled == false) + ? () {} + : widget.showAsGrid + ? showFileSourceSheet + : onFilePicker), + 16.height, + if (widget.attachment.isNotEmpty) + Wrap( + spacing: 8.toScreenWidth, + children: List.generate( + widget.attachment.length, + (index) { + File image = File(widget.attachment[index].name!); + return MultiFilesPickerItem( + file: image, + enabled: widget.enabled, + onRemoveTap: (image) { + if (!widget.enabled) { + return; + } + widget.attachment.removeAt(index); + if (widget.onChange != null) { + widget.onChange!(widget.attachment); + } + setState(() {}); + }, + ); + }, + ), + ), + ], + ); + } + + fromFilePicker() async { + FilePickerResult? result = await FilePicker.platform.pickFiles( + type: FileType.custom, + allowMultiple: true, + allowedExtensions: widget.onlyImages ? ['jpg', 'jpeg', 'png'] : ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xlsx', 'pptx'], + ); + if (result != null) { + for (var path in result.paths) { + widget.attachment.add(GenericAttachmentModel(id: 0,name: File(path!).path)); + } + if (widget.onChange != null) { + widget.onChange!(widget.attachment); + } + setState(() {}); + } + } +} + + ImageSource source = (await showModalBottomSheet( + context: context, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical( + top: Radius.circular(20), + ), + ), + clipBehavior: Clip.antiAliasWithSaveLayer, + builder: (BuildContext context) => Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "Attach File".heading4(context), + 12.height, + GridView( + padding: const EdgeInsets.all(0), + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1, crossAxisSpacing: 12, mainAxisSpacing: 12), + children: [ + gridItem(Icons.camera_enhance_rounded, context.translation.pickFromCamera).onPress(() => Navigator.of(context).pop(ImageSource.camera)), + gridItem(Icons.image_rounded, context.translation.pickFromGallery).onPress(() => Navigator.of(context).pop(ImageSource.gallery)), + gridItem(Icons.file_present_rounded, context.translation.pickFromFiles).onPress(() async { + await fromFilePicker(); + Navigator.pop(context); + }), + ], + ), + 12.height, + ], + ).paddingAll(21), + )) as ImageSource; + + final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800); + + if (pickedFile != null) { + File fileImage = File(pickedFile.path); + widget.attachment.add(GenericAttachmentModel(id: 0,name: fileImage.path)); + if (widget.onChange != null) { + widget.onChange!(widget.attachment); + } + setState(() {}); + } + } + + Widget gridItem(IconData iconData, String title) { + return Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + border: Border.all(color: const Color(0xffF1F1F1), width: 1), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Icon(iconData, color: const Color(0xff7D859A), size: 36), + Text( + title, + style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w500), + ), + ], + ), + ); + } + + onFilePicker() async { + if (widget.attachment.length >= 5) { + Fluttertoast.showToast(msg: context.translation.maxImagesNumberIs5); + return; + } + ImageSource? source = await showModalBottomSheet( + context: context, + builder: (BuildContext context) { + Widget listCard({required String icon, required String label, required VoidCallback onTap}) { + return GestureDetector( + onTap: onTap, + child: Container( + constraints: BoxConstraints(minWidth: 111.toScreenWidth, minHeight: 111.toScreenHeight), + padding: EdgeInsets.symmetric(horizontal: 12.toScreenWidth, vertical: 12.toScreenHeight), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), border: Border.all(width: 1, color: AppColor.white70)), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + icon.toSvgAsset(), + 24.height, + label.bodyText2(context).custom(color: AppColor.black20), + ], + ), + ), + ); + } + + return Container( + padding: const EdgeInsets.all(16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + listCard( + icon: 'camera_icon', + label: '${context.translation.open}\n${context.translation.camera}', + onTap: () { + Navigator.of(context).pop(ImageSource.camera); + }, + ), + listCard( + icon: 'gallery_icon', + label: '${context.translation.open}\n${context.translation.gallery}', + onTap: () { + Navigator.of(context).pop(ImageSource.gallery); + }, + ), + listCard( + icon: 'file_icon', + label: '${context.translation.open}\n${context.translation.files}', + onTap: () async { + await fromFilePicker(); + Navigator.pop(context); + }, + ), + ], + ), + ); + }, + ); + // ImageSource source = await showDialog( + // context: context, + // builder: (dialogContext) => CupertinoAlertDialog( + // actions: [ + // TextButton( + // child: Text(context.translation.pickFromCamera), + // onPressed: () { + // Navigator.of(dialogContext).pop(ImageSource.camera); + // }, + // ), + // TextButton( + // child: Text(context.translation.pickFromGallery), + // onPressed: () { + // Navigator.of(dialogContext).pop(ImageSource.gallery); + // }, + // ), + // TextButton( + // child: Text(context.translation.pickFromFiles), + // onPressed: () async { + // await fromFilePicker(); + // Navigator.pop(context); + // }, + // ), + // ], + // ), + // ); + if (source == null) return; + + final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800); + + if (pickedFile != null) { + File fileImage = File(pickedFile.path); + widget.attachment.add(GenericAttachmentModel(id: 0, name: fileImage.path)); + if (widget.onChange != null) { + widget.onChange!(widget.attachment); + } + setState(() {}); + } + + setState(() {}); + } +} diff --git a/lib/views/widgets/images/multi_image_picker_item.dart b/lib/views/widgets/images/multi_image_picker_item.dart index bb1e7a36..4669440e 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 (_isLocalUrl(file.path)) { OpenFile.open(file.path); } else { - if (!await launchUrl(Uri.parse(file.path), mode: LaunchMode.externalApplication)) { + if (!await launchUrl(Uri.parse(URLs.getFileUrl(file.path)!), mode: LaunchMode.externalApplication)) { Fluttertoast.showToast(msg: "UnExpected Error with file."); throw Exception('Could not launch'); } diff --git a/lib/views/widgets/images/new_multi_image_picker.dart b/lib/views/widgets/images/new_multi_image_picker.dart index 30f4a9ff..040af263 100644 --- a/lib/views/widgets/images/new_multi_image_picker.dart +++ b/lib/views/widgets/images/new_multi_image_picker.dart @@ -72,7 +72,7 @@ class _MultiFilesPickerState extends State { children: List.generate( widget.files!.length, (index) { - File image = widget.files![index].file; + File image = widget.files[index].file; return MultiFilesPickerItem( file: image, enabled: widget.enabled, diff --git a/lib/views/widgets/notifications/notification_item.dart b/lib/views/widgets/notifications/notification_item.dart index 682deea7..89fef4b5 100644 --- a/lib/views/widgets/notifications/notification_item.dart +++ b/lib/views/widgets/notifications/notification_item.dart @@ -28,14 +28,14 @@ class NotificationItem extends StatelessWidget { label: notification.priorityName, textColor: AppColor.getRequestStatusTextColorByName(context, notification.priorityName!), backgroundColor: AppColor.getRequestStatusColorByName(context, notification.priorityName!), - ).toShimmer(isShow: isLoading), + ).toShimmer(isShow: isLoading,context: context), 8.width, if ((notification.statusName ?? "").isNotEmpty && notification.sourceName != "Asset Transfer") StatusLabel( label: notification.statusName ?? "", textColor: AppColor.getRequestStatusTextColorByName(context, notification.statusName ?? ""), backgroundColor: AppColor.getRequestStatusColorByName(context, notification.statusName ?? ""), - ).toShimmer(isShow: isLoading), + ).toShimmer(isShow: isLoading,context: context), ], ), 8.height, @@ -47,7 +47,7 @@ class NotificationItem extends StatelessWidget { style: AppTextStyles.heading6.copyWith( color: context.isDark ? AppColor.neutral30 : AppColor.neutral50, ), - ).toShimmer(isShow: isLoading).expanded, + ).toShimmer(isShow: isLoading,context: context).expanded, 8.width, Text( notification.createdOn?.toServiceRequestCardFormat ?? "", @@ -55,7 +55,7 @@ class NotificationItem extends StatelessWidget { style: AppTextStyles.tinyFont.copyWith( color: context.isDark ? AppColor.neutral20 : AppColor.neutral50, ), - ).toShimmer(isShow: isLoading), + ).toShimmer(isShow: isLoading,context: context), ], ), Text( @@ -63,7 +63,7 @@ class NotificationItem extends StatelessWidget { style: AppTextStyles.bodyText2.copyWith( color: context.isDark ? AppColor.neutral10 : const Color(0xFF757575), ), - ).toShimmer(isShow: isLoading), + ).toShimmer(isShow: isLoading,context: context), ], ).onPress(() { onPressed(notification); diff --git a/lib/views/widgets/parts/auto_complete_parts_field.dart b/lib/views/widgets/parts/auto_complete_parts_field.dart index 649d2d38..566c0b8f 100644 --- a/lib/views/widgets/parts/auto_complete_parts_field.dart +++ b/lib/views/widgets/parts/auto_complete_parts_field.dart @@ -88,11 +88,11 @@ class _AutoCompletePartsFieldState extends State { constraints: const BoxConstraints(), suffixIconConstraints: const BoxConstraints(minWidth: 0), filled: true, - fillColor: (context.isDark ? AppColor.neutral50 : AppColor.neutral100), + fillColor: AppColor.fieldBgColor(context), errorStyle: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60), floatingLabelStyle: AppTextStyle.body1.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? null : AppColor.neutral20), labelText: widget.byName ? context.translation.partName : context.translation.partNumber, - labelStyle: AppTextStyles.tinyFont.copyWith(color: AppColor.neutral120), + labelStyle: AppTextStyles.tinyFont.copyWith(color: AppColor.textColor(context)), ), textInputAction: TextInputAction.search, onChanged: (text) { diff --git a/lib/views/widgets/pentry/calibration_tool_asset_picker.dart b/lib/views/widgets/pentry/calibration_tool_asset_picker.dart index bad35478..740c6f58 100644 --- a/lib/views/widgets/pentry/calibration_tool_asset_picker.dart +++ b/lib/views/widgets/pentry/calibration_tool_asset_picker.dart @@ -64,7 +64,7 @@ class _CalibrationToolAssetPickerState extends State PickAsset( showAssetInfo: false, forPPM: true, - cardColor: AppColor.neutral100, + cardColor: AppColor.fieldBgColor(context), device: widget.initialValue == null ? null : Asset( diff --git a/lib/views/widgets/timer/app_timer.dart b/lib/views/widgets/timer/app_timer.dart index 090f6913..93270c9e 100644 --- a/lib/views/widgets/timer/app_timer.dart +++ b/lib/views/widgets/timer/app_timer.dart @@ -162,7 +162,7 @@ class _AppTimerState extends State { ADatePicker( label: context.translation.startTime, hideShadow: true, - backgroundColor: AppColor.neutral100, + backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, date: _pickerStartAt, from: widget.pickerFromDate, enable: widget.enabled ? _tempPickerTimer == null : false, @@ -195,7 +195,7 @@ class _AppTimerState extends State { ADatePicker( label: context.translation.endTime, hideShadow: true, - backgroundColor: AppColor.neutral100, + backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, enable: widget.enabled ? _pickerStartAt != null : false, from: _pickerStartAt, date: _pickerEndAt, @@ -256,8 +256,9 @@ class _AppTimerState extends State { color: context.isDark && !widget.enabled ? AppColor.neutral60 : !widget.enabled + // backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, ? AppColor.neutral40 - : AppColor.background(context), + : AppColor.fieldBgColor(context), borderRadius: BorderRadius.circular(10), boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], ), @@ -355,7 +356,7 @@ class _AppTimerState extends State { // ADatePicker( // label: context.translation.startTime, // hideShadow: true, -// backgroundColor: AppColor.neutral100, +// backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, // date: _pickerStartAt, // enable: _tempPickerTimer == null, // formatDateWithTime: true, @@ -375,7 +376,7 @@ class _AppTimerState extends State { // ADatePicker( // label: context.translation.endTime, // hideShadow: true, -// backgroundColor: AppColor.neutral100, +// backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, // enable: _pickerStartAt != null, // date: _pickerEndAt, // formatDateWithTime: true, diff --git a/pubspec.yaml b/pubspec.yaml index 47ace654..a562ad1d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.3.5+24 +version: 1.3.6+25 environment: sdk: ">=3.5.0 <4.0.0"