feat: 二级页面色彩刷新 + 用药/通知/设备重构 + 后端健康档案/通知管线增强 + 大量测试
## 后端 - 健康档案: 新增手术状态字段 + EF 迁移; HealthArchiveService 新增查询方法 - 健康记录: HealthRecordService 新增批量/统计方法; 契约扩展 - 用药: 新增 MedicationScheduleStatus 枚举; MedicationService 排班逻辑调整 - 通知: EfUserNotificationPipeline 重构; 新增 EfReminderCatchUpService; 通知管线支持更多场景 - 用户: UserService 账号删除逻辑; 新增 local_account_file_cleanup; EfUserRepository 扩展 - AI: medication_agent_handler 微调; prompt_manager 优化; AiConversationService 上下文处理 - Endpoint: doctor/medication/exercise/health/notification/user 等多接口调整 - BackgroundService: health_record_reminder_service 重构, 提醒补漏逻辑 - 测试: 新增 account_deletion/doctor_endpoint/medication_schedule/medication_update/prompt_manager 测试 ## 前端 - UI 系统: app_theme 大幅重构; app_colors/app_design_tokens/app_module_visuals 调整; 二级页面色彩刷新 - 主页: home_page 背景渐变 + 消息列表提取 _HomeMessages + 通知检查逻辑; chat_messages_view 全面重构 - 用药: medication_list/edit/checkin 三页重构, 新增 medication_ui_logic 抽取 - 通知: notification_prefs_page 重构, 新增 notification_prefs_logic; notification_center 优化 - 设备: device_management 重构, 新增 device_sync_ui_logic; device_scan 优化 - 趋势图: trend_page 大幅重构 - 登录: login_page 重构 - 个人资料: 新增 profile_edit_page; profile_page 优化 - 运动: 新增 exercise/ 目录 + care_plan_ui_logic - 其他: remaining_pages/report_pages/health_drawer/admin/doctor 等多页面调整 - 组件: common_widgets/app_empty_state/app_error_state/app_future_view/app_toast/ai_content 优化 - Provider: chat_provider/consultation_provider/data_providers/auth_provider 调整 - AndroidManifest: 移除多余权限 - 测试: 新增 ai_content/care_plan/home_message/login_flow/medication_checkin/medication_ui/notification_prefs/profile_device/secondary_page/swipe_delete 等大量测试 ## 文档 - 新增 ui-design-system.md 设计系统文档 - 新增 secondary-page-color-refresh 计划 + specs 目录
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/app_design_tokens.dart';
|
||||
import '../../core/app_theme.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../widgets/ai_content.dart';
|
||||
import '../../widgets/app_error_state.dart';
|
||||
import '../../widgets/common_widgets.dart';
|
||||
import 'report_pages.dart';
|
||||
|
||||
/// AI 解读页:从服务器获取真实报告数据
|
||||
@@ -26,14 +29,18 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final analysis = ref.watch(reportProvider.select((s) => s.currentAnalysis));
|
||||
final reports = ref.watch(reportProvider.select((s) => s.reports));
|
||||
final reportState = ref.watch(reportProvider);
|
||||
final analysis = reportState.currentAnalysis;
|
||||
final reports = reportState.reports;
|
||||
final reportItem = reports.where((r) => r.id == widget.id).firstOrNull;
|
||||
|
||||
if (analysis == null) {
|
||||
if (reportState.isLoadingDetail) {
|
||||
return GradientScaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(icon: const Icon(Icons.arrow_back), onPressed: () => popRoute(ref)),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => popRoute(ref),
|
||||
),
|
||||
title: const Text('报告解读'),
|
||||
),
|
||||
body: const Center(
|
||||
@@ -42,10 +49,30 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
);
|
||||
}
|
||||
|
||||
if (analysis == null) {
|
||||
return GradientScaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => popRoute(ref),
|
||||
),
|
||||
title: const Text('报告解读'),
|
||||
),
|
||||
body: AppErrorState(
|
||||
title: '报告详情加载失败',
|
||||
subtitle: reportState.detailError ?? '暂时无法读取这份报告',
|
||||
onRetry: () =>
|
||||
ref.read(reportProvider.notifier).fetchReportDetail(widget.id),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final displayType = _displayName(analysis.reportType);
|
||||
final aiStatus = reportItem?.aiStatus ?? analysis.aiStatus;
|
||||
final reviewStatus = reportItem?.reviewStatus ?? analysis.reviewStatus;
|
||||
final fileUrl = reportItem?.fileUrl ?? analysis.fileUrl;
|
||||
final fileType = reportItem?.type ?? analysis.fileType;
|
||||
final isPdf = isPdfReport(fileType, fileUrl ?? '');
|
||||
final isReviewed = reviewStatus == 'Reviewed';
|
||||
final isAnalyzing = aiStatus == 'Analyzing';
|
||||
final isFailed = aiStatus == 'Failed';
|
||||
@@ -73,6 +100,10 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (reportState.detailError != null) ...[
|
||||
_detailErrorBanner(reportState.detailError!),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
if (fileUrl != null && fileUrl.isNotEmpty) ...[
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
@@ -80,16 +111,26 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
onPressed: () => pushRoute(
|
||||
ref,
|
||||
'reportOriginal',
|
||||
params: {'url': fileUrl, 'title': displayType},
|
||||
params: {
|
||||
'url': fileUrl,
|
||||
'title': displayType,
|
||||
'fileType': fileType,
|
||||
},
|
||||
),
|
||||
icon: Icon(
|
||||
isPdf
|
||||
? Icons.picture_as_pdf_outlined
|
||||
: Icons.image_outlined,
|
||||
size: 18,
|
||||
),
|
||||
icon: const Icon(Icons.image_outlined, size: 18),
|
||||
label: const Text('查看原始报告'),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: AppColors.primary,
|
||||
side: const BorderSide(color: AppColors.primaryLight),
|
||||
foregroundColor: AppColors.textPrimary,
|
||||
backgroundColor: Colors.white,
|
||||
side: const BorderSide(color: AppColors.border),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: AppRadius.mdBorder,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -99,17 +140,26 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
if (isAnalyzing || isFailed) ...[
|
||||
_analysisStateCard(
|
||||
isFailed
|
||||
? (analysis.summary.isNotEmpty ? analysis.summary : 'AI 分析失败,请重新上传或稍后重试')
|
||||
: 'AI 正在分析报告,请稍后刷新查看',
|
||||
? (analysis.summary.isNotEmpty
|
||||
? analysis.summary
|
||||
: 'AI 分析失败,请重新上传或稍后重试')
|
||||
: (reportState.pollingTimedOut
|
||||
? '分析时间比预期更长,您可以稍后返回此页查看'
|
||||
: 'AI 正在分析报告,请稍后刷新查看'),
|
||||
isFailed: isFailed,
|
||||
busy: reportState.reanalyzingReportId == widget.id,
|
||||
onRetry: isFailed
|
||||
? () => ref.read(reportProvider.notifier).reanalyzeReport(widget.id)
|
||||
? () => ref
|
||||
.read(reportProvider.notifier)
|
||||
.reanalyzeReport(widget.id)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
// 指标分析
|
||||
if (!isAnalyzing && !isFailed && analysis.indicators.isNotEmpty) ...[
|
||||
if (!isAnalyzing &&
|
||||
!isFailed &&
|
||||
analysis.indicators.isNotEmpty) ...[
|
||||
_sectionTitle('指标分析'),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
@@ -147,8 +197,8 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
// 医生审核意见
|
||||
_sectionTitle('医生审核意见'),
|
||||
const SizedBox(height: 8),
|
||||
if (isReviewed)
|
||||
_doctorReviewCard(reportItem!)
|
||||
if (isReviewed && reportItem != null)
|
||||
_doctorReviewCard(reportItem)
|
||||
else
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -171,7 +221,10 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
Spacer(),
|
||||
Text(
|
||||
'AI 预解读',
|
||||
style: TextStyle(fontSize: 14, color: AppColors.textHint),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -184,19 +237,16 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
);
|
||||
}
|
||||
|
||||
BoxDecoration _cardDeco() => BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: AppColors.border),
|
||||
boxShadow: AppColors.cardShadowLight,
|
||||
);
|
||||
BoxDecoration _cardDeco() =>
|
||||
BoxDecoration(color: Colors.white, borderRadius: AppRadius.lgBorder);
|
||||
|
||||
Widget _analysisStateCard(
|
||||
String message, {
|
||||
required bool isFailed,
|
||||
bool busy = false,
|
||||
VoidCallback? onRetry,
|
||||
}) {
|
||||
final color = isFailed ? AppColors.error : AppColors.primary;
|
||||
final color = isFailed ? AppColors.errorText : AppColors.primary;
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: _cardDeco(),
|
||||
@@ -217,7 +267,9 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
height: 1.6,
|
||||
color: isFailed ? AppColors.error : AppColors.textPrimary,
|
||||
color: isFailed
|
||||
? AppColors.errorText
|
||||
: AppColors.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
@@ -228,18 +280,10 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
const SizedBox(height: 14),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: onRetry,
|
||||
icon: const Icon(Icons.refresh, size: 18),
|
||||
label: const Text('重新分析'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.primary,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: AppGradientOutlineButton(
|
||||
label: busy ? '正在重新分析...' : '重新分析',
|
||||
loading: busy,
|
||||
onPressed: busy ? null : onRetry,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -248,6 +292,32 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _detailErrorBanner(String message) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.errorLight,
|
||||
borderRadius: AppRadius.mdBorder,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.error_outline, color: AppColors.errorText, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
message,
|
||||
style: const TextStyle(
|
||||
color: AppColors.errorText,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _sectionTitle(String text) => Row(
|
||||
children: [
|
||||
Container(
|
||||
@@ -272,9 +342,9 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
|
||||
Widget _indicatorRow(Indicator ind) {
|
||||
final (color, icon) = switch (ind.status) {
|
||||
'high' => (AppColors.error, Icons.arrow_upward),
|
||||
'low' => (AppColors.warning, Icons.arrow_downward),
|
||||
_ => (AppColors.success, Icons.check_circle),
|
||||
'high' => (AppColors.errorText, Icons.arrow_upward),
|
||||
'low' => (AppColors.warningText, Icons.arrow_downward),
|
||||
_ => (AppColors.successText, Icons.check_circle),
|
||||
};
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
@@ -341,7 +411,7 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.cardInner,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: AppRadius.mdBorder,
|
||||
),
|
||||
child: Text(
|
||||
report.doctorComment!,
|
||||
@@ -360,7 +430,7 @@ class _AiAnalysisPageState extends ConsumerState<AiAnalysisPage> {
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.cardInner,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: AppRadius.mdBorder,
|
||||
),
|
||||
child: Text(
|
||||
report.doctorRecommendation!,
|
||||
|
||||
Reference in New Issue
Block a user