diff --git a/lib/assets/icons/CONCEPTS_N.png b/lib/assets/icons/CONCEPTS_N.png new file mode 100644 index 0000000..18efa35 Binary files /dev/null and b/lib/assets/icons/CONCEPTS_N.png differ diff --git a/lib/assets/icons/INDUSTRY_ENVIRONMENT_N.png b/lib/assets/icons/INDUSTRY_ENVIRONMENT_N.png new file mode 100644 index 0000000..4da3480 Binary files /dev/null and b/lib/assets/icons/INDUSTRY_ENVIRONMENT_N.png differ diff --git a/lib/assets/icons/MACRO_ENVIRONMENT_N.png b/lib/assets/icons/MACRO_ENVIRONMENT_N.png new file mode 100644 index 0000000..1650a75 Binary files /dev/null and b/lib/assets/icons/MACRO_ENVIRONMENT_N.png differ diff --git a/lib/assets/icons/MACRO_TRENDS_N.png b/lib/assets/icons/MACRO_TRENDS_N.png new file mode 100644 index 0000000..5724e38 Binary files /dev/null and b/lib/assets/icons/MACRO_TRENDS_N.png differ diff --git a/lib/assets/icons/MODERN_INVESTMENTS_N.png b/lib/assets/icons/MODERN_INVESTMENTS_N.png new file mode 100644 index 0000000..c2fb4ba Binary files /dev/null and b/lib/assets/icons/MODERN_INVESTMENTS_N.png differ diff --git a/lib/models/story_model.dart b/lib/models/story_model.dart index 22d9b98..6d747a9 100644 --- a/lib/models/story_model.dart +++ b/lib/models/story_model.dart @@ -97,9 +97,9 @@ class UserStories { String _mapCategoryToIcon(String category) { switch (category) { case 'MACRO_TRENDS': - return 'lib/assets/icons/MACRO_TRENDS.svg'; + return 'lib/assets/icons/MACRO_TRENDS_N.png'; case 'INDUSTRY_ENVIRONMENT': - return 'lib/assets/icons/INDUSTRY_ENVIRONMENT.svg'; + return 'lib/assets/icons/INDUSTRY_ENVIRONMENT_N.png'; case 'COMPETITION_ENVIRONMENT': return Assets.startup; case 'OPPORTUNITIES': @@ -111,11 +111,11 @@ String _mapCategoryToIcon(String category) { case 'STARTUPS': return Assets.startup; case 'CONCEPTS': - return 'lib/assets/icons/CONCEPTS.svg'; + return 'lib/assets/icons/CONCEPTS_N.png'; case 'MACRO_ENVIRONMENT': - return 'lib/assets/icons/MACRO_ENVIRONMENT.svg'; + return 'lib/assets/icons/MACRO_ENVIRONMENT_N.png'; case 'MODERN_INVESTMENTS': - return 'lib/assets/icons/MODERN_INVESTMENTS.svg'; + return 'lib/assets/icons/MODERN_INVESTMENTS_N.png'; default: return Assets.stats; } diff --git a/lib/views/ai_section/widgets/ai_section_bnb.dart b/lib/views/ai_section/widgets/ai_section_bnb.dart index 8fde39f..6dac1e0 100644 --- a/lib/views/ai_section/widgets/ai_section_bnb.dart +++ b/lib/views/ai_section/widgets/ai_section_bnb.dart @@ -53,7 +53,23 @@ class AiSectionBNB extends StatelessWidget { title: 'عکس ساز', selectedIcon: cameraSolid, unselectedIcon: cameraRegular, - onTap: () => onTabChanged(0), + onTap: () { + final aiState = context.read(); + if (aiState.tools != null && aiState.tools!.isNotEmpty) { + final Tools imageGenTool = aiState.tools![0]; // ابزار عکس ساز + if (imageGenTool.bots != null && imageGenTool.bots!.isNotEmpty) { + final bot = imageGenTool.bots!.first; + Navigator.of(context).pushNamed( + Routes.aiChat, + arguments: AiChatArgs(bot: bot, isTool: imageGenTool.bots), + ); + } + } else { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('ابزار عکس ساز در حال بارگذاری است...')), + ); + } + }, ), _AiNavBarItem( isSelected: currentTabIndex == 1, @@ -77,7 +93,25 @@ class AiSectionBNB extends StatelessWidget { title: 'جست و جو', selectedIcon: searchSolid, unselectedIcon: searchRegular, - onTap: () => onTabChanged(3), + onTap: () { + final aiState = context.read(); + // نکته: طبق کد شما، تب جستجو (اندیس ۳) ویجت تحلیل نمودار را نمایش می‌دهد + // که از ابزار اندیس ۱ استفاده می‌کند. + if (aiState.tools != null && aiState.tools!.length > 1) { + final Tools chartAnalysisTool = aiState.tools![1]; + if (chartAnalysisTool.bots != null && chartAnalysisTool.bots!.isNotEmpty) { + final bot = chartAnalysisTool.bots!.first; + Navigator.of(context).pushNamed( + Routes.aiChat, + arguments: AiChatArgs(bot: bot, isTool: chartAnalysisTool.bots), + ); + } + } else { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('ابزار جستجو در حال بارگذاری است...')), + ); + } + }, ), _AiNavBarItem( isSelected: currentTabIndex == 4, @@ -173,4 +207,4 @@ class _AiNavBarItem extends StatelessWidget { ), ); } -} +} \ No newline at end of file diff --git a/lib/views/home/main/widgets/story_section.dart b/lib/views/home/main/widgets/story_section.dart index d001061..ca435c2 100644 --- a/lib/views/home/main/widgets/story_section.dart +++ b/lib/views/home/main/widgets/story_section.dart @@ -1,4 +1,3 @@ -import 'package:cached_network_image/cached_network_image.dart'; import 'package:didvan/models/story_model.dart'; import 'package:didvan/routes/routes.dart'; import 'package:flutter/material.dart'; @@ -41,8 +40,6 @@ class StorySection extends StatelessWidget { } } -// lib/views/home/main/widgets/story_section.dart - class _StoryCircle extends StatelessWidget { final UserStories userStories; final VoidCallback onTap; @@ -76,32 +73,43 @@ class _StoryCircle extends StatelessWidget { shape: BoxShape.circle, gradient: isViewed ? const LinearGradient( - colors: [Color.fromARGB(255, 184, 184, 184),Color.fromARGB(255, 184, 184, 184)], + colors: [ + Color.fromARGB(255, 184, 184, 184), + Color.fromARGB(255, 184, 184, 184) + ], ) : const LinearGradient( - colors: [ Color.fromARGB(255, 27, 60, 79), Color.fromARGB(255, 27, 60, 79)], + colors: [ + Color.fromARGB(255, 27, 60, 79), + Color.fromARGB(255, 27, 60, 79) + ], begin: Alignment.topRight, end: Alignment.bottomLeft, ), ), child: Padding( - padding: const EdgeInsets.all(4.0), + padding: const EdgeInsets.all(4.0), child: Container( decoration: const BoxDecoration( color: Colors.white, shape: BoxShape.circle, ), child: Padding( - padding: const EdgeInsets.all(4.0), + padding: const EdgeInsets.all(4.0), child: CircleAvatar( - backgroundColor: const Color.fromARGB(255, 230, 242, 246), + backgroundColor: + const Color.fromARGB(255, 230, 242, 246), child: ClipOval( - child: SvgPicture.asset( - "lib/assets/icons/MACRO_TRENDS.svg", + child: Image.asset( + userStories.user + .profileImageUrl, fit: BoxFit.cover, - width: 50.0, - height: 50.0, - placeholderBuilder: (context) => const CircularProgressIndicator(strokeWidth: 2.0), + width: 50.0, + height: 50.0, + errorBuilder: (context, error, stackTrace) { + return const Icon(Icons.person, + color: Colors.grey, size: 40.0); + }, ), ), ), @@ -121,4 +129,4 @@ class _StoryCircle extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/lib/views/story_viewer/story_viewer_page.dart b/lib/views/story_viewer/story_viewer_page.dart index 7e388b3..f9ff67f 100644 --- a/lib/views/story_viewer/story_viewer_page.dart +++ b/lib/views/story_viewer/story_viewer_page.dart @@ -128,29 +128,29 @@ class _UserStoryViewerState extends State break; case MediaType.video: _videoController = - VideoPlayerController.networkUrl(Uri.parse(story.url)) - ..initialize().then((_) { - if (mounted) { - setState(() { - if (_videoController!.value.isInitialized) { - // Check for a valid duration - if (_videoController!.value.duration > Duration.zero) { - _animationController.duration = - _videoController!.value.duration; - } else { - // Fallback to default duration if video duration is invalid - _animationController.duration = story.duration; - } - _videoController!.play(); - _animationController.forward(); - } else { - // Fallback for failed initialization - _animationController.duration = story.duration; - _animationController.forward(); - } - }); - } - }); + VideoPlayerController.networkUrl(Uri.parse(story.url)); + _videoController!.initialize().then((_) { + if (mounted) { + setState(() { + if (_videoController!.value.isInitialized && + _videoController!.value.duration > Duration.zero) { + _animationController.duration = + _videoController!.value.duration; + _videoController!.play(); + // _animationController.forward(); + } else { + print( + "Video failed to initialize or has zero duration. Skipping."); + _nextStory(); + } + }); + } + }).catchError((error) { + print("Error loading video: $error. Skipping."); + if (mounted) { + _nextStory(); + } + }); break; } setState(() {}); @@ -360,15 +360,16 @@ class _UserInfo extends StatelessWidget { backgroundColor: Colors.grey[300], child: ClipOval( child: Padding( - padding: const EdgeInsets.all(5.0), - child: SvgPicture.asset( + padding: const EdgeInsets.all(0.0), + child: Image.asset( user.profileImageUrl, width: 40.0, height: 40.0, fit: BoxFit.cover, - placeholderBuilder: (context) => const CircularProgressIndicator( - strokeWidth: 2.0, - ), + errorBuilder: (context, error, stackTrace) { + return const Icon(Icons.person, + color: Colors.grey, size: 40.0); + }, ), ), ), @@ -403,4 +404,4 @@ class _UserInfo extends StatelessWidget { ], ); } -} \ No newline at end of file +}