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.5 KiB
205 lines
5.5 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: Colors.blue.shade100,
|
|
endColor: Colors.blue.shade200,
|
|
iconBgColor: Colors.blue.withOpacity(0.2),
|
|
iconColor: Colors.blue.shade600,
|
|
agentId: 'personal_assistant',
|
|
targetRoute: Routes.chat,
|
|
),
|
|
AIFeature(
|
|
title: '同声翻译',
|
|
description: '实时翻译40+种语言',
|
|
icon: Icons.translate,
|
|
startColor: Colors.green.shade100,
|
|
endColor: Colors.green.shade200,
|
|
iconBgColor: Colors.green.withOpacity(0.2),
|
|
iconColor: Colors.green.shade600,
|
|
agentId: 'simultaneous_interpreter',
|
|
targetRoute: Routes.translation,
|
|
),
|
|
AIFeature(
|
|
title: 'AI女友',
|
|
description: '智能陪伴,随时聊天',
|
|
icon: Icons.favorite,
|
|
startColor: Colors.pink.shade100,
|
|
endColor: Colors.pink.shade200,
|
|
iconBgColor: Colors.pink.withOpacity(0.2),
|
|
iconColor: Colors.pink.shade600,
|
|
agentId: 'cyber_girlfriend',
|
|
targetRoute: Routes.chat,
|
|
),
|
|
AIFeature(
|
|
title: '健康顾问',
|
|
description: '提供科学健康建议',
|
|
icon: Icons.healing,
|
|
startColor: Colors.amber.shade100,
|
|
endColor: Colors.amber.shade200,
|
|
iconBgColor: Colors.amber.withOpacity(0.2),
|
|
iconColor: Colors.amber.shade600,
|
|
agentId: 'health_advisor',
|
|
targetRoute: Routes.chat,
|
|
),
|
|
];
|
|
|
|
// 热门功能场景列表
|
|
final List<FunctionScene> functionScenes = [
|
|
FunctionScene(
|
|
title: '商务会议助手',
|
|
description: '实时记录会议纪要,多语言翻译',
|
|
icon: Icons.people,
|
|
startColor: Colors.blue.shade200,
|
|
endColor: Colors.blue.shade300,
|
|
iconColor: Colors.blue.shade600,
|
|
),
|
|
FunctionScene(
|
|
title: '语言学习助手',
|
|
description: '发音纠正,实时练习口语',
|
|
icon: Icons.school,
|
|
startColor: Colors.green.shade200,
|
|
endColor: Colors.green.shade300,
|
|
iconColor: Colors.green.shade600,
|
|
),
|
|
FunctionScene(
|
|
title: '旅行翻译助手',
|
|
description: '实时语音翻译,旅游景点介绍',
|
|
icon: Icons.language,
|
|
startColor: Colors.amber.shade200,
|
|
endColor: Colors.amber.shade300,
|
|
iconColor: Colors.amber.shade600,
|
|
),
|
|
];
|
|
|
|
// 搜索功能
|
|
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();
|
|
}
|
|
}
|