refactor: 死代码清理 + 趋势图重构 + 侧边栏交互优化 + 智能体卡片去延迟
- 死代码清理: 删除 AppCard/AppMenuItem/AppTabChip/AppButtons 等 4 个未使用 Widget 文件; 清理 common_widgets/enterprise_widgets/app_status_badge 中未使用 class; 移除 HealthService 等未使用方法; 后端移除 ExerciseService.CreateFromItemsAsync/HealthArchiveService.GetOrCreateAsync/MedicationAgentHandler 死分支/ChatRequest DTO - 趋势图: 直线折线 + 渐变填充 + 阴影; 去网格; X 轴日+月份; Y 轴整数刻度最多 4 个; 点击数据点/录入记录显示上方浮层; 选中点变实心 - 侧边栏: 对话记录改单选删除(灰底高亮); 操作栏浮层修复触摸问题; 常用功能/健康仪表盘间距收紧; _Panel 去外框 - 智能体: 欢迎卡片去掉 400ms 延迟; 胶囊去阴影 - 其他: api_client IP 适配; 多页面 UI 微调; 新增 chat_provider/prelaunch_guardrails 测试
This commit is contained in:
@@ -78,7 +78,7 @@ class _HomePageState extends ConsumerState<HomePage>
|
||||
final imagePath = _pickedImagePath;
|
||||
if (text.isEmpty && imagePath == null) return;
|
||||
_textCtrl.clear();
|
||||
_focusNode.unfocus();
|
||||
_dismissKeyboard();
|
||||
setState(() => _pickedImagePath = null);
|
||||
if (imagePath != null) {
|
||||
ref.read(chatProvider.notifier).sendImage(imagePath, text);
|
||||
@@ -145,9 +145,9 @@ class _HomePageState extends ConsumerState<HomePage>
|
||||
left: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
width: 44,
|
||||
width: MediaQuery.sizeOf(context).width * 0.8,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onHorizontalDragStart: (details) {
|
||||
_drawerDragStartX = details.globalPosition.dx;
|
||||
},
|
||||
@@ -255,16 +255,20 @@ class _HomePageState extends ConsumerState<HomePage>
|
||||
];
|
||||
|
||||
Widget _buildAgentBar() {
|
||||
final activeAgent = ref.watch(
|
||||
chatProvider.select((state) => state.activeAgent),
|
||||
);
|
||||
return SizedBox(
|
||||
height: 42,
|
||||
height: 46,
|
||||
child: ListView.separated(
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 2),
|
||||
itemCount: _agentDefs.length,
|
||||
separatorBuilder: (_, _) => const SizedBox(width: 8),
|
||||
itemBuilder: (_, i) {
|
||||
final agent = _agentDefs[i];
|
||||
final visual = _agentVisual(agent);
|
||||
final selected = activeAgent == agent;
|
||||
return GestureDetector(
|
||||
onTap: () => ref
|
||||
.read(chatProvider.notifier)
|
||||
@@ -272,9 +276,14 @@ class _HomePageState extends ConsumerState<HomePage>
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 9),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.86),
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
border: Border.all(color: Colors.white, width: 1.2),
|
||||
border: Border.all(
|
||||
color: selected
|
||||
? AppColors.auraIndigo.withValues(alpha: 0.42)
|
||||
: const Color(0xFFD5DAE4),
|
||||
width: selected ? 1.4 : 1.1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -477,6 +486,7 @@ class _HomePageState extends ConsumerState<HomePage>
|
||||
}
|
||||
|
||||
void _showAttachmentPicker(BuildContext context) {
|
||||
_dismissKeyboard();
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.white,
|
||||
@@ -496,6 +506,7 @@ class _HomePageState extends ConsumerState<HomePage>
|
||||
title: const Text('拍照'),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
_dismissKeyboard();
|
||||
_pickImage(ImageSource.camera);
|
||||
},
|
||||
),
|
||||
@@ -507,6 +518,7 @@ class _HomePageState extends ConsumerState<HomePage>
|
||||
title: const Text('从相册选择'),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
_dismissKeyboard();
|
||||
_pickImage(ImageSource.gallery);
|
||||
},
|
||||
),
|
||||
@@ -518,6 +530,7 @@ class _HomePageState extends ConsumerState<HomePage>
|
||||
title: const Text('上传 PDF'),
|
||||
onTap: () async {
|
||||
Navigator.pop(ctx);
|
||||
_dismissKeyboard();
|
||||
final result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['pdf'],
|
||||
@@ -532,6 +545,7 @@ class _HomePageState extends ConsumerState<HomePage>
|
||||
.read(chatProvider.notifier)
|
||||
.sendPdf(path, pdfFile.name, _textCtrl.text.trim());
|
||||
_textCtrl.clear();
|
||||
_dismissKeyboard();
|
||||
if (mounted) setState(() {});
|
||||
},
|
||||
),
|
||||
@@ -543,17 +557,25 @@ class _HomePageState extends ConsumerState<HomePage>
|
||||
}
|
||||
|
||||
Future<void> _pickImage(ImageSource source) async {
|
||||
_dismissKeyboard();
|
||||
final picked = await ImagePicker().pickImage(
|
||||
source: source,
|
||||
imageQuality: 85,
|
||||
);
|
||||
_dismissKeyboard();
|
||||
if (picked != null) {
|
||||
final token = await ref.read(apiClientProvider).accessToken;
|
||||
if (token == null) return;
|
||||
setState(() => _pickedImagePath = picked.path);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => _dismissKeyboard());
|
||||
}
|
||||
}
|
||||
|
||||
void _dismissKeyboard() {
|
||||
_focusNode.unfocus();
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
}
|
||||
|
||||
Future<void> _pickFoodImage(ImageSource source) async {
|
||||
final picked = await ImagePicker().pickImage(
|
||||
source: source,
|
||||
|
||||
Reference in New Issue
Block a user