You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
276 lines
8.6 KiB
276 lines
8.6 KiB
import 'package:get/get.dart';
|
|
import 'package:flutter/material.dart';
|
|
import '../../../data/providers/agent_provider.dart';
|
|
import '../../../routes/app_routes.dart';
|
|
|
|
class AIFeature {
|
|
final String title;
|
|
final String description;
|
|
final IconData icon;
|
|
final Color startColor;
|
|
final Color endColor;
|
|
final Color iconBgColor;
|
|
final Color iconColor;
|
|
final String agentId;
|
|
final String targetRoute;
|
|
|
|
AIFeature({
|
|
required this.title,
|
|
required this.description,
|
|
required this.icon,
|
|
required this.startColor,
|
|
required this.endColor,
|
|
required this.iconBgColor,
|
|
required this.iconColor,
|
|
required this.agentId,
|
|
required this.targetRoute,
|
|
});
|
|
}
|
|
|
|
class FunctionScene {
|
|
final String title;
|
|
final String description;
|
|
final IconData icon;
|
|
final Color startColor;
|
|
final Color endColor;
|
|
final Color iconColor;
|
|
final String targetRoute;
|
|
|
|
FunctionScene({
|
|
required this.title,
|
|
required this.description,
|
|
required this.icon,
|
|
required this.startColor,
|
|
required this.endColor,
|
|
required this.iconColor,
|
|
required this.targetRoute,
|
|
});
|
|
}
|
|
|
|
class ExploreController extends GetxController {
|
|
// 搜索关键词
|
|
final searchController = TextEditingController();
|
|
|
|
// AI功能列表
|
|
final List<AIFeature> aiFeatures = [
|
|
AIFeature(
|
|
title: 'aiAssistant'.tr, // AI全能助手
|
|
description: 'aiAssistantInfo'.tr, // 帮你解决各类问题
|
|
icon: Icons.assistant,
|
|
startColor: const Color(0xFF0066CC),
|
|
endColor: const Color(0xFF5E5CE6),
|
|
iconBgColor: const Color(0xFF0066CC).withOpacity(0.2),
|
|
iconColor: const Color(0xFF0066CC),
|
|
agentId: 'personal_assistant',
|
|
targetRoute: Routes.agent,
|
|
),
|
|
AIFeature(
|
|
title: 'simultaneousInterpretation'.tr, // 同声翻译
|
|
description: 'simultaneousInterpretationInfo'.tr, // 实时翻译80+种语言
|
|
icon: Icons.translate,
|
|
startColor: const Color(0xFF4CAF50),
|
|
endColor: const Color(0xFF009688),
|
|
iconBgColor: const Color(0xFF4CAF50).withOpacity(0.2),
|
|
iconColor: const Color(0xFF4CAF50),
|
|
agentId: 'simultaneous_interpreter',
|
|
targetRoute: Routes.translationMiddleware,
|
|
),
|
|
// 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,
|
|
// startColor: const Color(0xFFE91E63),
|
|
// endColor: const Color(0xFFFF5252),
|
|
// iconBgColor: const Color(0xFFE91E63).withOpacity(0.2),
|
|
// iconColor: const Color(0xFFE91E63),
|
|
// agentId: 'cyber_girlfriend',
|
|
// targetRoute: Routes.chat,
|
|
// ),
|
|
// AIFeature(
|
|
// title: 'healthConsultant'.tr, // 健康顾问
|
|
// description: 'healthConsultantInfo'.tr, // 提供科学健康建议
|
|
// icon: Icons.healing,
|
|
// startColor: const Color(0xFFFFC107),
|
|
// endColor: const Color(0xFFFF9800),
|
|
// iconBgColor: const Color(0xFFFFC107).withOpacity(0.2),
|
|
// iconColor: const Color(0xFFFFC107),
|
|
// agentId: 'health_advisor',
|
|
// targetRoute: Routes.chat,
|
|
// ),
|
|
];
|
|
|
|
final List<AIFeature> 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<FunctionScene> functionScenes = [
|
|
FunctionScene(
|
|
title: 'conferenceAssistant'.tr, // 商务会议助手
|
|
description: 'conferenceAssistantInfo'.tr, // 实时记录会议纪要,多语言翻译
|
|
icon: Icons.people,
|
|
startColor: const Color(0xFFab47bc),
|
|
endColor: const Color(0xFFec407a),
|
|
iconColor: const Color(0xFFd81b60),
|
|
targetRoute: Routes.meeting,
|
|
),
|
|
FunctionScene(
|
|
title: 'studyAssistant'.tr, // 语言学习助手
|
|
description: 'studyAssistantInfo'.tr, // 发音纠正,实时练习口语
|
|
icon: Icons.school,
|
|
startColor: const Color(0xFF4CAF50),
|
|
endColor: const Color(0xFF009688),
|
|
iconColor: const Color(0xFF4CAF50),
|
|
targetRoute: Routes.realtime,
|
|
),
|
|
FunctionScene(
|
|
title: 'travelTranslator'.tr, // 旅行翻译助手
|
|
description: 'travelTranslatorInfo'.tr, // 实时语音翻译,旅游景点介绍
|
|
icon: Icons.language,
|
|
startColor: const Color(0xFFFFC107),
|
|
endColor: const Color(0xFFFF9800),
|
|
iconColor: const Color(0xFFFFC107),
|
|
targetRoute: '',
|
|
),
|
|
];
|
|
|
|
// 搜索功能
|
|
void search() {
|
|
if (searchController.text.isEmpty) return;
|
|
|
|
Get.snackbar(
|
|
'search'.tr, // 搜索
|
|
'${'beSearching'.tr} ${searchController.text}', // 正在搜索:
|
|
snackPosition: SnackPosition.TOP,
|
|
);
|
|
|
|
// 实际应用中,这里应该实现真正的搜索逻辑
|
|
searchController.clear();
|
|
}
|
|
|
|
// 点击AI功能
|
|
void onAIFeatureTap(int index) {
|
|
if (index < 0 || index >= aiFeatures.length) return;
|
|
|
|
final feature = aiFeatures[index];
|
|
final agent = AgentProvider.getAgentById(feature.agentId);
|
|
|
|
if (agent == null) {
|
|
Get.snackbar(
|
|
'error'.tr, // 错误
|
|
'noAssistantFound'.tr, // 未找到对应的AI助手
|
|
snackPosition: SnackPosition.TOP,
|
|
);
|
|
return;
|
|
}
|
|
|
|
// 根据目标路由进行跳转
|
|
if (feature.targetRoute == Routes.chat) {
|
|
// 跳转到聊天页面
|
|
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 == Routes.translationMiddleware) {
|
|
// 跳转到翻译页面
|
|
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);
|
|
}
|
|
}
|
|
|
|
// 点击功能场景
|
|
void onFunctionSceneTap(int index) {
|
|
if (index < 0 || index >= functionScenes.length) return;
|
|
|
|
final scene = functionScenes[index];
|
|
|
|
if (scene.targetRoute.isNotEmpty) {
|
|
Get.toNamed(scene.targetRoute);
|
|
} else {
|
|
Get.snackbar(
|
|
'scene'.tr, // 场景
|
|
'${'youHaveSelected'.tr} ${functionScenes[index].title}', // 您选择了:
|
|
snackPosition: SnackPosition.TOP,
|
|
);
|
|
}
|
|
}
|
|
|
|
// 尝试新功能
|
|
void tryNewFeature() {
|
|
Get.snackbar(
|
|
'newFunction'.tr, // 新功能
|
|
'${'youChoseTry'.tr}${'aiSinger'.tr}', // 您选择了尝试 // AI歌手模式
|
|
snackPosition: SnackPosition.TOP,
|
|
);
|
|
|
|
// 实际应用中,这里应该跳转到新功能页面
|
|
}
|
|
|
|
// 跳转到翻译统计页面
|
|
void goToTranslationStats() {
|
|
Get.toNamed(Routes.translationStats);
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
searchController.dispose();
|
|
super.onClose();
|
|
}
|
|
}
|
|
|