diff --git a/lib/modules/explore/controllers/explore_controller.dart b/lib/modules/explore/controllers/explore_controller.dart index 067e4b6af..f09d1e1bd 100644 --- a/lib/modules/explore/controllers/explore_controller.dart +++ b/lib/modules/explore/controllers/explore_controller.dart @@ -76,6 +76,17 @@ class ExploreController extends GetxController { targetRoute: Routes.translation, ), // AIFeature( + // title: 'conferenceAssistant'.tr, // 商务会议助手 + // description: 'conferenceAssistantInfo'.tr, // 实时记录会议纪要,多语言翻译 + // icon: Icons.people, + // startColor: const Color(0xFFab47bc), + // endColor: const Color(0xFFec407a), + // iconBgColor: const Color(0xFFd81b60).withOpacity(0.2), + // iconColor: const Color(0xFFd81b60), + // agentId: 'meeting_assistant', + // targetRoute: Routes.meeting, + // ), + // AIFeature( // title: 'aiGirlfriend'.tr, // 亲子陪伴 // description: 'aiGirlfriendInfo'.tr, // 智能陪伴,随时聊天 // icon: Icons.favorite, @@ -99,6 +110,20 @@ class ExploreController extends GetxController { // ), ]; + final List aiFeaturesWide = [ + AIFeature( + title: 'conferenceAssistant'.tr, // 商务会议助手 + description: 'conferenceAssistantInfo'.tr, // 实时记录会议纪要,多语言翻译 + icon: Icons.people, + startColor: const Color(0xFFab47bc), + endColor: const Color(0xFFec407a), + iconBgColor: const Color(0xFFd81b60).withOpacity(0.2), + iconColor: const Color(0xFFd81b60), + agentId: 'meeting_assistant', + targetRoute: Routes.meeting, + ), + ]; + // 热门功能场景列表 final List functionScenes = [ FunctionScene( @@ -177,6 +202,36 @@ class ExploreController extends GetxController { Get.toNamed(feature.targetRoute); } else if (feature.targetRoute == Routes.agent) { Get.toNamed(feature.targetRoute); + } else if (feature.targetRoute == Routes.meeting) { + // 跳转到会议页面 + Get.toNamed(feature.targetRoute); + } + } + + // 点击AI功能(宽版本) + void onAIFeatureWideTap(int index) { + if (index < 0 || index >= aiFeaturesWide.length) return; + + final feature = aiFeaturesWide[index]; + + // 直接根据目标路由进行跳转 + if (feature.targetRoute == Routes.meeting) { + Get.toNamed(feature.targetRoute); + } else if (feature.targetRoute == Routes.chat) { + final agent = AgentProvider.getAgentById(feature.agentId); + if (agent != null) { + Get.toNamed(feature.targetRoute, arguments: { + 'agentId': agent.id, + 'agentName': agent.name, + 'agentVoice': agent.voice, + 'agentAvatar': agent.avatarUrl, + 'agentSubtitle': agent.description, + 'systemPrompt': agent.systemPrompt, + 'welcomeMessage': agent.welcomeMessage, + }); + } + } else if (feature.targetRoute.isNotEmpty) { + Get.toNamed(feature.targetRoute); } } diff --git a/lib/modules/explore/views/explore_view.dart b/lib/modules/explore/views/explore_view.dart index 9f5250a69..3f0fee73c 100644 --- a/lib/modules/explore/views/explore_view.dart +++ b/lib/modules/explore/views/explore_view.dart @@ -65,11 +65,11 @@ class ExploreView extends GetView { // AI功能列表 SizedBox(height: 24.h), - _buildAIFeaturesSection(isDarkMode), + _buildCustomAILayout(isDarkMode), // 热门功能场景 SizedBox(height: 24.h), - _buildFunctionScenesSection(isDarkMode), + //_buildFunctionScenesSection(isDarkMode), // 新功能推荐 SizedBox(height: 24.h), @@ -250,8 +250,23 @@ class ExploreView extends GetView { ); } - // AI功能部分 - Widget _buildAIFeaturesSection(bool isDarkMode) { + // 自定义AI功能布局:2x2网格,商务会议助手占据下方两个网格位置 + Widget _buildCustomAILayout(bool isDarkMode) { + // 找到AI全能助手 + final aiAssistantIndex = controller.aiFeatures.indexWhere( + (feature) => feature.agentId == 'personal_assistant', + ); + + // 找到同声传译 + final translationIndex = controller.aiFeatures.indexWhere( + (feature) => feature.agentId == 'simultaneous_interpreter', + ); + + // 找到商务会议助手(在aiFeaturesWide中) + final meetingFeature = controller.aiFeaturesWide.isNotEmpty + ? controller.aiFeaturesWide.first + : null; + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -264,20 +279,56 @@ class ExploreView extends GetView { ), ), SizedBox(height: 16.h), - GridView.builder( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 16.w, - mainAxisSpacing: 16.h, - childAspectRatio: 1.0, - ), - itemCount: controller.aiFeatures.length, - itemBuilder: (context, index) { - final feature = controller.aiFeatures[index]; - return _buildAIFeatureItem(feature, index, isDarkMode); - }, + + // 2x2网格布局 + Column( + children: [ + // 上层:AI全能助手(左)和同声传译(右) + Row( + children: [ + // 左上角:AI全能助手 + if (aiAssistantIndex != -1) + Expanded( + child: AspectRatio( + aspectRatio: 1.0, // 正方形 + child: _buildAIFeatureItem( + controller.aiFeatures[aiAssistantIndex], + aiAssistantIndex, + isDarkMode, + ), + ), + ), + + SizedBox(width: 16.w), + + // 右上角:同声传译 + if (translationIndex != -1) + Expanded( + child: AspectRatio( + aspectRatio: 1.0, // 正方形 + child: _buildAIFeatureItem( + controller.aiFeatures[translationIndex], + translationIndex, + isDarkMode, + ), + ), + ), + ], + ), + + SizedBox(height: 16.h), + + // 下层:商务会议助手(横跨整行) + if (meetingFeature != null) + AspectRatio( + aspectRatio: 2.0, // 宽高比2:1,横跨两个网格位置 + child: _buildAIFeatureItemWideForMeeting( + meetingFeature, + 0, // 使用固定索引,因为这是aiFeaturesWide中的项目 + isDarkMode, + ), + ), + ], ), ], ); @@ -366,20 +417,211 @@ class ExploreView extends GetView { ); } +//整行布局 + Widget _buildAIFeaturesWideSection(bool isDarkMode) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Text( + // 'aiFunction'.tr, // AI功能 + // style: TextStyle( + // fontSize: 18.sp, + // fontWeight: FontWeight.w600, + // color: isDarkMode ? Colors.white : Colors.grey[800], + // ), + // ), + // SizedBox(height: 16.h), + // 直接使用 Column 包裹宽版卡片 + Column( + children: controller.aiFeaturesWide.map((feature) { + return Padding( + padding: EdgeInsets.only(bottom: 16.h), // 卡片间距 + child: _buildAIFeatureItemWide( + feature, + controller.aiFeatures.indexOf(feature), + isDarkMode, + ), + ); + }).toList(), + ), + ], + ); +} + + // AI功能项(宽版本,用于横跨整行的AI全能助手) + Widget _buildAIFeatureItemWide(AIFeature feature, int index, bool isDarkMode) { + return GestureDetector( + onTap: () => controller.onAIFeatureTap(index), + child: Container( + padding: EdgeInsets.all(20.w), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + feature.startColor.withOpacity(isDarkMode ? 0.3 : 0.3), + feature.endColor.withOpacity(isDarkMode ? 0.3 : 0.3), + ], + ), + borderRadius: BorderRadius.circular(20.r), + boxShadow: [ + BoxShadow( + color: isDarkMode + ? Colors.black.withOpacity(0.2) + : Colors.grey.withOpacity(0.1), + blurRadius: 8.w, + offset: const Offset(0, 4), + ), + ], + ), + child: Row( + children: [ + // 图标圆圈 + Container( + width: 48.w, + height: 48.w, + decoration: BoxDecoration( + color: feature.iconColor.withValues(alpha: 0.2), + shape: BoxShape.circle, + ), + child: Icon( + feature.icon, + size: 24.sp, + color: feature.iconColor, + ), + ), + SizedBox(width: 16.w), + // 文本内容 + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // 标题 + Text( + feature.title, + style: TextStyle( + fontSize: 16.sp, + fontWeight: FontWeight.w600, + color: isDarkMode ? Colors.white : Colors.grey[800], + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + SizedBox(height: 4.h), + // 描述 + Text( + feature.description, + style: TextStyle( + fontSize: 12.sp, + color: isDarkMode ? Colors.grey[400] : Colors.grey[600], + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ], + ), + ), + ], + ), + ), + ); + } + + // AI功能项(宽版本,专门用于商务会议助手) + Widget _buildAIFeatureItemWideForMeeting(AIFeature feature, int index, bool isDarkMode) { + return GestureDetector( + onTap: () => controller.onAIFeatureWideTap(index), + child: Container( + padding: EdgeInsets.all(20.w), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + feature.startColor.withValues(alpha: isDarkMode ? 0.3 : 0.3), + feature.endColor.withValues(alpha: isDarkMode ? 0.3 : 0.3), + ], + ), + borderRadius: BorderRadius.circular(20.r), + boxShadow: [ + BoxShadow( + color: isDarkMode + ? Colors.black.withValues(alpha: 0.2) + : Colors.grey.withValues(alpha: 0.1), + blurRadius: 8, + offset: const Offset(0, 4), + ), + ], + ), + child: Row( + children: [ + // 图标圆圈 + Container( + width: 48.w, + height: 48.w, + decoration: BoxDecoration( + color: feature.iconColor.withValues(alpha: 0.2), + shape: BoxShape.circle, + ), + child: Icon( + feature.icon, + size: 24.sp, + color: feature.iconColor, + ), + ), + SizedBox(width: 16.w), + // 文本内容 + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // 标题 + Text( + feature.title, + style: TextStyle( + fontSize: 18.sp, + fontWeight: FontWeight.w600, + color: isDarkMode ? Colors.white : Colors.grey[800], + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + SizedBox(height: 4.h), + // 描述 + Text( + feature.description, + style: TextStyle( + fontSize: 14.sp, + color: isDarkMode ? Colors.grey[400] : Colors.grey[600], + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ], + ), + ), + ], + ), + ), + ); + } + // 热门功能场景部分 Widget _buildFunctionScenesSection(bool isDarkMode) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - 'popularFunction'.tr, // 热门功能场景 - style: TextStyle( - fontSize: 18.sp, - fontWeight: FontWeight.w600, - color: isDarkMode ? Colors.white : Colors.grey[800], - ), - ), - SizedBox(height: 16.h), + // Text( + // 'popularFunction'.tr, // 热门功能场景 + // style: TextStyle( + // fontSize: 18.sp, + // fontWeight: FontWeight.w600, + // color: isDarkMode ? Colors.white : Colors.grey[800], + // ), + // ), + // SizedBox(height: 16.h), ListView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), @@ -404,13 +646,13 @@ class ExploreView extends GetView { child: Container( padding: EdgeInsets.all(16.w), decoration: BoxDecoration( - color: isDarkMode ? Colors.white.withOpacity(0.05) : Colors.grey[100], + color: isDarkMode ? Colors.white.withValues(alpha: 0.05) : Colors.grey[100], borderRadius: BorderRadius.circular(16.r), boxShadow: [ BoxShadow( color: isDarkMode - ? Colors.black.withOpacity(0.2) - : Colors.grey.withOpacity(0.1), + ? Colors.black.withValues(alpha: 0.2) + : Colors.grey.withValues(alpha: 0.1), blurRadius: 4, offset: const Offset(0, 2), ),