From 12bf9f9e5f7177d40e357c33e0707faa5155079c Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 27 Aug 2025 14:39:22 +0300 Subject: [PATCH] feat(verify_email): add dialog --- .../pages/verify_email_screen.dart | 17 +++- .../widgets/code_not_received_dialog.dart | 82 +++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 lib/features/registration/presentation/widgets/code_not_received_dialog.dart diff --git a/lib/features/registration/presentation/pages/verify_email_screen.dart b/lib/features/registration/presentation/pages/verify_email_screen.dart index 8d1ef619..4ade2581 100644 --- a/lib/features/registration/presentation/pages/verify_email_screen.dart +++ b/lib/features/registration/presentation/pages/verify_email_screen.dart @@ -8,6 +8,7 @@ import 'package:eatvio_app/core/widgets/custom_outlined_button.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/verify_email_cubit/verify_email_cubit.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/verify_email_cubit/verify_email_state.dart'; import 'package:eatvio_app/features/registration/presentation/widgets/change_email_dialog.dart'; +import 'package:eatvio_app/features/registration/presentation/widgets/code_not_received_dialog.dart'; import 'package:eatvio_app/features/registration/services/registration_analytics_service.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -113,7 +114,21 @@ class _VerifyEmailScreenState extends State { Text("Код отправлен на почту\n$email", textAlign: TextAlign.center), const SizedBox(height: 20), Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: List.generate(4, (index) => _buildCodeField(context, index))), - const SizedBox(height: 40), + const SizedBox(height: 16), + GestureDetector( + onTap: () { + final verifyEmailCubit = context.read(); + showDialog(context: context, builder: (context) => CodeNotReceivedDialog( + currentEmail: email, + verifyEmailCubit: verifyEmailCubit, + )); + }, + child: Text( + 'Не приходит код?', + style: TextStyles.textSMedium.copyWith(color: appTheme.blueA400, decoration: TextDecoration.underline), + ), + ), + const SizedBox(height: 24), CustomOutlinedButton( text: 'Запросить код повторно', height: 52, diff --git a/lib/features/registration/presentation/widgets/code_not_received_dialog.dart b/lib/features/registration/presentation/widgets/code_not_received_dialog.dart new file mode 100644 index 00000000..c59d80d9 --- /dev/null +++ b/lib/features/registration/presentation/widgets/code_not_received_dialog.dart @@ -0,0 +1,82 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/gestures.dart'; +import 'package:eatvio_app/core/theme/custom_text_style.dart'; +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/features/registration/presentation/widgets/change_email_dialog.dart'; +import 'package:eatvio_app/features/registration/presentation/bloc/verify_email_cubit/verify_email_cubit.dart'; + +class CodeNotReceivedDialog extends StatelessWidget { + final String currentEmail; + final VerifyEmailCubit verifyEmailCubit; + + const CodeNotReceivedDialog({ + super.key, + required this.currentEmail, + required this.verifyEmailCubit + }); + + void _showChangeEmailDialog(BuildContext context) { + Navigator.of(context).pop(); // Закрываем текущий диалог + showDialog( + context: context, + builder: (context) => ChangeEmailDialog( + currentEmail: currentEmail, + verifyEmailCubit: verifyEmailCubit, + ), + ); + } + + @override + Widget build(BuildContext context) { + return Dialog( + backgroundColor: Colors.transparent, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16.0), + border: Border.all(color: Colors.grey[800]!, width: 2.0), + ), + padding: const EdgeInsets.all(24.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text('Почему может не приходить код?', style: TextStyles.textLSemibold.copyWith(color: appTheme.black)), + const SizedBox(height: 16), + RichText( + text: TextSpan( + style: TextStyles.textMMedium.copyWith(color: appTheme.gray600), + children: [ + const TextSpan(text: 'Опечатка в email: Если адрес введён неправильно, код не придёт. '), + TextSpan( + text: 'Ввести email повторно.', + style: TextStyles.textMMedium.copyWith( + color: appTheme.blueA400, + decoration: TextDecoration.underline, + ), + recognizer: TapGestureRecognizer() + ..onTap = () => _showChangeEmailDialog(context), + ), + const TextSpan(text: '\n\nПроверьте спам/промо/мусорную папку: Код может попасть туда из-за фильтров почтового провайдера\n\nПодождите 1-2 минуты: Иногда email задерживается из-за сетевых проблем.\n\nУбедитесь в стабильном соединении: Проверьте интернет и уведомления на устройстве.'), + ], + ), + ), + const SizedBox(height: 24), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () => Navigator.of(context).pop(), + style: ElevatedButton.styleFrom( + backgroundColor: appTheme.blueA400, + foregroundColor: Colors.white, + padding: const EdgeInsets.symmetric(vertical: 16), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + ), + child: Text('Понятно', style: TextStyles.textMSemibold.copyWith(color: Colors.white)), + ), + ), + ], + ), + ), + ); + } +}