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 HealthCard extends StatelessWidget {
  const HealthCard({
    super.key,
    required this.icon,
    this.iconColor,
    this.iconBgColor,
    required this.labelText,
    required this.subtitle,
    this.onTap,
  });

  final String icon;
  final Color? iconColor;
  final Color? iconBgColor;
  final String labelText;
  final String subtitle;
  final VoidCallback? onTap;

  @override
  Widget build(BuildContext context) {
    AppState appState = getIt.get<AppState>();
    return Container(
      decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 20.r, hasShadow: false),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Container(
              decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: iconBgColor ?? Colors.transparent, borderRadius: 10.r),
              height: 40.w,
              width: 40.w,
              child: Utils.buildSvgWithAssets(icon: icon, fit: BoxFit.none, height: 22.w, width: 22.w, iconColor: iconColor, )),
          SizedBox(width: 12.h),
          Expanded(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  children: [
                    labelText.toText16(weight: FontWeight.w600,),
                  ],
                ),
                SizedBox(height: 4.h),
                subtitle.toText12(maxLine: 2, color: AppColors.greyTextColor),
              ],
            ),
          ),
          SizedBox(width: 2.h),
          Transform.flip(
            flipX: appState.getLanguageCode() == "ar",
            child: Utils.buildSvgWithAssets(icon: AppAssets.arrowRight, width: 24.w, height: 24.h, fit: BoxFit.cover, iconColor: AppColors.textColor),
          ),
        ],
      ).paddingAll(16.w).onPress(() {
        onTap!();
      }),
    );
  }
}
