import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/enums.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/features/blood_donation/blood_donation_view_model.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';

class SelectGenderWidget extends StatelessWidget {
  const SelectGenderWidget({super.key, required this.bloodDonationViewModel, required this.isArabic});

  final BloodDonationViewModel bloodDonationViewModel;
  final bool isArabic;

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        SizedBox(height: 8.h),
        SizedBox(
            height: MediaQuery.sizeOf(context).height * .4,
            child: ListView.separated(
                itemBuilder: (_, index) {
                  return DecoratedBox(
                      decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
                        color: AppColors.whiteColor,
                        borderRadius: 20.h,
                        hasShadow: false,
                      ),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Expanded(
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              spacing: 8.h,
                              children: [
                                (isArabic
                                  ? GenderTypeEnum.values[index].typeAr
                                  : GenderTypeEnum.values[index].type)
                                .toText16(color: AppColors.textColor, isBold: true)
                              ],
                            ),
                          ),
                          Transform.flip(
                            flipX: isArabic,
                            child: Utils.buildSvgWithAssets(
                              icon: AppAssets.forward_arrow_icon,
                              iconColor: AppColors.blackColor,
                              width: 40.h,
                              height: 40.h,
                              fit: BoxFit.contain,
                            ),
                          ),
                        ],
                      ).paddingSymmetrical(16.h, 16.h).onPress(() {
                        final genderValue =
                            // isArabic
                            //   ? GenderTypeEnum.values[index].typeAr

                            //   :
                            GenderTypeEnum.values[index].type;
                        bloodDonationViewModel.onGenderChange(genderValue);
                        Navigator.of(context).pop();
                      }));
                },
                separatorBuilder: (_, __) => SizedBox(
                      height: 8.h,
                    ),
                itemCount: GenderTypeEnum.values.length))
      ],
    );
  }
}
