//
// //TODO old Flow ..
// import 'package:flutter/material.dart';
// import 'package:provider/provider.dart';
// import 'package:test_sa/controllers/providers/api/comments_provider.dart';
// import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
// 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/string_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/service_request/service_request.dart';
// import 'package:test_sa/new_views/app_style/app_color.dart';
// import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
// import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
// import 'package:test_sa/views/pages/user/requests/comments_bottom_sheet.dart';
// import 'package:test_sa/views/pages/user/requests/work_order/work_orders_list_page.dart';
// import 'package:test_sa/views/widgets/images/files_list.dart';
// import 'package:test_sa/views/widgets/loaders/app_loading.dart';
// import 'package:test_sa/views/widgets/sound/sound_player.dart';
//
// import '../../../widgets/requests/request_status.dart';
// import 'first_action_bottom_sheet.dart';
//// //todo @delete
// class ServiceRequestDetailsPage extends StatefulWidget {
//   static const String id = "/call-details";
//   ServiceRequest serviceRequest;
//
//   ServiceRequestDetailsPage({Key? key, required this.serviceRequest}) : super(key: key);
//
//   @override
//   State<ServiceRequestDetailsPage> createState() => _ServiceRequestDetailsPageState();
// }
//
// class _ServiceRequestDetailsPageState extends State<ServiceRequestDetailsPage> {
//   bool loading = false;
//   ServiceRequest? serviceRequest;
//
//   @override
//   void initState() {
//     super.initState();
//     getServiceRequest();
//   }
//
//   void getServiceRequest() {
//     loading = true;
//     setState(() {});
//     WidgetsFlutterBinding.ensureInitialized().addPostFrameCallback((timeStamp) async {
//       Provider.of<CommentsProvider>(context, listen: false).reset();
//       serviceRequest = await Provider.of<ServiceRequestsProvider>(context, listen: false).getServiceRequestObjectById(requestId: widget.serviceRequest.id!);
//       loading = false;
//       setState(() {});
//     });
//   }
//
//   @override
//   Widget build(BuildContext context) {
//     UserProvider userProvider = Provider.of<UserProvider>(context, listen: false);
//
//     Widget informationCard(ServiceRequest serviceRequest) {
//       return Column(
//         crossAxisAlignment: CrossAxisAlignment.start,
//         children: [
//           Column(
//             mainAxisSize: MainAxisSize.min,
//             crossAxisAlignment: CrossAxisAlignment.start,
//             children: [
//               Row(
//                 crossAxisAlignment: CrossAxisAlignment.start,
//                 children: [
//                   Column(
//                     crossAxisAlignment: CrossAxisAlignment.start,
//                     children: [
//                       Row(
//                         children: [
//                           StatusLabel(
//                             label: serviceRequest.priority!.name,
//                             id: serviceRequest.priority!.id!,
//                             textColor: AppColor.getPriorityStatusTextColor(context, serviceRequest.priority!.id!),
//                             backgroundColor: AppColor.getPriorityStatusColor(context, serviceRequest.priority!.id!),
//                           ),
//                           8.width,
//                           StatusLabel(
//                             label: serviceRequest.statusLabel,
//                             textColor: AppColor.getRequestStatusTextColor(context, serviceRequest.statusValue!),
//                             backgroundColor: AppColor.getRequestStatusColor(context, serviceRequest.statusValue!),
//                           ),
//                           1.width.expanded,
//                         ],
//                       ),
//                       8.height,
//                       Text(serviceRequest.deviceEnName?.cleanupWhitespace.capitalizeFirstOfEach ?? "",
//                           style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
//                       8.height,
//                       Text(
//                         '${context.translation.assetNumber}:  ${serviceRequest.device!.assetNumber}',
//                         style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//                       ),
//                       Text(
//                         '${context.translation.requestType}: ${serviceRequest.type!.name}',
//                         style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//                       ),
//                       Text(
//                         '${context.translation.equipmentStatus}: ${serviceRequest.defectType!.name}',
//                         style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//                       ),
//                       Text(
//                         '${context.translation.requestNo}: ${serviceRequest.requestCode}',
//                         style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//                       ),
//                       Text(
//                         '${context.translation.requesterName}: ${serviceRequest.callCreatedBy?.name ?? "-"}',
//                         style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//                       ),
//                     ],
//                   ).expanded,
//                   Column(
//                     crossAxisAlignment: CrossAxisAlignment.end,
//                     children: [
//                       // if (userProvider.user!.type == UsersTypes.normal_user)
//                       //   context.translation.code.toSvgAsset(width: 48).onPress(() {
//                       //     Navigator.push(context, MaterialPageRoute(builder: (context) => UpdateServiceRequestPage(serviceRequest: serviceRequest)));
//                       //   }),
//                       if (userProvider.user!.type == UsersTypes.engineer) 16.height,
//                       Text(
//                         serviceRequest.date!.toServiceRequestCardFormat,
//                         textAlign: TextAlign.end,
//                         style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
//                       ),
//                     ],
//                   )
//                 ],
//               ),
//               8.height,
//               const Divider().defaultStyle(context),
//               8.height,
//               Text(
//                 '${context.translation.manufacture}: ${serviceRequest.device!.modelDefinition!.manufacturerName?.cleanupWhitespace.capitalizeFirstOfEach}',
//                 style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//               ),
//               Text(
//                 '${context.translation.model}: ${serviceRequest.device!.modelDefinition!.modelName?.cleanupWhitespace.capitalizeFirstOfEach}',
//                 style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//               ),
//               Text(
//                 '${context.translation.site}: ${serviceRequest.device!.site?.custName?.cleanupWhitespace.capitalizeFirstOfEach}',
//                 style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//               ),
//               Text(
//                 '${context.translation.building}: ${serviceRequest.device!.building?.name?.cleanupWhitespace.capitalizeFirstOfEach}',
//                 style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//               ),
//               Text(
//                 '${context.translation.floor}: ${serviceRequest.device!.floor?.name?.cleanupWhitespace.capitalizeFirstOfEach ?? ""}',
//                 style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//               ),
//               Text(
//                 '${context.translation.department}: ${serviceRequest.device!.department?.departmentName?.cleanupWhitespace.capitalizeFirstOfEach}',
//                 style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//               ),
//               Text(
//                 '${context.translation.room}: ${(serviceRequest.device!.room?.name ?? "").cleanupWhitespace.capitalizeFirstOfEach}',
//                 style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//               ),
//               8.height,
//               if ((serviceRequest.callComments ?? "").isNotEmpty) ...[
//                 const Divider().defaultStyle(context),
//                 8.height,
//                 Text(
//                   serviceRequest.callComments!,
//                   style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//                 ),
//               ],
//               if (serviceRequest.devicePhotos?.isNotEmpty ?? false) ...[
//                 8.height,
//                 const Divider().defaultStyle(context),
//                 FilesList(images: serviceRequest.devicePhotos!),
//               ],
//               if (serviceRequest.audio?.isNotEmpty ?? false) ...[
//                 const Divider().defaultStyle(context),
//                 16.height,
//                 ASoundPlayer(audio: serviceRequest.audio!),
//                 8.height,
//               ],
//             ],
//           ).paddingOnly(start: 16, end: 16, top: 16, bottom: 8),
//           (userProvider.user!.type == UsersTypes.normal_user
//                   ? Container(
//                       height: 50,
//                       padding: const EdgeInsets.only(left: 16, right: 16),
//                       alignment: Alignment.center,
//                       width: double.infinity,
//                       decoration: ShapeDecoration(
//                         color: context.isDark ? AppColor.neutral50 : AppColor.neutral30,
//                         shape: const RoundedRectangleBorder(
//                           borderRadius: BorderRadius.only(
//                             bottomLeft: Radius.circular(20),
//                             bottomRight: Radius.circular(20),
//                           ),
//                         ),
//                       ),
//                       child: Row(
//                         children: [
//                           Text(
//                             '${context.translation.commentHere}...',
//                             style: AppTextStyles.heading6.copyWith(
//                               color: (context.isDark ? AppColor.neutral30 : AppColor.neutral50).withOpacity(.6),
//                             ),
//                           ).expanded,
//                           "comment_send".toSvgAsset(width: 24, color: context.isDark ? AppColor.primary50 : AppColor.primary70),
//                         ],
//                       ),
//                     )
//                   : Column(
//                       mainAxisSize: MainAxisSize.min,
//                       crossAxisAlignment: CrossAxisAlignment.start,
//                       children: [
//                         const Divider().defaultStyle(context),
//                         16.height,
//                         Row(
//                           mainAxisSize: MainAxisSize.min,
//                           children: [
//                             Text(
//                               context.translation.viewComments,
//                               style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)),
//                             ),
//                             4.width,
//                             Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14)
//                           ],
//                         ),
//                       ],
//                     ).paddingOnly(bottom: 16, start: 16, end: 16))
//               .onPress(() {
//             showModalBottomSheet(
//               context: context,
//               useSafeArea: true,
//               isScrollControlled: true,
//               useRootNavigator: true,
//               backgroundColor: Colors.transparent,
//               builder: (context) => CommentsBottomSheet(requestId: serviceRequest.id!),
//             );
//           }),
//         ],
//       ).toShadowContainer(context, padding: 0);
//     }
//
//     return Scaffold(
//       appBar: DefaultAppBar(title: context.translation.serviceDetails),
//       //backgroundColor: const Color(0xfff8f9fb),
//       body: SafeArea(
//         child: loading
//             ? const ALoading().center
//             : serviceRequest == null
//                 ? Text(
//                     context.translation.noDataFound,
//                     style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
//                   ).center
//                 : Column(
//                     crossAxisAlignment: CrossAxisAlignment.start,
//                     children: [
//                       SingleChildScrollView(
//                         padding: const EdgeInsets.all(16),
//                         child: informationCard(serviceRequest!),
//                       ).expanded,
//                       if (userProvider.user!.type == UsersTypes.engineer || (serviceRequest!.statusValue == 5 || serviceRequest!.statusValue == 3))
//                         (serviceRequest?.firstAction == null
//                                 ? AppFilledButton(
//                                     label: context.translation.firstAction,
//                                     maxWidth: true,
//                                     onPressed: () async {
//                                       bool shouldReloadData = (await showModalBottomSheet(
//                                         context: context,
//                                         useSafeArea: true,
//                                         isScrollControlled: true,
//                                         backgroundColor: Colors.transparent,
//                                         builder: (context) => FirstActionBottomSheet(request: serviceRequest!),
//                                       )) as bool;
//                                       if (shouldReloadData ?? false) {
//                                         getServiceRequest();
//                                       }
//                                     },
//                                   )
//                                 : AppFilledButton(
//                                     label: context.translation.viewWorkOrder,
//                                     maxWidth: true,
//                                     onPressed: () {
//                                       Navigator.push(
//                                         context,
//                                         MaterialPageRoute(builder: (context) => WorkOrderListPage(serviceRequest: serviceRequest)),
//                                       );
//                                       // Navigator.of(context).pushNamed(WorkOrderListPage.id, arguments: serviceRequest);
//                                     },
//                                   ))
//                             .paddingOnly(start: 16, end: 16, bottom: 24),
//                     ],
//                   ),
//       ),
//     );
//   }
// }
