import 'package:flutter/material.dart';

import 'package:pweb/generated/i18n/app_localizations.dart';


Future<String?> requestVerificationEmail(
  BuildContext context,
  AppLocalizations locs,
) async {
  final controller = TextEditingController();
  final email = await showDialog<String>(
    context: context,
    builder: (dialogContext) => AlertDialog(
      title: Text(locs.signupConfirmationResend),
      content: TextField(
        controller: controller,
        autofocus: true,
        keyboardType: TextInputType.emailAddress,
        decoration: InputDecoration(
          labelText: locs.username,
          hintText: locs.usernameHint,
        ),
        onSubmitted: (_) =>
            Navigator.of(dialogContext).pop(controller.text.trim()),
      ),
      actions: [
        TextButton(
          onPressed: () => Navigator.of(dialogContext).pop(),
          child: Text(locs.cancel),
        ),
        FilledButton(
          onPressed: () =>
              Navigator.of(dialogContext).pop(controller.text.trim()),
          child: Text(locs.signupConfirmationResend),
        ),
      ],
    ),
  );
  controller.dispose();
  return email?.trim();
}
