import 'package:flutter/material.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/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/theme/colors.dart';

class LabRadCard extends StatelessWidget {
  LabRadCard({super.key, required this.icon, required this.labelText, required this.labOrderTests, required this.isLoading});

  String icon;
  String labelText;
  List<String> labOrderTests = [];
  bool isLoading;

  @override
  Widget build(BuildContext context) {
    AppState appState = getIt.get<AppState>();
    return Container(
      decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.h, hasShadow: false),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              Utils.buildSvgWithAssets(
                icon: icon,
                width: 40.h,
                height: 40.h,
                fit: BoxFit.contain,
              ).toShimmer2(isShow: false, radius: 12.h),
              SizedBox(width: 8.h),
              labelText.toText13(isBold: true).toShimmer2(isShow: false, radius: 6.h, height: 32.h),
            ],
          ),
          SizedBox(height: 16.h),
          labOrderTests.isNotEmpty
              ? ListView.separated(
                  scrollDirection: Axis.vertical,
                  padding: EdgeInsets.zero,
                  physics: NeverScrollableScrollPhysics(),
                  shrinkWrap: true,
            itemBuilder: (cxt, index) {
                    return labOrderTests[index].toText12(isBold: true, maxLine: 1).toShimmer2(isShow: false, radius: 6.h, height: 24.h, width: 120.h).toShimmer2(isShow: isLoading);
                  },
                  separatorBuilder: (cxt, index) => SizedBox(height: 8.h),
                  itemCount: 3,
                )
              : "You don't have any records yet".needTranslation.toText12(fontWeight: FontWeight.w500, color: AppColors.greyTextColor, isCenter: true),
          SizedBox(height: 16.h),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              SizedBox.shrink(),
              Transform.flip(
                flipX: appState.isArabic(),
                child: Utils.buildSvgWithAssets(icon: AppAssets.forward_arrow_icon_small, width: 15.h, height: 15.h, fit: BoxFit.contain, iconColor: AppColors.textColor)
                    .toShimmer2(isShow: false, radius: 12.h),
              ),
            ],
          )
        ],
      ).paddingAll(16.h),
    );
  }
}
