Initial commit: 健康管家 AI 健康陪伴助手
- Backend: .NET 10 Minimal API + EF Core + PostgreSQL - Frontend: Flutter + Riverpod + GoRouter + Dio - AI: DeepSeek LLM + Qwen VLM (OpenAI-compatible) - Auth: SMS + JWT (access/refresh tokens) - Features: AI chat, health tracking, medication management, diet analysis, exercise plans, doctor consultations, report analysis
This commit is contained in:
61
health_app/lib/widgets/agent_bar.dart
Normal file
61
health_app/lib/widgets/agent_bar.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../providers/chat_provider.dart';
|
||||
|
||||
/// 智能体胶囊栏——横向滑动
|
||||
class AgentBar extends ConsumerWidget {
|
||||
const AgentBar({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final selected = ref.watch(selectedAgentProvider);
|
||||
final chatNotifier = ref.read(chatProvider.notifier);
|
||||
|
||||
void onTap(ActiveAgent agent) {
|
||||
final notifier = ref.read(selectedAgentProvider.notifier);
|
||||
notifier.select(agent == selected ? null : agent);
|
||||
chatNotifier.setAgent(agent);
|
||||
}
|
||||
|
||||
return Container(
|
||||
height: 48,
|
||||
color: Colors.white,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
children: [
|
||||
_buildCapsule('AI问诊', Icons.medical_services, ActiveAgent.consultation, selected, onTap),
|
||||
_buildCapsule('记数据', Icons.edit_note, ActiveAgent.health, selected, onTap),
|
||||
_buildCapsule('拍饮食', Icons.restaurant, ActiveAgent.diet, selected, onTap),
|
||||
_buildCapsule('药管家', Icons.medication, ActiveAgent.medication, selected, onTap),
|
||||
_buildCapsule('看报告', Icons.description, ActiveAgent.report, selected, onTap),
|
||||
_buildCapsule('运动计划', Icons.fitness_center, ActiveAgent.exercise, selected, onTap),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCapsule(String label, IconData icon, ActiveAgent agent, ActiveAgent? selected, void Function(ActiveAgent) onTap) {
|
||||
final isSelected = selected == agent;
|
||||
return GestureDetector(
|
||||
onTap: () => onTap(agent),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 4, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? const Color(0xFF635BFF) : Colors.white,
|
||||
border: Border.all(color: const Color(0xFF635BFF)),
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 16, color: isSelected ? Colors.white : const Color(0xFF635BFF)),
|
||||
const SizedBox(width: 6),
|
||||
Text(label, style: TextStyle(fontSize: 13, color: isSelected ? Colors.white : const Color(0xFF635BFF))),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user