import 'package:flutter/material.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/presentation/insurance/insurance_home_page.dart';
import 'package:hmg_patient_app_new/presentation/lab/lab_orders_page.dart';
import 'package:hmg_patient_app_new/presentation/prescriptions/prescriptions_list_page.dart';
import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart';

import '../../../core/utils/utils.dart';
import '../../../theme/colors.dart';
import '../../radiology/radiology_orders_page.dart' show RadiologyOrdersPage;

class SmallServiceCard extends StatelessWidget {
  final String serviceName;
  final String icon;
  final String title;
  final String subtitle;
  final Color iconColor;
  final Color textColor;
  final Color backgroundColor;
  final bool isBold;

  SmallServiceCard({
    super.key,
    this.icon = "",
    this.serviceName = "",
    this.title = "",
    this.subtitle = "",
    this.backgroundColor = AppColors.whiteColor,
    this.iconColor = AppColors.blackColor,
    this.textColor = AppColors.blackColor,
    this.isBold = false,
  });

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 3.h),
      child: Container(
        decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
          color: backgroundColor,
          borderRadius: 16,
        ),
        child: Padding(
          padding: EdgeInsets.all(12.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Utils.buildSvgWithAssets(icon: icon, iconColor: iconColor, width: 32.h, height: 32.h),
              SizedBox(height: 6.h),
              title.toText11(color: textColor, isBold: isBold, isCenter: true),
              subtitle.toText11(color: textColor, isBold: isBold, isCenter: true),
            ],
          ),
        ),
      ),
    ).onPress(() {
      switch (serviceName) {
        case "lab_results":
          Navigator.of(context).push(
            FadePage(
              page: LabOrdersPage(),
            ),
          );
          break;
        case "radiology_results":
          Navigator.of(context).push(
            FadePage(
              page: RadiologyOrdersPage(),
            ),
          );
          break;
        case "prescriptions":
          Navigator.of(context).push(
            FadePage(
              page: PrescriptionsListPage(),
            ),
          );
          break;
        case "insurance_update":
          Navigator.of(context).push(
            FadePage(
              page: InsuranceHomePage(),
            ),
          );
          break;
        default:
          // Handle unknown service
          break;
      }
    });
  }
}
