From 9d1e621769e4d0d521284d1be19fb5b95d239352 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 11 Jun 2025 15:34:16 +0300 Subject: [PATCH] feat(chat¬ifications): Issue-191 and Issue-440 and auth screen policy --- ios/Runner.xcodeproj/project.pbxproj | 6 +++--- ios/Runner/Info.plist | 6 +++--- lib/core/app_router.dart | 21 +++++++++++++++++++ lib/core/const.dart | 2 -- lib/core/firebase_api.dart | 5 ++--- lib/core/locator_service.dart | 2 ++ .../auth/presentation/pages/auth_screen.dart | 14 ++++++++++++- .../widgets/chat_bubble_widget.dart | 9 ++++---- pubspec.yaml | 1 + 9 files changed, 49 insertions(+), 17 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 63d0dd02..b7e87af6 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 = 25; + CURRENT_PROJECT_VERSION = 26; 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 = 25; + CURRENT_PROJECT_VERSION = 26; 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 = 25; + CURRENT_PROJECT_VERSION = 26; DEVELOPMENT_TEAM = VL68C36HYS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 2f074053..793b8e28 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 25 + 26 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS @@ -32,11 +32,11 @@ NSCameraUsageDescription - Нужно для загрузки фото + Предоставление доступа позволит Вам делать фотографии и добавлять к записям NSLocationWhenInUseUsageDescription NSPhotoLibraryUsageDescription - Нужно для загрузки фото + Предоставление доступа позволит Вам добавлять фото к записям UIApplicationSupportsIndirectInputEvents UIBackgroundModes diff --git a/lib/core/app_router.dart b/lib/core/app_router.dart index c849628d..0bd17c58 100644 --- a/lib/core/app_router.dart +++ b/lib/core/app_router.dart @@ -1,5 +1,9 @@ +import 'dart:io'; +import 'package:device_info_plus/device_info_plus.dart'; import 'package:dio/dio.dart'; import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/firebase_api.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/core/websockets/ws_manager.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/features/auth/presentation/pages/auth_screen.dart'; @@ -154,6 +158,23 @@ class AppRouter { name: 'welcomeScreen', builder: (context, state) => const WelcomeScreen(), redirect: (context, state) async { + try { + if (await TokenStorage.haveTokenInStorage()) { + final firebaseApi = sl(); + final fbToken = await firebaseApi.getToken(); + final deviceInfo = DeviceInfoPlugin(); + await sl().post( + '/api/profile/notification/token/register', + data: { + 'platform': Platform.isIOS ? 'ios': 'android', + 'hw_id': Platform.isIOS ? (await deviceInfo.iosInfo).identifierForVendor : (await deviceInfo.androidInfo).id, + 'token': fbToken, + }, + ); + } + } catch (e) { + rethrow; + } final sharedPreferences = await SharedPreferences.getInstance(); final welcomeScreenWasShowed = sharedPreferences.getBool('welcomeScreenWasShowed'); if (welcomeScreenWasShowed == true) { diff --git a/lib/core/const.dart b/lib/core/const.dart index 74e85d08..618a9866 100644 --- a/lib/core/const.dart +++ b/lib/core/const.dart @@ -1,6 +1,4 @@ -// 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/core/firebase_api.dart b/lib/core/firebase_api.dart index f83d47d6..fbf8e5c1 100644 --- a/lib/core/firebase_api.dart +++ b/lib/core/firebase_api.dart @@ -1,11 +1,10 @@ import 'package:firebase_messaging/firebase_messaging.dart'; class FirebaseApi { - final _firebaseMessaging = FirebaseMessaging.instance; - Future getToken() async{ + Future getToken() async { await _firebaseMessaging.requestPermission(); return await _firebaseMessaging.getToken(); } -} \ No newline at end of file +} diff --git a/lib/core/locator_service.dart b/lib/core/locator_service.dart index cd8731a3..ad23cce1 100644 --- a/lib/core/locator_service.dart +++ b/lib/core/locator_service.dart @@ -1,6 +1,7 @@ import 'package:dio/dio.dart'; import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/dio/phone_verify_error_interceptor.dart'; +import 'package:eatvio_app/core/firebase_api.dart'; import 'package:eatvio_app/core/interceptors/token_interceptor.dart'; import 'package:eatvio_app/core/websockets/ws_manager.dart'; import 'package:eatvio_app/core/websockets/ws_service.dart'; @@ -204,6 +205,7 @@ Future init() async { sl.registerLazySingleton(() => CreatePlanService(sl())); sl.registerLazySingleton(() => NotificationsService(sl())); sl.registerLazySingleton(() => MyRecipesService(sl())); + sl.registerLazySingleton(() => FirebaseApi()); // External sl.registerLazySingleton( diff --git a/lib/features/auth/presentation/pages/auth_screen.dart b/lib/features/auth/presentation/pages/auth_screen.dart index 20f5be91..5455d5fd 100644 --- a/lib/features/auth/presentation/pages/auth_screen.dart +++ b/lib/features/auth/presentation/pages/auth_screen.dart @@ -39,6 +39,7 @@ class _AuthScreenState extends State { late StreamSubscription keyboardSubscription; bool isFocused = false; int tapsCount = 0; + @override void initState() { super.initState(); @@ -148,7 +149,7 @@ class _AuthScreenState extends State { child: RichText( textAlign: TextAlign.center, text: TextSpan( - text: 'Нажимая "Войти", Вы соглашаетесь \n', + text: 'Нажимая "Войти" или "Зарегистрироваться", Вы соглашаетесь \n', style: const TextStyle( fontSize: 12, color: Colors.black, @@ -165,6 +166,17 @@ class _AuthScreenState extends State { ), recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('$baseUrl/oferta_bs.pdf')), ), + const TextSpan(text: ' и '), + TextSpan( + text: 'Политикой конфиденциальности\nи защитой персональных данных', + style: TextStyle( + fontSize: 12, + color: appTheme.blueA400, + decorationColor: appTheme.blueA400, + decoration: TextDecoration.underline, + ), + recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('$baseUrl/docs/privacy.pdf')), + ), ], ), ), diff --git a/lib/features/chat/presentation/widgets/chat_bubble_widget.dart b/lib/features/chat/presentation/widgets/chat_bubble_widget.dart index c0857612..b80b12ac 100644 --- a/lib/features/chat/presentation/widgets/chat_bubble_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_bubble_widget.dart @@ -1,6 +1,5 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:dismissible_page/dismissible_page.dart'; -import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/core/utils/date_time_utils.dart'; @@ -81,7 +80,7 @@ class ChatBubbleWidget extends StatelessWidget { contentPadding: const EdgeInsets.all(4), horizontalTitleGap: 8, onTap: () async { - if (!await launchUrl(Uri.parse('$baseUrl/storage/${mediaData[index]}'))) { + if (!await launchUrl(Uri.parse('${mediaData[index]}'))) { throw Exception('Could not launch ${mediaData[index].toString()}'); } }, @@ -108,18 +107,18 @@ class ChatBubbleWidget extends StatelessWidget { onTap: () { context.pushTransparentRoute( PhotoViewScreen( - imageUrls: mediaData.map((e) => '$baseUrl/storage/$e').toList(), + imageUrls: mediaData.map((e) => '$e').toList(), index: index, ), ); }, child: Hero( - tag: '$baseUrl/storage/${mediaData[index]}', + tag: '${mediaData[index]}', transitionOnUserGestures: true, child: ClipRRect( borderRadius: BorderRadius.circular(16), child: CachedNetworkImage( - imageUrl: '$baseUrl/storage/${mediaData[index]}', + imageUrl: '${mediaData[index]}', ), ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 34560571..7927f247 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -69,6 +69,7 @@ dependencies: shared_preferences: ^2.5.3 version: ^3.0.2 package_info_plus: ^8.3.0 + device_info_plus: ^11.4.0 dev_dependencies: build_runner: ^2.4.15