import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../../../../Constants.dart';
import '../advance_payment_page.dart';

class SelectBeneficiaryDialog extends StatefulWidget {
  final BeneficiaryType beneficiaryType;
  final Function(BeneficiaryType) onValueSelected;

  SelectBeneficiaryDialog({Key key, this.beneficiaryType, this.onValueSelected});

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

class _SelectBeneficiaryDialogState extends State<SelectBeneficiaryDialog> {
  _SelectBeneficiaryDialogState(this.beneficiaryType);

  BeneficiaryType 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 = BeneficiaryType.MyAccount;
                        });
                      },
                      child: ListTile(
                        title: Text(
                          TranslationBase.of(context).myAccount,
                          style: TextStyle(
                            fontSize: 14,
                            fontWeight: FontWeight.w600,
                            letterSpacing: -0.46,
                          ),
                        ),
                        leading: Radio(
                          value: BeneficiaryType.MyAccount,
                          groupValue: beneficiaryType,
                          activeColor: secondaryColor,
                          onChanged: (BeneficiaryType value) {
                            setState(() {
                              beneficiaryType = value;
                            });
                          },
                        ),
                      ),
                    ),
                  )
                ],
              ),
              SizedBox(
                height: 5.0,
              ),
              Row(
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: InkWell(
                      onTap: () {
                        setState(() {
                          beneficiaryType = BeneficiaryType.MyFamilyFiles;
                        });
                      },
                      child: ListTile(
                        title: Text(
                          TranslationBase.of(context).myFamilyFiles,
                          style: TextStyle(
                            fontSize: 14,
                            fontWeight: FontWeight.w600,
                            letterSpacing: -0.46,
                          ),
                        ),
                        leading: Radio(
                          value: BeneficiaryType.MyFamilyFiles,
                          groupValue: beneficiaryType,
                          activeColor: Color(0xffC5272D),
                          onChanged: (BeneficiaryType value) {
                            setState(() {
                              beneficiaryType = value;
                            });
                          },
                        ),
                      ),
                    ),
                  )
                ],
              ),
              SizedBox(
                height: 5.0,
              ),
              Row(
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: InkWell(
                      onTap: () {
                        setState(() {
                          beneficiaryType = BeneficiaryType.OtherAccount;
                        });
                      },
                      child: ListTile(
                        title: Text(
                          TranslationBase.of(context).otherAccount,
                          style: TextStyle(
                            fontSize: 14,
                            fontWeight: FontWeight.w600,
                            letterSpacing: -0.46,
                          ),
                        ),
                        leading: Radio(
                          value: BeneficiaryType.OtherAccount,
                          groupValue: beneficiaryType,
                          activeColor: Color(0xffC5272D),
                          onChanged: (BeneficiaryType value) {
                            setState(() {
                              beneficiaryType = value;
                            });
                          },
                        ),
                      ),
                    ),
                  )
                ],
              ),
              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: Text(
                              TranslationBase.of(context).cancel.toUpperCase(),
                              style: TextStyle(
                                fontSize: 14,
                                fontWeight: FontWeight.w600,
                                letterSpacing: -0.46,
                                color: Color(0xffC5272D),
                              ),
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                  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: Text(
                            TranslationBase.of(context).ok.toUpperCase(),
                            style: TextStyle(
                              fontSize: 14,
                              fontWeight: FontWeight.w600,
                              letterSpacing: -0.46,
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              )
            ],
          ),
        )
      ],
    );
  }
}
