import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart';
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../widgets/shared/dialogs/ShowImageDialog.dart';

class PrescriptionItemsWidget extends StatelessWidget {
  final String? itemDescription;
  final String? route;
  final String? frequency;
  final dynamic dailyDoses;
  final String? imageSRCUrl;
  final String? remarks;
  final int? days;
  final PrescriptionViewModel? prescriptionViewModel;

  PrescriptionItemsWidget({
    this.itemDescription,
    this.route,
    this.frequency,
    this.dailyDoses,
    this.imageSRCUrl,
    this.remarks,
    this.days,
    this.prescriptionViewModel,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        ...List.generate(
          // TODO Elham*  List.generate to list.builder
          prescriptionViewModel!.prescriptionReportEnhList.length,
          (index) => Container(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(12),
              color: Colors.white,
            ),
            margin: EdgeInsets.all(12),
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Container(
                    margin: EdgeInsets.only(left: 18, right: 18),
                    child: AppText(
                      prescriptionViewModel!.prescriptionReportEnhList[index].itemDescription!,
                      bold: true,
                    ),
                  ),
                  SizedBox(
                    height: 12,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      SizedBox(
                        width: 18,
                      ),
                      Container(
                        decoration: BoxDecoration(shape: BoxShape.circle, border: Border.all(width: 0.5, color: Colors.grey)),
                        height: 55,
                        width: 55,
                        child: InkWell(
                          onTap: () {
                            showDialog(
                                context: context,
                                builder: (ctx) => ShowImageDialog(
                                      imageUrl: prescriptionViewModel!.prescriptionReportEnhList[index].imageSRCUrl!,
                                    ));
                          },
                          child: Stack(
                            children: [
                              Padding(
                                padding: const EdgeInsets.all(8.0),
                                child: Image.network(
                                  prescriptionViewModel!.prescriptionReportEnhList[index].imageSRCUrl!,
                                  fit: BoxFit.cover,
                                ),
                              ),
                              Positioned(
                                  top: 10,
                                  right: 10,
                                  child: Icon(
                                    EvaIcons.search,
                                    color: Colors.grey,
                                    size: 35,
                                  ))
                            ],
                          ),
                        ),
                      ),
                      SizedBox(
                        width: 10,
                      ),
                      Expanded(
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            CustomRow(
                              label: TranslationBase.of(context).route + ' : ',
                              value: " " + prescriptionViewModel!.prescriptionReportEnhList[index].route! ?? '',
                              labelSize: 13,
                              valueSize: 13,
                            ),
                            CustomRow(
                              label: TranslationBase.of(context).frequency + ' : ',
                              value: " " + prescriptionViewModel!.prescriptionReportEnhList[index].frequency! ?? '',
                              labelSize: 13,
                              valueSize: 13,
                            ),
                            CustomRow(
                              label: TranslationBase.of(context).dailyDoses + ' : ',
                              value: " " + prescriptionViewModel!.prescriptionReportEnhList[index].doseDailyQuantity.toString() ?? '',
                              labelSize: 13,
                              valueSize: 13,
                            ),
                            CustomRow(
                              label: TranslationBase.of(context).duration + ' : ',
                              value: " " + prescriptionViewModel!.prescriptionReportList[index].days.toString() ?? '',
                              labelSize: 13,
                              valueSize: 13,
                            ),
                            SizedBox(
                              height: 12,
                            ),
                            CustomRow(
                              label: '',
                              value: prescriptionViewModel!.prescriptionReportList[index].remarks ?? '',
                              valueSize: 14,
                            ),
                          ],
                        ),
                      )
                    ],
                  )
                ],
              ),
            ),
          ),
        ),
      ],
    );
  }
}
