import 'package:eitc_erm_dental_flutter/exts.dart';
import 'package:eitc_erm_dental_flutter/funcs.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class PatientListItem extends StatelessWidget {
  final int index;
  final String name;
  final String idCard;
  final String relation;
  final void Function(int index) onTap;

  const PatientListItem({
    super.key,
    required this.index,
    required this.name,
    required this.idCard,
    required this.relation,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => onTap(index),
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
        decoration: BoxDecoration(
            color: context.surfaceContainerHighColor,
            borderRadius: BorderRadius.circular(8.r)),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Text(name),
                SizedBox(
                  width: 10.w,
                ),
                Container(
                  padding:
                      EdgeInsets.symmetric(horizontal: 10.w, vertical: 1.h),
                  decoration: BoxDecoration(
                    border: Border.fromBorderSide(
                        BorderSide(color: context.primaryColor)),
                    borderRadius: BorderRadius.circular(30.r),
                  ),
                  child: Text(
                    relation,
                    style:
                        TextStyle(fontSize: 10.sp, color: context.primaryColor),
                  ),
                )
              ],
            ),
            Text(setIdCardStar(idCard))
          ],
        ),
      ),
    );
  }
}
