import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_export.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 AddressItem extends StatelessWidget {
  final bool isSelected;
  final String address;
  final VoidCallback? onTap;
  final String title;

  const AddressItem(
      {super.key,
      required this.isSelected,
      required this.address,
      this.onTap,
      required this.title});

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        SizedBox(
          height: 18.h,
          width: 18.h,
          child: DecoratedBox(
            decoration: BoxDecoration(
                border: Border.all(
                  color: AppColors.bottomNAVBorder,
                  width: 1.5,
                ),
                borderRadius: BorderRadius.circular(70.h)),
            child: CircleAvatar(
              radius: 70.h,
              backgroundColor:
                  isSelected ? AppColors.errorLightColor : Colors.transparent,
            ).paddingAll(3.h),
          ),
        ),
        SizedBox(width: 12.h),
        Expanded(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            spacing: 2.h,
            children: [
              title.toText12(
                color: AppColors.greyTextColor,
                isBold: true,
              ),
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Expanded(
                    child: address.toText14(
                      color: AppColors.textColor,
                      weight: FontWeight.w600,
                        textOverflow : TextOverflow.ellipsis,
                        maxlines: 2
                    ),
                  ),
                ],
              )
            ],
          ),
        ),

        Container(
            height: 40.h,
            width: 40.h,
            margin: EdgeInsets.only(right: 10.h),
            padding: EdgeInsets.all(8.h),
            decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
              borderRadius: 10.h,
              color: AppColors.greyColor,
            ),
            child: Utils.buildSvgWithAssets(
                fit: BoxFit.contain,
                icon: AppAssets.location,
                iconColor: AppColors.greyTextColor))
      ],
    );
  }
}
