- 报告模块:重写AI解读页,统一白色卡片+三栏布局(指标→解读→医生审核);加删除功能+后端删接口;VLM自动识别报告类型生成中文标题;去五颜六色
- 饮食分析:全面重设计,暖橙主题配色,图片自适应,餐次emoji选择器,去紫色
- 运动确认卡片:修复duration_minutes JSON类型转换,支持中文数字识别(三十分钟/半小时→30);主区域只显示运动名,字段行改为横向排列
- 流式输出:简化为最基础逐字追加,去buffer+Timer+淡入动画
- 欢迎卡片:每智能体独立渐变色(青/橙/蓝/紫/绿/粉),加卡片入场滑入+淡入动画(600ms)
- 确认卡片:头部去紫色背景改浅灰白,字段行去图标改纯信息横排,编辑框去双重边框
- 用药管理:胶囊改TabBar,添加按钮改右下FAB;打卡按钮改对号圆圈形式;药丸图标白底
- 侧边栏:加VIP服务/保险栏+图标,标题字体放大;服务包去查看更多+去VIP金色标签
- 胶囊:首页智能体胶囊白底深色字; side胶囊加阴影
- 对话流:reverse=false,今日健康出现在顶部; 对话页input bar匹配主页面样式
- 其他:个人资料去紫色+去多余入口;设置页白底图标;蓝牙页加返回按钮;报告管理改名
- 后端:加DELETE /api/reports/{id}; 修复manage_exercise数据类型转换;AI提示优化中文数字
147 lines
6.6 KiB
Dart
147 lines
6.6 KiB
Dart
import 'package:flutter/material.dart';
|
||
import '../../core/app_colors.dart';
|
||
import '../../core/app_theme.dart';
|
||
import '../../core/navigation_provider.dart';
|
||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||
import '../../providers/auth_provider.dart';
|
||
import '../../providers/data_providers.dart';
|
||
|
||
class MedicationCheckInPage extends ConsumerStatefulWidget {
|
||
final String? medId; // 可选:指定药品,null 显示全部
|
||
const MedicationCheckInPage({super.key, this.medId});
|
||
@override ConsumerState<MedicationCheckInPage> createState() => _MedicationCheckInPageState();
|
||
}
|
||
|
||
class _MedicationCheckInPageState extends ConsumerState<MedicationCheckInPage> {
|
||
Future<List<Map<String, dynamic>>>? _future;
|
||
|
||
@override void initState() { super.initState(); _load(); }
|
||
void _load() => setState(() { _future = ref.read(medicationReminderProvider.future); });
|
||
|
||
Future<void> _toggleDose(String medId, String time, bool taken) async {
|
||
try {
|
||
final api = ref.read(apiClientProvider);
|
||
if (taken) {
|
||
// 取消打卡:删掉对应 log
|
||
await api.delete('/api/medications/$medId/confirm-dose/$time');
|
||
} else {
|
||
// 打卡
|
||
await api.post('/api/medications/$medId/confirm-dose', data: {'scheduledTime': time, 'status': 'taken'});
|
||
}
|
||
ref.invalidate(medicationReminderProvider);
|
||
ref.invalidate(medicationListProvider);
|
||
_load();
|
||
} catch (e) { debugPrint('[MedCheckIn] 打卡失败: $e'); }
|
||
}
|
||
|
||
@override Widget build(BuildContext context) {
|
||
return GradientScaffold(
|
||
appBar: AppBar(leading: IconButton(icon: const Icon(Icons.arrow_back), onPressed: () => popRoute(ref)), title: const Text('服药打卡'), centerTitle: true),
|
||
body: FutureBuilder<List<Map<String, dynamic>>>(
|
||
future: _future,
|
||
builder: (ctx, snap) {
|
||
if (snap.connectionState == ConnectionState.waiting) {
|
||
return const Center(child: CircularProgressIndicator(color: AppTheme.primary));
|
||
}
|
||
final reminders = snap.data ?? [];
|
||
if (reminders.isEmpty) {
|
||
return Center(
|
||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||
Icon(Icons.check_circle_outline, size: 64, color: AppTheme.textHint),
|
||
const SizedBox(height: 12),
|
||
const Text('今天所有用药已打卡', style: TextStyle(fontSize: 19, color: AppColors.textSecondary)),
|
||
]),
|
||
);
|
||
}
|
||
|
||
// 如果指定了 medId,只显示该药品
|
||
var filtered = reminders;
|
||
if (widget.medId != null) {
|
||
filtered = reminders.where((r) => r['id']?.toString() == widget.medId).toList();
|
||
}
|
||
|
||
// 按药品分组
|
||
final grouped = <String, List<Map<String, dynamic>>>{};
|
||
for (final r in filtered) {
|
||
final name = r['name']?.toString() ?? '药品';
|
||
grouped.putIfAbsent(name, () => []).add(r);
|
||
}
|
||
|
||
return RefreshIndicator(
|
||
onRefresh: () async => _load(),
|
||
child: ListView(
|
||
padding: const EdgeInsets.all(14),
|
||
children: grouped.entries.map((entry) {
|
||
final medName = entry.key;
|
||
final doses = entry.value;
|
||
final dosage = doses.first['dosage']?.toString() ?? '';
|
||
return Container(
|
||
margin: const EdgeInsets.only(bottom: 12),
|
||
padding: const EdgeInsets.all(16),
|
||
decoration: BoxDecoration(
|
||
color: AppTheme.surface,
|
||
borderRadius: BorderRadius.circular(AppTheme.rLg),
|
||
boxShadow: [AppTheme.shadowCard],
|
||
),
|
||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||
Row(children: [
|
||
Container(
|
||
width: 40, height: 40,
|
||
decoration: BoxDecoration(color: AppColors.warningLight, borderRadius: BorderRadius.circular(10)),
|
||
child: const Center(child: Text('💊', style: TextStyle(fontSize: 23))),
|
||
),
|
||
const SizedBox(width: 12),
|
||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||
Text(medName, style: const TextStyle(fontSize: 19, fontWeight: FontWeight.w700)),
|
||
if (dosage.isNotEmpty) Text(dosage, style: const TextStyle(fontSize: 16, color: AppColors.textSecondary)),
|
||
]),
|
||
]),
|
||
const SizedBox(height: 14),
|
||
...doses.map((d) {
|
||
final time = d['scheduledTime']?.toString() ?? '';
|
||
final status = d['status']?.toString() ?? 'pending';
|
||
final isTaken = status == 'taken';
|
||
final medId = d['id']?.toString() ?? '';
|
||
return Padding(
|
||
padding: const EdgeInsets.only(bottom: 8),
|
||
child: Row(children: [
|
||
Icon(
|
||
isTaken ? Icons.check_circle : Icons.radio_button_unchecked,
|
||
size: 23,
|
||
color: isTaken ? AppTheme.success : AppTheme.border,
|
||
),
|
||
const SizedBox(width: 10),
|
||
Text(time, style: TextStyle(
|
||
fontSize: 18, fontWeight: FontWeight.w500,
|
||
color: isTaken ? AppTheme.textSub : AppTheme.text,
|
||
)),
|
||
const Spacer(),
|
||
GestureDetector(
|
||
onTap: () => _toggleDose(medId, time, isTaken),
|
||
child: Container(
|
||
width: 40, height: 40,
|
||
decoration: BoxDecoration(
|
||
color: isTaken ? AppColors.successLight : AppColors.cardInner,
|
||
borderRadius: BorderRadius.circular(12),
|
||
),
|
||
child: Icon(
|
||
isTaken ? Icons.check_circle : Icons.check_circle_outline,
|
||
size: 28,
|
||
color: isTaken ? AppTheme.success : AppColors.textHint,
|
||
),
|
||
),
|
||
),
|
||
]),
|
||
);
|
||
}),
|
||
]),
|
||
);
|
||
}).toList(),
|
||
),
|
||
);
|
||
},
|
||
),
|
||
);
|
||
}
|
||
}
|