From 8c0efc1a341c86da881f80234c8d754fa0296c25 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Mon, 9 Jun 2025 17:57:01 +0300 Subject: [PATCH] fix(chat®): fix chat screen, reg email valid --- lib/core/const.dart | 3 +- lib/features/chat/models/chat_user_model.dart | 1 - .../chat/presentation/pages/chat_screen.dart | 3 +- .../widgets/chat_entry_widget.dart | 3 +- .../presentation/pages/profile_screen.dart | 64 +++++++++---------- .../registration_cubit.dart | 29 ++++++--- .../repositories/registration_repository.dart | 15 +++++ 7 files changed, 70 insertions(+), 48 deletions(-) diff --git a/lib/core/const.dart b/lib/core/const.dart index 31c47e9c..52647d4f 100644 --- a/lib/core/const.dart +++ b/lib/core/const.dart @@ -1,4 +1,5 @@ -String baseUrl = 'https://eatvio.ru'; +String baseUrl = 'http://10.55.5.121:1092'; +// String baseUrl = 'https://eatvio.ru'; // String baseUrl = 'https://dev2.eatvio.com'; const List durationValues = [7, 14, 21]; diff --git a/lib/features/chat/models/chat_user_model.dart b/lib/features/chat/models/chat_user_model.dart index 14feb316..ad876727 100644 --- a/lib/features/chat/models/chat_user_model.dart +++ b/lib/features/chat/models/chat_user_model.dart @@ -9,7 +9,6 @@ abstract class ChatUserModel with _$ChatUserModel { required int id, required String name, required String slug, - @JsonKey(name: 'profile_photo_path') String? profilePhotoPath, @JsonKey(name: 'profile_photo_url') String? profilePhotoUrl, }) = _ChatUserModel; diff --git a/lib/features/chat/presentation/pages/chat_screen.dart b/lib/features/chat/presentation/pages/chat_screen.dart index 9cd3ff71..5ec98c6c 100644 --- a/lib/features/chat/presentation/pages/chat_screen.dart +++ b/lib/features/chat/presentation/pages/chat_screen.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'dart:math'; import 'package:easy_debounce/easy_debounce.dart'; -import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/widgets/custom_outlined_button.dart'; import 'package:eatvio_app/core/widgets/data_error_widget.dart'; import 'package:eatvio_app/core/widgets/loader.dart'; @@ -155,7 +154,7 @@ class _ChatScreenState extends State { if (state.chatRoom.users.receiver.profilePhotoUrl != null) CircleAvatar( radius: 20, - foregroundImage: NetworkImage(baseUrl + state.chatRoom.users.receiver.profilePhotoUrl!), + foregroundImage: NetworkImage(state.chatRoom.users.receiver.profilePhotoUrl!), backgroundImage: const AssetImage('assets/images/no_avatar.png'), ), if (state.chatRoom.users.receiver.profilePhotoUrl == null) diff --git a/lib/features/chat/presentation/widgets/chat_entry_widget.dart b/lib/features/chat/presentation/widgets/chat_entry_widget.dart index a6d5b3bb..1338c60b 100644 --- a/lib/features/chat/presentation/widgets/chat_entry_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_entry_widget.dart @@ -1,4 +1,3 @@ -import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/utils/date_time_utils.dart'; import 'package:eatvio_app/features/chat/models/chat_room_pagination_model.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; @@ -42,7 +41,7 @@ class _ChatEntryWidgetState extends State { CircleAvatar( radius: 24, foregroundImage: NetworkImage( - baseUrl + widget.chatRoom.users.toChatUser.profilePhotoUrl, + widget.chatRoom.users.toChatUser.profilePhotoUrl, ), backgroundImage: const AssetImage('assets/images/no_avatar.png'), backgroundColor: Colors.white, diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index ef9aac1a..363c2152 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -440,12 +440,12 @@ class _ProfileScreenState extends State { padding: const EdgeInsets.only(bottom: 16), child: Column( children: [ - const Padding( - padding: EdgeInsets.symmetric(horizontal: 16), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( + const Text( 'Дипломы\nи сертификаты', style: TextStyle( color: Color(0xFF323F4B), @@ -454,19 +454,19 @@ class _ProfileScreenState extends State { fontWeight: FontWeight.w600, ), ), - // GestureDetector( - // onTap: () { - // GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug); - // }, - // child: Text( - // widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '', - // style: const TextStyle( - // color: Color(0xFF2F80ED), - // fontSize: 16, - // fontWeight: FontWeight.w500, - // ), - // ), - // ), + GestureDetector( + onTap: () { + GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug); + }, + child: Text( + widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '', + style: const TextStyle( + color: Color(0xFF2F80ED), + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ), ], ), ), @@ -541,12 +541,12 @@ class _ProfileScreenState extends State { padding: const EdgeInsets.only(bottom: 16), child: Column( children: [ - const Padding( - padding: EdgeInsets.symmetric(horizontal: 16), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( + const Text( 'Образование', style: TextStyle( color: Color(0xFF323F4B), @@ -554,19 +554,19 @@ class _ProfileScreenState extends State { fontWeight: FontWeight.w600, ), ), - // GestureDetector( - // onTap: () { - // GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug); - // }, - // child: Text( - // widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '', - // style: const TextStyle( - // color: Color(0xFF2F80ED), - // fontSize: 16, - // fontWeight: FontWeight.w500, - // ), - // ), - // ), + GestureDetector( + onTap: () { + GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug); + }, + child: Text( + widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '', + style: const TextStyle( + color: Color(0xFF2F80ED), + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ), ], ), ), diff --git a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart index af748b69..1ccbde80 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart @@ -3,6 +3,7 @@ import 'dart:developer'; import 'package:eatvio_app/core/app_router.dart'; import 'package:eatvio_app/core/token_storage.dart'; +import 'package:eatvio_app/core/widgets/show_error_dialog.dart'; import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_state.dart'; import 'package:eatvio_app/features/registration/repositories/registration_repository.dart'; @@ -50,17 +51,25 @@ class RegistrationCubit extends Cubit { updateSheet(UserRegistrationSheet sheet) => emit(RegistrationState(sheet: sheet)); Future tryRegistration() async { - try { - final token = await registrationRepository.tryRegister( - state.sheet.copyWith( - phone: state.sheet.phone.replaceAll(' ', '').replaceAll('(', '').replaceAll(')', ''), - responseBody: '{}', - ), + if (await registrationRepository.emailIsReachable(state.sheet.email)) { + try { + final token = await registrationRepository.tryRegister( + state.sheet.copyWith( + phone: state.sheet.phone.replaceAll(' ', '').replaceAll('(', '').replaceAll(')', ''), + responseBody: '{}', + ), + ); + await TokenStorage.saveTokenInStorage(token); + AppRouter.navigatorKey.currentContext?.pushNamed('verifyEmailScreen'); + } catch (e) { + log(e.toString()); + } + } else { + showErrorDialog( + AppRouter.navigatorKey.currentContext!, + title: 'Ошибка регистрации', + description: 'Несуществующая почта.', ); - await TokenStorage.saveTokenInStorage(token); - AppRouter.navigatorKey.currentContext?.pushNamed('verifyEmailScreen'); - } catch (e) { - log(e.toString()); } } diff --git a/lib/features/registration/repositories/registration_repository.dart b/lib/features/registration/repositories/registration_repository.dart index e5a32e94..7a4a14ae 100644 --- a/lib/features/registration/repositories/registration_repository.dart +++ b/lib/features/registration/repositories/registration_repository.dart @@ -1,3 +1,5 @@ +import 'package:dio/dio.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/models/location_model.dart'; import 'package:eatvio_app/features/registration/services/registration_service.dart'; @@ -30,4 +32,17 @@ class RegistrationRepository { rethrow; } } + + Future emailIsReachable(String email) async { + try { + final response = await sl().getUri(Uri.parse('https://api.validate.email/validate?email=$email')); + if (response.data['result']['reachable'] != 'invalid') { + return true; + } else { + return false; + } + } catch (e) { + return false; + } + } }