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.
205 lines
5.6 KiB
205 lines
5.6 KiB
import 'package:get/get.dart';
|
|
import 'package:flutter/material.dart';
|
|
import '../../../data/providers/agent_provider.dart';
|
|
import '../../../core/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;
|
|
|
|
FunctionScene({
|
|
required this.title,
|
|
required this.description,
|
|
required this.icon,
|
|
required this.startColor,
|
|
required this.endColor,
|
|
required this.iconColor,
|
|
});
|
|
}
|
|
|
|
class ExploreController extends GetxController {
|
|
// 搜索关键词
|
|
final searchController = TextEditingController();
|
|
|
|
// AI功能列表
|
|
final List<AIFeature> aiFeatures = [
|
|
AIFeature(
|
|
title: '全能助理',
|
|
description: '帮你解决各类问题',
|
|
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.chat,
|
|
),
|
|
AIFeature(
|
|
title: '同声翻译',
|
|
description: '实时翻译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.translation,
|
|
),
|
|
AIFeature(
|
|
title: 'AI女友',
|
|
description: '智能陪伴,随时聊天',
|
|
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: '健康顾问',
|
|
description: '提供科学健康建议',
|
|
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<FunctionScene> functionScenes = [
|
|
FunctionScene(
|
|
title: '商务会议助手',
|
|
description: '实时记录会议纪要,多语言翻译',
|
|
icon: Icons.people,
|
|
startColor: const Color(0xFF3F51B5),
|
|
endColor: const Color(0xFF673AB7),
|
|
iconColor: const Color(0xFF3F51B5),
|
|
),
|
|
FunctionScene(
|
|
title: '语言学习助手',
|
|
description: '发音纠正,实时练习口语',
|
|
icon: Icons.school,
|
|
startColor: const Color(0xFF4CAF50),
|
|
endColor: const Color(0xFF009688),
|
|
iconColor: const Color(0xFF4CAF50),
|
|
),
|
|
FunctionScene(
|
|
title: '旅行翻译助手',
|
|
description: '实时语音翻译,旅游景点介绍',
|
|
icon: Icons.language,
|
|
startColor: const Color(0xFFFFC107),
|
|
endColor: const Color(0xFFFF9800),
|
|
iconColor: const Color(0xFFFFC107),
|
|
),
|
|
];
|
|
|
|
// 搜索功能
|
|
void search() {
|
|
if (searchController.text.isEmpty) return;
|
|
|
|
Get.snackbar(
|
|
'搜索',
|
|
'正在搜索: ${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(
|
|
'错误',
|
|
'未找到对应的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.translation) {
|
|
// 跳转到翻译页面
|
|
Get.toNamed(feature.targetRoute);
|
|
}
|
|
}
|
|
|
|
// 点击功能场景
|
|
void onFunctionSceneTap(int index) {
|
|
if (index < 0 || index >= functionScenes.length) return;
|
|
|
|
Get.snackbar(
|
|
'场景',
|
|
'您选择了: ${functionScenes[index].title}',
|
|
snackPosition: SnackPosition.TOP,
|
|
);
|
|
|
|
// 实际应用中,这里应该跳转到对应的场景页面
|
|
}
|
|
|
|
// 尝试新功能
|
|
void tryNewFeature() {
|
|
Get.snackbar(
|
|
'新功能',
|
|
'您选择了尝试AI歌手模式',
|
|
snackPosition: SnackPosition.TOP,
|
|
);
|
|
|
|
// 实际应用中,这里应该跳转到新功能页面
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
searchController.dispose();
|
|
super.onClose();
|
|
}
|
|
}
|