import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:hmg_patient_app_new/core/utils/size_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/lab/lab_view_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:provider/provider.dart';

class LabOrderSpecialResult extends StatelessWidget {
  const LabOrderSpecialResult({super.key});

  @override
  Widget build(BuildContext context) {
    return Selector<LabViewModel, bool>(
        selector: (_, model) => model.isSpecialResultsLoading,
        builder: (_, isLoading, __) {
          return Selector<LabViewModel, String>(
              selector: (_, model) => model.labSpecialResult,
              builder: (_, data, __) {
                if(isLoading){
                  return Container(
                      margin: EdgeInsets.symmetric(vertical: 8.h),
                      padding: EdgeInsets.symmetric(
                          horizontal: 16.h, vertical: 16.h),
                      width: MediaQuery.sizeOf(context).width - 24,
                      decoration: RoundedRectangleBorder()
                          .toSmoothCornerDecoration(
                          color: AppColors.whiteColor,
                          borderRadius: 20.h,
                          hasShadow: true),
                      child:Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        spacing: 12.h,
                        children: [
                          "loading".toText14().toShimmer2(isShow: isLoading),
                          "loading".toText14().toShimmer2(isShow: isLoading),
                        ],
                      )
                  );
                }
                if(data.isNotEmpty ) {
                  return 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(
                        padding: EdgeInsets.symmetric(
                            horizontal: 16.h, vertical: 16.h),
                        width: MediaQuery.sizeOf(context).width - 24,
                        child: Column(
                          spacing: 8.h,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            // ...labOrder!.testDetails!.map((detail) {
                            LocaleKeys.specialResult
                                .tr()
                                .toText14(isBold: true)
                                .toShimmer2(isShow: isLoading),

                            data.isEmpty
                                ? LocaleKeys.noSpecialResult
                                    .tr()
                                    .toText12(
                                        isBold: true,
                                        color: AppColors.textColorLight)
                                    .toShimmer2(isShow: isLoading)
                                : HtmlWidget(data).toShimmer2(isShow: isLoading)

                            //
                          ],
                        ),
                      ));
                } return SizedBox.shrink();
              });

        });
  }
}

/*Text(
                "Special Results",
                style: TextStyle(
                    fontSize: 18.fSize,
                    isBold: true,
                    color: AppColors.blackColor),
              ),
              Container(
                  decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
                    color: AppColors.whiteColor,
                    borderRadius: 20.h,
                  hasShadow: true
                  ),
                  padding: EdgeInsets.all(16.h),
                  width: MediaQuery.sizeOf(context).width-24,
                  child: Selector<LabViewModel, bool>(
                      selector: (_, model) =>
                          model.isLabResultByHospitalLoading,
                      builder: (_, isLoading, __) {
                        return Selector<LabViewModel, String>(
                            selector: (_, model) => model.labSpecialResult,
                            builder: (_, data, __) {
                              return (data.isEmpty)
                                  ? Text("No result available".needTranslation,
                                          style: TextStyle(
                                              fontSize: 12.fSize,
                                              isBold: true,
                                              color: AppColors.textColorLight))
                                      .toShimmer2(isShow: isLoading)
                                  : HtmlWidget(data)
                                      .toShimmer2(isShow: isLoading);
                            });
                      }))*/
