import 'package:hmg_patient_app/pages/settings/settings.dart';
import 'package:hmg_patient_app/theme/colors.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/widgets/buttons/defaultButton.dart';
import 'package:hmg_patient_app/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ConfirmSendEmailDialog extends StatefulWidget {
  final String? email;
  final GestureTapCallback? onTapSendEmail;

  ConfirmSendEmailDialog({this.email, this.onTapSendEmail});

  @override
  _ConfirmSendEmailDialogState createState() => _ConfirmSendEmailDialogState();
}

class _ConfirmSendEmailDialogState extends State<ConfirmSendEmailDialog> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Dialog(
      backgroundColor: Colors.white,
      shape: RoundedRectangleBorder(),
      insetPadding: EdgeInsets.only(left: 21, right: 21),
      child: Container(
        padding: EdgeInsets.only(left: 20, right: 20, top: 36, bottom: 36),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Expanded(
                  child: Text(
                    TranslationBase.of(context).confirm,
                    style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: Color(0xff2B353E), height: 35 / 24, letterSpacing: -0.96),
                  ),
                ),
                IconButton(
                  padding: EdgeInsets.zero,
                  icon: Icon(Icons.close),
                  constraints: BoxConstraints(),
                  onPressed: () {
                    Navigator.pop(context);
                  },
                )
              ],
            ),
            Text(
              TranslationBase.of(context).sendConfEmail,
              style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff808080), letterSpacing: -0.48),
            ),
            SizedBox(height: 18),
            Container(
              padding: EdgeInsets.symmetric(vertical: 16, horizontal: 11),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(10.0)),
                color: Color(0xffEAEAEA),
              ),
              child: Row(
                children: [
                  Expanded(
                    child: Text(
                      widget.email!,
                      style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48),
                    ),
                  ),
                  IconButton(
                    padding: EdgeInsets.zero,
                    icon: Icon(Icons.edit),
                    iconSize: 16,
                    constraints: BoxConstraints(),
                    onPressed: () {
                      Navigator.pop(context);
                      Navigator.push(
                        context,
                        FadePage(
                          page: Settings(
                            type: 1,
                          ),
                        ),
                      );
                    },
                  )
                ],
              ),
            ),
            SizedBox(height: 18),
            Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                Expanded(
                  child: DefaultButton(
                    TranslationBase.of(context).cancel,
                    () {
                      Navigator.pop(context);
                    },
                    textColor: Colors.white,
                    color: CustomColors.accentColor,
                  ),
                ),
                SizedBox(width: 10),
                Expanded(
                  child: DefaultButton(
                    TranslationBase.of(context).send,
                    () {
                      Navigator.pop(context);
                      widget.onTapSendEmail!();
                    },
                    color: Color(0xff359846),
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
