import 'dart:async';

import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_view_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/lab/lab_result_item_view.dart';
import 'package:hmg_patient_app_new/presentation/prescriptions/prescription_delivery_orders_list_page.dart';
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
import 'package:hmg_patient_app_new/presentation/prescriptions/prescription_detail_page.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
import 'package:provider/provider.dart';

import 'dart:ui' as ui;

class PrescriptionsListPage extends StatefulWidget {
  const   PrescriptionsListPage({super.key});

  @override
  State<PrescriptionsListPage> createState() => _PrescriptionsListPageState();
}

class _PrescriptionsListPageState extends State<PrescriptionsListPage> {
  int? expandedIndex;

  late PrescriptionsViewModel prescriptionsViewModel;

  @override
  void initState() {
    scheduleMicrotask(() {
      prescriptionsViewModel.initPrescriptionsViewModel();
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    AppState appState = getIt.get<AppState>();
    prescriptionsViewModel = Provider.of<PrescriptionsViewModel>(context, listen: false);
    return Scaffold(
      backgroundColor: AppColors.bgScaffoldColor,
      body: CollapsingListView(
        title: LocaleKeys.prescriptions.tr(context: context),
        requests: () {
          prescriptionsViewModel.getPrescriptionOrdersList();
          Navigator.of(context).push(
            CustomPageRoute(
              page: PrescriptionDeliveryOrdersListPage(),
            ),
          );
        },
        child: SingleChildScrollView(
          child: Consumer<PrescriptionsViewModel>(builder: (context, model, child) {
            return Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                SizedBox(height: 16.h),
                // Clinic & Hospital Sort
                // Row(
                //   children: [
                //     CustomButton(
                //       text: LocaleKeys.byClinic.tr(context: context),
                //       onPressed: () {
                //         model.setIsSortByClinic(true);
                //       },
                //       backgroundColor: model.isSortByClinic ? AppColors.bgRedLightColor : AppColors.whiteColor,
                //       borderColor: model.isSortByClinic ? AppColors.primaryRedColor : AppColors.textColor.withOpacity(0.2),
                //       textColor: model.isSortByClinic ? AppColors.primaryRedColor : AppColors.blackColor,
                //       fontSize: 12,
                //       isBold: true,
                //       borderRadius: 10,
                //       padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                //       height: 40.h,
                //     ),
                //     SizedBox(width: 8.h),
                //     CustomButton(
                //       text: LocaleKeys.byHospital.tr(context: context),
                //       onPressed: () {
                //         model.setIsSortByClinic(false);
                //       },
                //       backgroundColor: model.isSortByClinic ? AppColors.whiteColor : AppColors.bgRedLightColor,
                //       borderColor: model.isSortByClinic ? AppColors.textColor.withOpacity(0.2) : AppColors.primaryRedColor,
                //       textColor: model.isSortByClinic ? AppColors.blackColor : AppColors.primaryRedColor,
                //       fontSize: 12,
                //       isBold: true,
                //       borderRadius: 10,
                //       padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                //       height: 40.h,
                //     ),
                //   ],
                // ).paddingSymmetrical(24.h, 0.h),
                // SizedBox(height: 20.h),
                // Expandable list
                ListView.builder(
                  itemCount: model.isPrescriptionsOrdersLoading
                      ? 4
                      : model.patientPrescriptionOrders.isNotEmpty
                          ? model.patientPrescriptionOrders.length
                          : 1,
                  physics: NeverScrollableScrollPhysics(),
                  shrinkWrap: true,
                  padding: const EdgeInsets.only(left: 0, right: 8),
                  itemBuilder: (context, index) {
                    // final isExpanded = expandedIndex == index;
                    return model.isPrescriptionsOrdersLoading
                        ? LabResultItemView(
                            onTap: () {},
                            labOrder: null,
                            index: index,
                            isLoading: true,
                          )
                        : model.patientPrescriptionOrders.isNotEmpty
                            ? AnimationConfiguration.staggeredList(
                                position: index,
                                duration: const Duration(milliseconds: 500),
                                child: SlideAnimation(
                                  verticalOffset: 100.0,
                                  child: FadeInAnimation(
                                    child: AnimatedContainer(
                                      duration: Duration(milliseconds: 300),
                                      curve: Curves.easeInOut,
                                      margin: EdgeInsets.symmetric(vertical: 8.h),
                                      decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 20.h, hasShadow: true),
                                      child: Container(
                                        key: ValueKey<int>(index),
                                        padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 16.h),
                                        child: Column(
                                          crossAxisAlignment: CrossAxisAlignment.start,
                                          children: [
                                            AppCustomChipWidget(
                                              labelText:
                                                  "${getIt.get<AppState>().isArabic() ? model.patientPrescriptionOrders[index].isInOutPatientDescriptionN : model.patientPrescriptionOrders[index].isInOutPatientDescription}",
                                              backgroundColor: AppColors.warningColorYellow.withOpacity(0.1),
                                              textColor: AppColors.warningColorYellow,
                                            ),
                                            SizedBox(height: 16.h),
                                            Row(
                                              mainAxisSize: MainAxisSize.min,
                                              children: [
                                                Utils.buildImgWithNetwork(
                                                  url: model.patientPrescriptionOrders[index].doctorImageURL!,
                                                  iconColor: AppColors.blackBgColor,
                                                  width: 24.h,
                                                  height: 24.h,
                                                  fit: BoxFit.fill,
                                                ).circle(100),
                                                SizedBox(width: 8.h),
                                                Expanded(child: model.patientPrescriptionOrders[index].doctorName!.toText14(isBold: true)),
                                              ],
                                            ),
                                            SizedBox(height: 8.h),
                                            Wrap(
                                              direction: Axis.horizontal,
                                              spacing: 6.h,
                                              runSpacing: 6.h,
                                              children: [
                                                Directionality(
                                                  textDirection: ui.TextDirection.ltr,
                                                  child: AppCustomChipWidget(
                                                    labelText: DateUtil.formatDateToDate(DateUtil.convertStringToDate(model.patientPrescriptionOrders[index].appointmentDate), false),
                                                    isEnglishOnly: true,
                                                  ),
                                                ),
                                                AppCustomChipWidget(
                                                  labelText: model.patientPrescriptionOrders[index].name,
                                                ),
                                                AppCustomChipWidget(
                                                  labelText: model.patientPrescriptionOrders[index].clinicDescription!,
                                                ),
                                              ],
                                            ),
                                            SizedBox(height: 8.h),
                                            Row(
                                              children: [
                                                Expanded(
                                                  flex: 6,
                                                  child: CustomButton(
                                                    text: model.patientPrescriptionOrders[index].isHomeMedicineDeliverySupported!
                                                        ? LocaleKeys.resendOrder.tr(context: context)
                                                        : LocaleKeys.prescriptionDeliveryError.tr(context: context),
                                                    onPressed: () async {
                                                      if (model.patientPrescriptionOrders[index].isHomeMedicineDeliverySupported!) {
                                                        LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingPrescriptionDetails.tr(context: context));
                                                        await prescriptionsViewModel.getPrescriptionDetails(prescriptionsViewModel.patientPrescriptionOrders[index], onSuccess: (val) {
                                                          LoaderBottomSheet.hideLoader();
                                                          prescriptionsViewModel.initiatePrescriptionDelivery(context);
                                                        });
                                                      }
                                                    },
                                                    backgroundColor: model.patientPrescriptionOrders[index].isHomeMedicineDeliverySupported!
                                                        ? AppColors.successColor.withOpacity(0.15)
                                                        : AppColors.textColor.withOpacity(0.15),
                                                    borderColor: AppColors.successColor.withOpacity(0.01),
                                                    textColor: model.patientPrescriptionOrders[index].isHomeMedicineDeliverySupported! ? AppColors.successColor : AppColors.textColor.withOpacity(0.35),
                                                    fontSize: model.patientPrescriptionOrders[index].isHomeMedicineDeliverySupported! ? 14.f : 12.f,
                                                    fontWeight: FontWeight.w600,
                                                    borderRadius: 12.r,
                                                    padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                                                    height: 40.h,
                                                    icon: AppAssets.prescription_refill_icon,
                                                    iconColor: model.patientPrescriptionOrders[index].isHomeMedicineDeliverySupported! ? AppColors.successColor : AppColors.textColor.withOpacity(0.35),
                                                    iconSize: 16.h,
                                                  ),
                                                ),
                                                SizedBox(width: 8.h),
                                                Expanded(
                                                  flex: 1,
                                                  child: Container(
                                                    height: 40.h,
                                                    width: 40.w,
                                                    decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
                                                      color: AppColors.textColor,
                                                      borderRadius: 12,
                                                    ),
                                                    child: Padding(
                                                      padding: EdgeInsets.all(12.h),
                                                      child: Transform.flip(
                                                        flipX: appState.isArabic(),
                                                        child: Utils.buildSvgWithAssets(
                                                          icon: AppAssets.forward_arrow_icon_small,
                                                          iconColor: AppColors.whiteColor,
                                                          fit: BoxFit.contain,
                                                        ),
                                                      ),
                                                    ),
                                                  ).onPress(() {
                                                    model.setPrescriptionsDetailsLoading();
                                                    Navigator.of(context).push(
                                                      CustomPageRoute(
                                                        page: PrescriptionDetailPage(
                                                          prescriptionsResponseModel: model.patientPrescriptionOrders[index],
                                                          isFromAppointments: false,
                                                        ),
                                                      ),
                                                    );
                                                  }),
                                                ),
                                              ],
                                            ),
                                            // SizedBox(height: 12.h),
                                            // Divider(color: AppColors.borderOnlyColor.withValues(alpha: 0.05), height: 1.h),
                                            // SizedBox(height: 12.h),
                                          ],
                                        ),
                                        // Column(
                                        //   crossAxisAlignment: CrossAxisAlignment.start,
                                        //   children: [
                                        //     ...model.patientPrescriptionOrders.map((prescription) {
                                        //       return Column(
                                        //         crossAxisAlignment: CrossAxisAlignment.start,
                                        //         children: [
                                        //           Row(
                                        //             mainAxisSize: MainAxisSize.min,
                                        //             children: [
                                        //               Image.network(
                                        //                 prescription.doctorImageURL!,
                                        //                 width: 24.h,
                                        //                 height: 24.h,
                                        //                 fit: BoxFit.fill,
                                        //               ).circle(100),
                                        //               SizedBox(width: 8.h),
                                        //               Expanded(child: prescription.doctorName!.toText14(isBold: true)),
                                        //             ],
                                        //           ),
                                        //           SizedBox(height: 8.h),
                                        //           Wrap(
                                        //             direction: Axis.horizontal,
                                        //             spacing: 6.h,
                                        //             runSpacing: 6.h,
                                        //             children: [
                                        //               Directionality(
                                        //                 textDirection: ui.TextDirection.ltr,
                                        //                 child: AppCustomChipWidget(
                                        //                   labelText: DateUtil.formatDateToDate(DateUtil.convertStringToDate(prescription.appointmentDate), false), isEnglishOnly: true,
                                        //                 ),
                                        //               ),
                                        //               AppCustomChipWidget(
                                        //                 labelText: model.isSortByClinic ? prescription.name ?? "" : prescription.clinicDescription!,
                                        //               ),
                                        //             ],
                                        //           ),
                                        //           SizedBox(height: 8.h),
                                        //           Row(
                                        //             children: [
                                        //               Expanded(
                                        //                 flex: 6,
                                        //                 child: CustomButton(
                                        //                   text: prescription.isHomeMedicineDeliverySupported!
                                        //                       ? LocaleKeys.resendOrder.tr(context: context)
                                        //                       : LocaleKeys.prescriptionDeliveryError.tr(context: context),
                                        //                   onPressed: () async {
                                        //                     if (prescription.isHomeMedicineDeliverySupported!) {
                                        //                       LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingPrescriptionDetails.tr(context: context));
                                        //                       await prescriptionsViewModel.getPrescriptionDetails(prescriptionsViewModel.patientPrescriptionOrders[index],
                                        //                           onSuccess: (val) {
                                        //                             LoaderBottomSheet.hideLoader();
                                        //                             prescriptionsViewModel.initiatePrescriptionDelivery();
                                        //                           });
                                        //                     }
                                        //                   },
                                        //                   backgroundColor:
                                        //                   prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor.withOpacity(0.15) : AppColors.greyF7Color,
                                        //                   borderColor: AppColors.successColor.withOpacity(0.01),
                                        //                   textColor: prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor : AppColors.textColor.withOpacity(0.35),
                                        //                   fontSize: prescription.isHomeMedicineDeliverySupported! ? 14.f : 12.f,
                                        //                   isBold: true,
                                        //                   borderRadius: 12.r,
                                        //                   padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                                        //                   height: 40.h,
                                        //                   icon: AppAssets.prescription_refill_icon,
                                        //                   iconColor: prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor : AppColors.textColor.withOpacity(0.35),
                                        //                   iconSize: 16.h,
                                        //                 ),
                                        //               ),
                                        //               SizedBox(width: 8.h),
                                        //               Expanded(
                                        //                 flex: 1,
                                        //                 child: Container(
                                        //                   height: 40.h,
                                        //                   width: 40.w,
                                        //                   decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
                                        //                     color: AppColors.textColor,
                                        //                     borderRadius: 12,
                                        //                   ),
                                        //                   child: Padding(
                                        //                     padding: EdgeInsets.all(12.h),
                                        //                     child: Transform.flip(
                                        //                       flipX: appState.isArabic(),
                                        //                       child: Utils.buildSvgWithAssets(
                                        //                         icon: AppAssets.forward_arrow_icon_small,
                                        //                         iconColor: AppColors.whiteColor,
                                        //                         fit: BoxFit.contain,
                                        //                       ),
                                        //                     ),
                                        //                   ),
                                        //                 ).onPress(() {
                                        //                   model.setPrescriptionsDetailsLoading();
                                        //                   Navigator.of(context).push(
                                        //                     CustomPageRoute(
                                        //                       page: PrescriptionDetailPage(
                                        //                         prescriptionsResponseModel: prescription,
                                        //                         isFromAppointments: false,
                                        //                       ),
                                        //                     ),
                                        //                   );
                                        //                 }),
                                        //               ),
                                        //             ],
                                        //           ),
                                        //           SizedBox(height: 12.h),
                                        //           Divider(color: AppColors.borderOnlyColor.withValues(alpha: 0.05), height: 1.h),
                                        //           SizedBox(height: 12.h),
                                        //         ],
                                        //       );
                                        //     }).toList(),
                                        //   ],
                                        // ),
                                      ),

                                      // InkWell(
                                      //   onTap: () {
                                      //     setState(() {
                                      //       expandedIndex = isExpanded ? null : index;
                                      //     });
                                      //   },
                                      //   child: Column(
                                      //     crossAxisAlignment: CrossAxisAlignment.start,
                                      //     children: [
                                      //       Padding(
                                      //         padding: EdgeInsets.all(16.h),
                                      //         child: Column(
                                      //           crossAxisAlignment: CrossAxisAlignment.start,
                                      //           children: [
                                      //             Row(
                                      //               mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                      //               children: [
                                      //                 CustomButton(
                                      //                   text: "${model.patientPrescriptionOrdersViewList[index].prescriptionsList!.length} Prescriptions Available",
                                      //                   onPressed: () {},
                                      //                   backgroundColor: AppColors.greyColor,
                                      //                   borderColor: AppColors.greyColor,
                                      //                   textColor: AppColors.blackColor,
                                      //                   fontSize: 10,
                                      //                   isBold: true,
                                      //                   borderRadius: 8,
                                      //                   padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                                      //                   height: 30.h,
                                      //                 ),
                                      //                 Icon(isExpanded ? Icons.expand_less : Icons.expand_more),
                                      //               ],
                                      //             ),
                                      //             SizedBox(height: 8.h),
                                      //             (model.patientPrescriptionOrdersViewList[index].filterName ?? "").toText16(isBold: true)
                                      //           ],
                                      //         ),
                                      //       ),
                                      //       AnimatedSwitcher(
                                      //         duration: Duration(milliseconds: 500),
                                      //         switchInCurve: Curves.easeIn,
                                      //         switchOutCurve: Curves.easeOut,
                                      //         transitionBuilder: (Widget child, Animation<double> animation) {
                                      //           return FadeTransition(
                                      //             opacity: animation,
                                      //             child: SizeTransition(
                                      //               sizeFactor: animation,
                                      //               axisAlignment: 0.0,
                                      //               child: child,
                                      //             ),
                                      //           );
                                      //         },
                                      //         // child: isExpanded
                                      //         //     ? Container(
                                      //         //         key: ValueKey<int>(index),
                                      //         //         padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 8.h),
                                      //         //         child: Column(
                                      //         //           crossAxisAlignment: CrossAxisAlignment.start,
                                      //         //           children: [
                                      //         //             ...model.patientPrescriptionOrdersViewList[index].prescriptionsList!.map((prescription) {
                                      //         //               return Column(
                                      //         //                 crossAxisAlignment: CrossAxisAlignment.start,
                                      //         //                 children: [
                                      //         //                   Row(
                                      //         //                     mainAxisSize: MainAxisSize.min,
                                      //         //                     children: [
                                      //         //                       Image.network(
                                      //         //                         prescription.doctorImageURL!,
                                      //         //                         width: 24.h,
                                      //         //                         height: 24.h,
                                      //         //                         fit: BoxFit.fill,
                                      //         //                       ).circle(100),
                                      //         //                       SizedBox(width: 8.h),
                                      //         //                       Expanded(child: prescription.doctorName!.toText14(isBold: true)),
                                      //         //                     ],
                                      //         //                   ),
                                      //         //                   SizedBox(height: 8.h),
                                      //         //                   Wrap(
                                      //         //                     direction: Axis.horizontal,
                                      //         //                     spacing: 6.h,
                                      //         //                     runSpacing: 6.h,
                                      //         //                     children: [
                                      //         //                       Directionality(
                                      //         //                         textDirection: ui.TextDirection.ltr,
                                      //         //                         child: AppCustomChipWidget(
                                      //         //                           labelText: DateUtil.formatDateToDate(DateUtil.convertStringToDate(prescription.appointmentDate), false), isEnglishOnly: true,
                                      //         //                         ),
                                      //         //                       ),
                                      //         //                       AppCustomChipWidget(
                                      //         //                         labelText: model.isSortByClinic ? prescription.name ?? "" : prescription.clinicDescription!,
                                      //         //                       ),
                                      //         //                     ],
                                      //         //                   ),
                                      //         //                   SizedBox(height: 8.h),
                                      //         //                   Row(
                                      //         //                     children: [
                                      //         //                       Expanded(
                                      //         //                         flex: 6,
                                      //         //                         child: CustomButton(
                                      //         //                           text: prescription.isHomeMedicineDeliverySupported!
                                      //         //                               ? LocaleKeys.resendOrder.tr(context: context)
                                      //         //                               : LocaleKeys.prescriptionDeliveryError.tr(context: context),
                                      //         //                           onPressed: () async {
                                      //         //                             if (prescription.isHomeMedicineDeliverySupported!) {
                                      //         //                               LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingPrescriptionDetails.tr(context: context));
                                      //         //                               await prescriptionsViewModel.getPrescriptionDetails(prescriptionsViewModel.patientPrescriptionOrders[index],
                                      //         //                                   onSuccess: (val) {
                                      //         //                                 LoaderBottomSheet.hideLoader();
                                      //         //                                 prescriptionsViewModel.initiatePrescriptionDelivery();
                                      //         //                               });
                                      //         //                             }
                                      //         //                           },
                                      //         //                           backgroundColor:
                                      //         //                               prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor.withOpacity(0.15) : AppColors.greyF7Color,
                                      //         //                           borderColor: AppColors.successColor.withOpacity(0.01),
                                      //         //                           textColor: prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor : AppColors.textColor.withOpacity(0.35),
                                      //         //                           fontSize: prescription.isHomeMedicineDeliverySupported! ? 14.f : 12.f,
                                      //         //                           isBold: true,
                                      //         //                           borderRadius: 12.r,
                                      //         //                           padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                                      //         //                           height: 40.h,
                                      //         //                           icon: AppAssets.prescription_refill_icon,
                                      //         //                           iconColor: prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor : AppColors.textColor.withOpacity(0.35),
                                      //         //                           iconSize: 16.h,
                                      //         //                         ),
                                      //         //                       ),
                                      //         //                       SizedBox(width: 8.h),
                                      //         //                       Expanded(
                                      //         //                         flex: 1,
                                      //         //                         child: Container(
                                      //         //                           height: 40.h,
                                      //         //                           width: 40.w,
                                      //         //                           decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
                                      //         //                             color: AppColors.textColor,
                                      //         //                             borderRadius: 12,
                                      //         //                           ),
                                      //         //                           child: Padding(
                                      //         //                             padding: EdgeInsets.all(12.h),
                                      //         //                             child: Transform.flip(
                                      //         //                               flipX: appState.isArabic(),
                                      //         //                               child: Utils.buildSvgWithAssets(
                                      //         //                                 icon: AppAssets.forward_arrow_icon_small,
                                      //         //                                 iconColor: AppColors.whiteColor,
                                      //         //                                 fit: BoxFit.contain,
                                      //         //                               ),
                                      //         //                             ),
                                      //         //                           ),
                                      //         //                         ).onPress(() {
                                      //         //                           model.setPrescriptionsDetailsLoading();
                                      //         //                           Navigator.of(context).push(
                                      //         //                             CustomPageRoute(
                                      //         //                               page: PrescriptionDetailPage(
                                      //         //                                 prescriptionsResponseModel: prescription,
                                      //         //                                 isFromAppointments: false,
                                      //         //                               ),
                                      //         //                             ),
                                      //         //                           );
                                      //         //                         }),
                                      //         //                       ),
                                      //         //                     ],
                                      //         //                   ),
                                      //         //                   SizedBox(height: 12.h),
                                      //         //                   Divider(color: AppColors.borderOnlyColor.withValues(alpha: 0.05), height: 1.h),
                                      //         //                   SizedBox(height: 12.h),
                                      //         //                 ],
                                      //         //               );
                                      //         //             }).toList(),
                                      //         //           ],
                                      //         //         ),
                                      //         //       )
                                      //         //     : SizedBox.shrink(),
                                      //       ),
                                      //     ],
                                      //   ),
                                      // ),
                                    ).onPress(() {
                                      model.setPrescriptionsDetailsLoading();
                                      Navigator.of(context).push(
                                        CustomPageRoute(
                                          page: PrescriptionDetailPage(
                                            prescriptionsResponseModel: model.patientPrescriptionOrders[index],
                                            isFromAppointments: false,
                                          ),
                                        ),
                                      );
                                    }),
                                  ),
                                ),
                              )
                            : Utils.getNoDataWidget(context, noDataText: LocaleKeys.youDontHaveAnyPrescriptionsYet.tr(context: context));
                  },
                ).paddingSymmetrical(24.h, 0.h),
              ],
            );
          }),
        ),
      ),
    );
  }
}
