From 7c354cc0a321a5ce6d80e3d3485bb21c684d2c9b Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Mon, 2 Jun 2025 17:51:27 +0300 Subject: [PATCH] feat(consultant): ***WIP: consultant request status in settings --- ios/Runner.xcodeproj/project.pbxproj | 6 +-- ios/Runner/Info.plist | 2 +- lib/core/const.dart | 2 +- lib/core/locator_service.dart | 2 +- .../presentation/pages/profile_screen.dart | 9 +++- .../bloc/settings_cubit/settings_cubit.dart | 24 +++++++-- .../bloc/settings_cubit/settings_state.dart | 2 + .../presentation/pages/settings_screen.dart | 50 +++++++++---------- 8 files changed, 59 insertions(+), 38 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index d535af69..b77d4412 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -388,7 +388,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 21; + CURRENT_PROJECT_VERSION = 22; DEVELOPMENT_TEAM = VL68C36HYS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -538,7 +538,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 21; + CURRENT_PROJECT_VERSION = 22; DEVELOPMENT_TEAM = VL68C36HYS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -576,7 +576,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 21; + CURRENT_PROJECT_VERSION = 22; DEVELOPMENT_TEAM = VL68C36HYS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 498d4b70..2b0b59b5 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 21 + 22 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/lib/core/const.dart b/lib/core/const.dart index 73e7ecfd..31c47e9c 100644 --- a/lib/core/const.dart +++ b/lib/core/const.dart @@ -1,4 +1,4 @@ - String baseUrl = 'https://eatvio.ru'; +String baseUrl = 'https://eatvio.ru'; // String baseUrl = 'https://dev2.eatvio.com'; const List durationValues = [7, 14, 21]; diff --git a/lib/core/locator_service.dart b/lib/core/locator_service.dart index 9ee53c7c..cd8731a3 100644 --- a/lib/core/locator_service.dart +++ b/lib/core/locator_service.dart @@ -120,7 +120,7 @@ Future init() async { sl.registerFactory(() => DietsCubit(feedRepository: sl(), dietsRepository: sl())); sl.registerFactory(() => CommentsCubit(feedRepository: sl())); sl.registerFactory(() => PlansCubit(feedRepository: sl(), planRepository: sl())); - sl.registerFactory(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl())); + sl.registerFactory(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl(), consultantRepository: sl())); sl.registerFactory(() => RegisterConsultantCubit(consultantRepository: sl())); sl.registerFactory( () => DiaryCubit(chatRepository: sl(), diaryRepository: sl(), glossaryRepository: sl(), profileRepository: sl(), dietRepository: sl())); diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index 6c91bbff..b9ecfff6 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -33,6 +33,7 @@ import 'package:flutter_native_splash/flutter_native_splash.dart'; import 'package:go_router/go_router.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:intl/intl.dart'; import 'package:share_plus/share_plus.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -594,6 +595,11 @@ class _ProfileScreenState extends State { } _educationBlock(String title, String date) { + final parsedDate = DateTime.tryParse(date); + final formattedDate = parsedDate != null + ? DateFormat('d MMMM y', 'ru_RU').format(parsedDate) + : date; + return SizedBox( width: double.infinity, child: Material( @@ -615,7 +621,7 @@ class _ProfileScreenState extends State { ), const SizedBox(height: 4), Text( - date, + formattedDate, style: const TextStyle( height: 1, color: Color(0xFF6D6F71), @@ -630,6 +636,7 @@ class _ProfileScreenState extends State { ); } + _socialLinks(ProfileStateLoaded state) { if (!state.profile.roles.contains('consultant')) { return const SizedBox.shrink(); diff --git a/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart b/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart index f0a388a4..1bc68637 100644 --- a/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart +++ b/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart @@ -1,3 +1,5 @@ +import 'package:eatvio_app/features/consultant/become_consultant/models/consultation_request_model.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/repositories/consultant_repository.dart'; import 'package:eatvio_app/features/profile/models/profile_model.dart'; import 'package:eatvio_app/features/profile/repositories/profile_repository.dart'; import 'package:eatvio_app/features/settings/models/profile_settings_model.dart'; @@ -8,19 +10,31 @@ import 'package:flutter_bloc/flutter_bloc.dart'; class SettingsCubit extends Cubit { final ProfileRepository profileRepository; final SettingsRepository settingsRepository; + final ConsultantRepository consultantRepository; SettingsCubit({ required this.profileRepository, required this.settingsRepository, + required this.consultantRepository, }) : super(const SettingsState.loading()); Future init() async { + final profile = await profileRepository.getMyProfile(); + late final ConsultationRequestModel? consultantInfo; try { - emit(SettingsState.loaded( - profileSettings: await settingsRepository.getProfileSettings(), - profileDetails: await profileRepository.getMyProfileDetails(), - profile: await profileRepository.getMyProfile(), - ),); + consultantInfo = await consultantRepository.getMyRequestStatus(profile.slug); + } catch (e) { + consultantInfo = null; + } + try { + emit( + SettingsState.loaded( + profileSettings: await settingsRepository.getProfileSettings(), + profileDetails: await profileRepository.getMyProfileDetails(), + profile: profile, + consultationRequestModel: consultantInfo, + ), + ); } catch (e) { emit(SettingsState.error(errorMessage: e.toString())); } diff --git a/lib/features/settings/presentation/bloc/settings_cubit/settings_state.dart b/lib/features/settings/presentation/bloc/settings_cubit/settings_state.dart index 34922051..f220fe5e 100644 --- a/lib/features/settings/presentation/bloc/settings_cubit/settings_state.dart +++ b/lib/features/settings/presentation/bloc/settings_cubit/settings_state.dart @@ -1,3 +1,4 @@ +import 'package:eatvio_app/features/consultant/become_consultant/models/consultation_request_model.dart'; import 'package:eatvio_app/features/profile/models/profile_model.dart'; import 'package:eatvio_app/features/settings/models/profile_settings_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; @@ -14,6 +15,7 @@ abstract class SettingsState with _$SettingsState { required ProfileSettingsModel profileSettings, required ProfileDetailsModel profileDetails, required ProfileModel profile, + ConsultationRequestModel? consultationRequestModel, }) = SettingsStateLoaded; const factory SettingsState.error({ diff --git a/lib/features/settings/presentation/pages/settings_screen.dart b/lib/features/settings/presentation/pages/settings_screen.dart index 18d6a261..7c4ab26e 100644 --- a/lib/features/settings/presentation/pages/settings_screen.dart +++ b/lib/features/settings/presentation/pages/settings_screen.dart @@ -58,11 +58,7 @@ class _SettingsScreenState extends State { const SizedBox(height: 12), _aboutEatvio(state), const SizedBox(height: 12), - if (!state.profile.roles.contains('consultant')) - Padding( - padding: const EdgeInsets.only(bottom: 8), - child: _becomeConsultantButton(state), - ), + _becomeConsultantButton(state), _deleteAccountButton(state), ], ), @@ -355,31 +351,33 @@ class _SettingsScreenState extends State { } _becomeConsultantButton(SettingsStateLoaded state) { - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: InkWell( - onTap: () => GoRouter.of(context).pushNamed('becomeConsultantScreen'), - borderRadius: BorderRadius.circular(20), - child: Ink( - height: 52, - width: MediaQuery.of(context).size.width - 16, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: appTheme.blueA400, - ), - child: const Center( - child: Text( - 'Стать консультантом', - style: TextStyle( - color: Colors.white, - height: 1, - fontSize: 18, + if (state.consultationRequestModel == null) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 16) + const EdgeInsets.only(bottom: 8), + child: InkWell( + onTap: () => GoRouter.of(context).pushNamed('becomeConsultantScreen'), + borderRadius: BorderRadius.circular(20), + child: Ink( + height: 52, + width: MediaQuery.of(context).size.width - 16, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: appTheme.blueA400, + ), + child: const Center( + child: Text( + 'Стать консультантом', + style: TextStyle( + color: Colors.white, + height: 1, + fontSize: 18, + ), ), ), ), ), - ), - ); + ); + } } _deleteAccountButton(SettingsStateLoaded state) {