import 'package:hmg_patient_app/pages/Blood/blood_donation.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class SelectGenderDialog extends StatefulWidget {
  final Gender beneficiaryType;
  final Function(Gender) onValueSelected;

  SelectGenderDialog({Key? key, required this.beneficiaryType, required this.onValueSelected});

  @override
  _SelectGenderDialogState createState() =>
      _SelectGenderDialogState(this.beneficiaryType);
}

class _SelectGenderDialogState extends State<SelectGenderDialog> {
  _SelectGenderDialogState(this.beneficiaryType);
  Gender beneficiaryType;

  @override
  Widget build(BuildContext context) {
    return SimpleDialog(
      children: [
        Container(
          child: Column(
            children: [
              Divider(),
              Row(
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: InkWell(
                      onTap: () {
                        setState(() {
                          beneficiaryType = Gender.Male;
                        });
                      },
                      child: ListTile(
                        title: Text(TranslationBase.of(context).male),
                        leading: Radio(
                          value: Gender.Male,
                          groupValue: beneficiaryType,
                          activeColor: Colors.red[800],
                          onChanged: (Gender? value) {
                            setState(() {
                              beneficiaryType = value!;
                            });
                          },
                        ),
                      ),
                    ),
                  )
                ],
              ),
              SizedBox(
                height: 5.0,
              ),
              Row(
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: InkWell(
                      onTap: () {
                        setState(() {
                          beneficiaryType = Gender.Female;
                        });
                      },
                      child: ListTile(
                        title: Text(TranslationBase.of(context).female),
                        leading:  Radio(
                          value: Gender.Female,
                          groupValue: beneficiaryType,
                          activeColor: Colors.red[800],
                          onChanged: (Gender? value) {
                            setState(() {
                              beneficiaryType = value!;
                            });
                          },
                        ),
                      ),
                    ),
                  )
                ],
              ),
              SizedBox(
                height: 5.0,
              ),
              SizedBox(
                height: 5.0,
              ),
              Row(
                // mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: InkWell(
                      onTap: () {
                        Navigator.pop(context);
                      },
                      child: Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: Container(
                          child: Center(
                            child: Texts(
                              TranslationBase.of(context).cancel.toUpperCase(),
                              color: Colors.red,
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                  Container(
                    width: 1,
                    height: 30,
                    color: Colors.grey[500],
                  ),
                  Expanded(
                    flex: 1,
                    child: InkWell(
                      onTap: () {
                        widget.onValueSelected(beneficiaryType);
                        Navigator.pop(context);
                      },
                      child: Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: Center(
                          child: Texts(
                            TranslationBase.of(context).ok,
                            fontWeight: FontWeight.w400,
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              )
            ],
          ),
        )
      ],
    );
  }
}
