From 7682859d3208fd5eede01a9d3720f2d4b0538842 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 18 Jun 2025 16:56:42 +0300 Subject: [PATCH] fix: Issue-514 BlackScreens + info for apple --- android/app/src/main/AndroidManifest.xml | 1 + ios/Runner.xcodeproj/project.pbxproj | 6 +- ios/Runner/Info.plist | 4 +- lib/core/app_router.dart | 15 +- .../auth/presentation/pages/auth_screen.dart | 24 ++- .../widgets/bottom_navigation_bar_widget.dart | 4 +- .../widgets/blog_post_widget.dart | 144 +++++++++--------- .../presentation/widgets/comments_widget.dart | 6 +- .../presentation/pages/profile_screen.dart | 9 +- .../widgets/profile_blog_post_widget.dart | 7 +- .../presentation/pages/welcome_screen.dart | 10 +- lib/main.dart | 16 +- pubspec.yaml | 2 +- 13 files changed, 138 insertions(+), 110 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index c7878e41..d8c4ec86 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -5,6 +5,7 @@ CFBundleSignature ???? CFBundleVersion - 27 + 28 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS @@ -31,6 +31,8 @@ NSAllowsArbitraryLoads + NSAppleMusicUsageDescription + This permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us. NSCameraUsageDescription Предоставление доступа позволит Вам делать фотографии и добавлять к записям NSLocationWhenInUseUsageDescription diff --git a/lib/core/app_router.dart b/lib/core/app_router.dart index 7291ed95..d8da4a42 100644 --- a/lib/core/app_router.dart +++ b/lib/core/app_router.dart @@ -158,6 +158,7 @@ class AppRouter { name: 'welcomeScreen', builder: (context, state) => const WelcomeScreen(), redirect: (context, state) async { + try { if (await TokenStorage.haveTokenInStorage()) { final firebaseApi = sl(); @@ -172,19 +173,17 @@ class AppRouter { }, ); } - } catch (e) { - rethrow; - } - try { final sharedPreferences = await SharedPreferences.getInstance(); - final welcomeScreenWasShowed = sharedPreferences.getBool('welcomeScreenWasShowed'); - if (welcomeScreenWasShowed == true) { + final welcomeScreenWasShowed = sharedPreferences.getBool('welcomeScreenWasShowed') ?? false; + if (welcomeScreenWasShowed == false) { + return null; + } else if (await TokenStorage.haveTokenInStorage()) { return '/feed-screen'; } else { - return null; + return '/auth-screen'; } } catch (e) { - return '/feed-screen'; + rethrow; } }, ), diff --git a/lib/features/auth/presentation/pages/auth_screen.dart b/lib/features/auth/presentation/pages/auth_screen.dart index 5455d5fd..179e0974 100644 --- a/lib/features/auth/presentation/pages/auth_screen.dart +++ b/lib/features/auth/presentation/pages/auth_screen.dart @@ -52,15 +52,23 @@ class _AuthScreenState extends State { } Future _reconnectWebSocket(BuildContext context) async { - await sl().clear(); - await sl().initialize(); + try { + await sl().clear(); + await sl().initialize(); + } catch (e) { + rethrow; + } if (context.mounted) { - context.read().getMyProfile(); - context.read().getChatRoomsWithLoading(); - context.read().connectToWebSocket(); - context.read().getNotifications(); - context.read().connectToWebSocket(); - showSuccessToast('Успешный вход'); + try { + context.read().getMyProfile(); + context.read().getChatRoomsWithLoading(); + context.read().connectToWebSocket(); + context.read().getNotifications(); + context.read().connectToWebSocket(); + showSuccessToast('Успешный вход'); + } catch (e) { + rethrow; + } GoRouter.of(context).go('/feed-screen', extra: {'needToInitializeWebSocket': false}); } } diff --git a/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart b/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart index 0fae58a6..e370452a 100644 --- a/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart +++ b/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart @@ -82,7 +82,9 @@ class _BottomNavigationBarWidgetState extends State { BottomNavigationBarItem( label: '', icon: CircleAvatar( - foregroundImage: NetworkImage(baseUrl + widget.profileModel.profilePhotoUrl), + foregroundImage: NetworkImage( + widget.profileModel.profilePhotoUrl.contains('https') ? widget.profileModel.profilePhotoUrl : baseUrl + widget.profileModel.profilePhotoUrl, + ), backgroundImage: const AssetImage('assets/images/no_avatar.png'), radius: 16, ), diff --git a/lib/features/feed/presentation/widgets/blog_post_widget.dart b/lib/features/feed/presentation/widgets/blog_post_widget.dart index bc7faec0..b349f8fa 100644 --- a/lib/features/feed/presentation/widgets/blog_post_widget.dart +++ b/lib/features/feed/presentation/widgets/blog_post_widget.dart @@ -56,81 +56,85 @@ class _BlogPostWidgetState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 12), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 12), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - GestureDetector( - onTap: () { - GoRouter.of(context).pushNamed( - 'profileScreen', - extra: Author( - authorSlug: state.feedBlogPostList[widget.index].author.authorSlug, - authorName: state.feedBlogPostList[widget.index].author.authorName, - authorProfileIcon: state.feedBlogPostList[widget.index].author.authorProfileIcon, - authorIsMe: state.feedBlogPostList[widget.index].author.authorIsMe, - ), - ); - }, - child: CircleAvatar( - radius: 20, - backgroundColor: Colors.black12, - foregroundImage: NetworkImage( - baseUrl + state.feedBlogPostList[widget.index].author.authorProfileIcon, - ), - backgroundImage: const AssetImage('assets/images/no_avatar.png'), - ), - ), - const SizedBox(width: 8), - // Имя и дата внутри Expanded - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - state.feedBlogPostList[widget.index].author.authorName, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - height: 1, - color: Colors.black87, - fontWeight: FontWeight.w500, - fontSize: 16, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + GestureDetector( + onTap: () { + GoRouter.of(context).pushNamed( + 'profileScreen', + extra: Author( + authorSlug: state.feedBlogPostList[widget.index].author.authorSlug, + authorName: state.feedBlogPostList[widget.index].author.authorName, + authorProfileIcon: state.feedBlogPostList[widget.index].author.authorProfileIcon.contains('https') + ? state.feedBlogPostList[widget.index].author.authorProfileIcon + : baseUrl + state.feedBlogPostList[widget.index].author.authorProfileIcon, + authorIsMe: state.feedBlogPostList[widget.index].author.authorIsMe, ), + ); + }, + child: CircleAvatar( + radius: 20, + backgroundColor: Colors.black12, + foregroundImage: NetworkImage( + state.feedBlogPostList[widget.index].author.authorProfileIcon.contains('https') + ? state.feedBlogPostList[widget.index].author.authorProfileIcon + : baseUrl + state.feedBlogPostList[widget.index].author.authorProfileIcon, ), - const SizedBox(height: 4), - Text( - '${calculateDifference(state.feedBlogPostList[widget.index].createdAt)} в ${state.feedBlogPostList[widget.index].createdAt.hour.toString().padLeft(2, '0')}:${state.feedBlogPostList[widget.index].createdAt.minute.toString().padLeft(2, '0')}', - style: const TextStyle( - height: 1, - color: Colors.black45, - fontSize: 14, - ), - ), - ], - ), - ), - // Кнопка подписки (если нужно) - if (!(state.feedBlogPostList[widget.index].author.isEntitySubscribedByMe ?? false) && - !state.feedBlogPostList[widget.index].author.authorIsMe) - Padding( - padding: const EdgeInsets.only(right: 8), - child: SubscribeButtonWidget( - slug: state.feedBlogPostList[widget.index].author.authorSlug, + backgroundImage: const AssetImage('assets/images/no_avatar.png'), ), ), - // Кнопка меню - CustomPopup( - isAuthor: state.feedBlogPostList[widget.index].author.authorIsMe, - complainedContentType: ComplainedContent.posts, - path: 'blog_post/${(state.feedBlogPostList[widget.index].id)}', - id: state.feedBlogPostList[widget.index].id, - feedBlogPostModel: state.feedBlogPostList[widget.index], - ), - ], + const SizedBox(width: 8), + // Имя и дата внутри Expanded + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + state.feedBlogPostList[widget.index].author.authorName, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + height: 1, + color: Colors.black87, + fontWeight: FontWeight.w500, + fontSize: 16, + ), + ), + const SizedBox(height: 4), + Text( + '${calculateDifference(state.feedBlogPostList[widget.index].createdAt)} в ${state.feedBlogPostList[widget.index].createdAt.hour.toString().padLeft(2, '0')}:${state.feedBlogPostList[widget.index].createdAt.minute.toString().padLeft(2, '0')}', + style: const TextStyle( + height: 1, + color: Colors.black45, + fontSize: 14, + ), + ), + ], + ), + ), + // Кнопка подписки (если нужно) + if (!(state.feedBlogPostList[widget.index].author.isEntitySubscribedByMe ?? false) && + !state.feedBlogPostList[widget.index].author.authorIsMe) + Padding( + padding: const EdgeInsets.only(right: 8), + child: SubscribeButtonWidget( + slug: state.feedBlogPostList[widget.index].author.authorSlug, + ), + ), + // Кнопка меню + CustomPopup( + isAuthor: state.feedBlogPostList[widget.index].author.authorIsMe, + complainedContentType: ComplainedContent.posts, + path: 'blog_post/${(state.feedBlogPostList[widget.index].id)}', + id: state.feedBlogPostList[widget.index].id, + feedBlogPostModel: state.feedBlogPostList[widget.index], + ), + ], + ), ), - ), - if (state.feedBlogPostList[widget.index].title.isNotEmpty) ...[ + if (state.feedBlogPostList[widget.index].title.isNotEmpty) ...[ const SizedBox(height: 12), Padding( padding: const EdgeInsets.symmetric(horizontal: 12), diff --git a/lib/features/feed/presentation/widgets/comments_widget.dart b/lib/features/feed/presentation/widgets/comments_widget.dart index 16f52f90..1e1a90d5 100644 --- a/lib/features/feed/presentation/widgets/comments_widget.dart +++ b/lib/features/feed/presentation/widgets/comments_widget.dart @@ -72,13 +72,15 @@ class _CommentsWidgetState extends State { extra: Author( authorSlug: comment.authorSlug, authorName: comment.authorName, - authorProfileIcon: comment.authorProfileIcon, + authorProfileIcon: comment.authorProfileIcon.contains('https') ? comment.authorProfileIcon : baseUrl + comment.authorProfileIcon, authorIsMe: (sl().state as ProfileAvatarStateLoaded).profile.slug == comment.authorSlug ? true : false, ), ); }, child: CircleAvatar( - foregroundImage: NetworkImage(baseUrl + comment.authorProfileIcon), + foregroundImage: NetworkImage( + comment.authorProfileIcon.contains('https') ? comment.authorProfileIcon : baseUrl + comment.authorProfileIcon, + ), backgroundImage: const AssetImage('assets/images/no_avatar.png'), radius: radius, ), diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index 363c2152..70bd7e84 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -600,9 +600,7 @@ 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; + final formattedDate = parsedDate != null ? DateFormat('d MMMM y', 'ru_RU').format(parsedDate) : date; return SizedBox( width: double.infinity, @@ -640,7 +638,6 @@ class _ProfileScreenState extends State { ); } - _socialLinks(ProfileStateLoaded state) { if (!state.profile.roles.contains('consultant')) { return const SizedBox.shrink(); @@ -1065,7 +1062,9 @@ class _ProfileScreenState extends State { tag: state.profile.profilePhotoUrl, child: CircleAvatar( radius: 32, - foregroundImage: NetworkImage(baseUrl + state.profile.profilePhotoUrl), + foregroundImage: NetworkImage( + state.profile.profilePhotoUrl.contains('https') ? state.profile.profilePhotoUrl : baseUrl + state.profile.profilePhotoUrl, + ), backgroundImage: const AssetImage('assets/images/no_avatar.png'), ), ), diff --git a/lib/features/profile/presentation/widgets/profile_blog_post_widget.dart b/lib/features/profile/presentation/widgets/profile_blog_post_widget.dart index 18f2a878..5ac4d60e 100644 --- a/lib/features/profile/presentation/widgets/profile_blog_post_widget.dart +++ b/lib/features/profile/presentation/widgets/profile_blog_post_widget.dart @@ -67,7 +67,9 @@ class _ProfileBlogPostWidgetState extends State { radius: 20, backgroundColor: Colors.black12, foregroundImage: NetworkImage( - baseUrl + state.blogPosts[widget.index].author.authorProfileIcon, + state.blogPosts[widget.index].author.authorProfileIcon.contains('https') + ? state.blogPosts[widget.index].author.authorProfileIcon + : baseUrl + state.blogPosts[widget.index].author.authorProfileIcon, ), backgroundImage: const AssetImage('assets/images/no_avatar.png'), ), @@ -119,8 +121,7 @@ class _ProfileBlogPostWidgetState extends State { ), ], if (state.blogPosts[widget.index].title.isEmpty) const SizedBox(height: 8), - if (state.blogPosts[widget.index].title.isNotEmpty && state.blogPosts[widget.index].description.isNotEmpty) - const SizedBox(height: 8), + if (state.blogPosts[widget.index].title.isNotEmpty && state.blogPosts[widget.index].description.isNotEmpty) const SizedBox(height: 8), if (state.blogPosts[widget.index].description.isNotEmpty) Padding( padding: const EdgeInsets.symmetric(horizontal: 4), diff --git a/lib/features/welcome/presentation/pages/welcome_screen.dart b/lib/features/welcome/presentation/pages/welcome_screen.dart index 25922a10..31b4bf0f 100644 --- a/lib/features/welcome/presentation/pages/welcome_screen.dart +++ b/lib/features/welcome/presentation/pages/welcome_screen.dart @@ -1,9 +1,9 @@ +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; import 'package:shared_preferences/shared_preferences.dart'; - -import '../../../../core/theme/theme_helper.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart'; class WelcomeScreen extends StatefulWidget { @@ -82,7 +82,11 @@ class _WelcomeScreenState extends State { onTap: () async { final sharedPreferences = await SharedPreferences.getInstance(); await sharedPreferences.setBool('welcomeScreenWasShowed', true); - goRouter.go('/feed-screen'); + if (await TokenStorage.haveTokenInStorage()) { + goRouter.go('/feed-screen'); + } else { + goRouter.go('/auth-screen'); + } }, borderRadius: BorderRadius.circular(8), child: Ink( diff --git a/lib/main.dart b/lib/main.dart index 1616d9eb..a712f6e3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,14 +20,20 @@ import 'package:keyboard_dismisser/keyboard_dismisser.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; Future main() async { - WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); + WidgetsBinding widgetsBinding = SentryWidgetsFlutterBinding.ensureInitialized(); FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding); + await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); await di.init(); - await SentryFlutter.init((options) { - options.dsn = 'http://ba7f2653067776f3034e6e89850e85a1@sentry.md-desk.ru:9000/2'; - options.tracesSampleRate = 1.0; - }, appRunner: () => runApp(const MyApp())); + + await SentryFlutter.init( + (options) { + options.dsn = 'http://ba7f2653067776f3034e6e89850e85a1@sentry.md-desk.ru:9000/2'; + options.tracesSampleRate = 1.0; + options.debug = false; + }, + appRunner: () => runApp(const MyApp()), + ); } class MyApp extends StatelessWidget { diff --git a/pubspec.yaml b/pubspec.yaml index c9e7430b..0a1982b6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: eatvio_app description: A new Flutter project. -version: 1.1.4+34 +version: 1.1.5+35 publish_to: 'none' environment: