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:
MingNian
2026-07-15 23:22:52 +08:00
parent e654c1e0cc
commit fade61ac21
138 changed files with 12636 additions and 5013 deletions

View File

@@ -13,10 +13,11 @@ class ProfilePage extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final auth = ref.watch(authProvider);
final user = auth.user;
final name = user?.name?.isNotEmpty == true ? user!.name! : '未设置昵称';
final phone = user?.phone ?? '';
final user = ref.watch(authProvider.select((state) => state.user));
final name = user?.name?.trim().isNotEmpty == true ? user!.name! : '未设置昵称';
final phone = user?.phone.trim().isNotEmpty == true
? user!.phone
: '未绑定手机号';
return GradientScaffold(
appBar: AppBar(
@@ -29,23 +30,48 @@ class ProfilePage extends ConsumerWidget {
),
body: SafeArea(
child: ListView(
padding: const EdgeInsets.fromLTRB(18, 16, 18, 32),
padding: const EdgeInsets.fromLTRB(18, 12, 18, 32),
children: [
_AccountCard(
_AccountSummary(
name: name,
phone: phone.isNotEmpty ? phone : '未绑定手机号',
phone: phone,
avatarUrl: user?.avatarUrl,
),
const SizedBox(height: 14),
_ActionTile(
icon: AppModuleVisuals.health.icon,
title: '健康档案',
subtitle: '维护个人资料、病史、手术和过敏信息',
visual: AppModuleVisuals.health,
onTap: () => pushRoute(ref, 'healthArchive'),
const SizedBox(height: 20),
const _SectionTitle('资料管理'),
const SizedBox(height: 9),
_SettingsGroup(
children: [
_ActionRow(
icon: Icons.badge_outlined,
iconColor: AppColors.primary,
title: '基本资料',
subtitle: '姓名、性别和出生日期',
onTap: () => pushRoute(ref, 'profileEdit'),
),
_ActionRow(
icon: AppModuleVisuals.health.icon,
iconColor: AppModuleVisuals.health.color,
title: '健康档案',
subtitle: '疾病、手术、过敏和生活习惯',
onTap: () => pushRoute(ref, 'healthArchive'),
),
],
),
const SizedBox(height: 20),
const _SectionTitle('账号操作'),
const SizedBox(height: 9),
_SettingsGroup(
children: [
_ActionRow(
icon: Icons.logout_rounded,
iconColor: AppColors.textSecondary,
title: '退出登录',
showChevron: false,
onTap: () => _logout(context, ref),
),
],
),
const SizedBox(height: 14),
_LogoutButton(onPressed: () => _logout(context, ref)),
],
),
),
@@ -53,37 +79,37 @@ class ProfilePage extends ConsumerWidget {
}
Future<void> _logout(BuildContext context, WidgetRef ref) async {
final ok = await showDialog<bool>(
final confirmed = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
builder: (dialogContext) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: AppRadius.lgBorder),
title: const Text('退出登录'),
content: const Text('确定退出当前账号?'),
content: const Text('确定退出当前账号'),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx, false),
onPressed: () => Navigator.pop(dialogContext, false),
child: const Text('取消'),
),
TextButton(
onPressed: () => Navigator.pop(ctx, true),
child: const Text('确定', style: TextStyle(color: AppColors.error)),
onPressed: () => Navigator.pop(dialogContext, true),
style: TextButton.styleFrom(foregroundColor: AppColors.errorText),
child: const Text('退出'),
),
],
),
);
if (ok == true) {
await ref.read(authProvider.notifier).logout();
goRoute(ref, 'login');
}
if (confirmed != true || !context.mounted) return;
await ref.read(authProvider.notifier).logout();
goRoute(ref, 'login');
}
}
class _AccountCard extends StatelessWidget {
class _AccountSummary extends StatelessWidget {
final String name;
final String phone;
final String? avatarUrl;
const _AccountCard({
const _AccountSummary({
required this.name,
required this.phone,
required this.avatarUrl,
@@ -91,17 +117,31 @@ class _AccountCard extends StatelessWidget {
@override
Widget build(BuildContext context) => Container(
padding: AppSpacing.panel,
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: AppRadius.lgBorder,
border: Border.all(color: AppColors.border, width: 1.1),
boxShadow: AppShadows.soft,
),
child: Row(
children: [
_Avatar(avatarUrl: avatarUrl),
const SizedBox(width: 14),
Container(
width: 60,
height: 60,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: AppModuleVisuals.health.lightColor,
borderRadius: AppRadius.lgBorder,
),
child: avatarUrl?.isNotEmpty == true
? Image.network(
avatarUrl!,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) =>
const _AvatarFallback(),
)
: const _AvatarFallback(),
),
const SizedBox(width: 15),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -113,11 +153,11 @@ class _AccountCard extends StatelessWidget {
style: AppTextStyles.summaryTitle.copyWith(fontSize: 20),
),
const SizedBox(height: 5),
Text(
phone,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppTextStyles.listSubtitle,
Text(phone, style: AppTextStyles.listSubtitle),
const SizedBox(height: 5),
const Text(
'头像由账号系统统一管理',
style: TextStyle(fontSize: 12, color: AppColors.textHint),
),
],
),
@@ -127,103 +167,124 @@ class _AccountCard extends StatelessWidget {
);
}
class _Avatar extends StatelessWidget {
final String? avatarUrl;
const _Avatar({required this.avatarUrl});
class _AvatarFallback extends StatelessWidget {
const _AvatarFallback();
@override
Widget build(BuildContext context) => Container(
width: 58,
height: 58,
decoration: BoxDecoration(
gradient: AppModuleVisuals.health.gradient,
borderRadius: AppRadius.lgBorder,
),
clipBehavior: Clip.antiAlias,
child: avatarUrl != null && avatarUrl!.isNotEmpty
? Image.network(avatarUrl!, fit: BoxFit.cover)
: const Icon(Icons.person_rounded, color: Colors.white, size: 34),
Widget build(BuildContext context) => Icon(
Icons.person_rounded,
color: AppModuleVisuals.health.color,
size: 34,
);
}
class _ActionTile extends StatelessWidget {
class _SectionTitle extends StatelessWidget {
final String text;
const _SectionTitle(this.text);
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 2),
child: Text(
text,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w800,
color: AppColors.textSecondary,
),
),
);
}
class _SettingsGroup extends StatelessWidget {
final List<Widget> children;
const _SettingsGroup({required this.children});
@override
Widget build(BuildContext context) => Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: AppRadius.lgBorder,
),
child: Column(
children: [
for (var i = 0; i < children.length; i++) ...[
children[i],
if (i != children.length - 1)
const Padding(
padding: EdgeInsets.only(left: 62),
child: Divider(height: 1, color: AppColors.borderLight),
),
],
],
),
);
}
class _ActionRow extends StatelessWidget {
final IconData icon;
final Color iconColor;
final String title;
final String subtitle;
final AppModuleVisual visual;
final String? subtitle;
final bool showChevron;
final VoidCallback onTap;
const _ActionTile({
const _ActionRow({
required this.icon,
required this.iconColor,
required this.title,
required this.subtitle,
required this.visual,
this.subtitle,
this.showChevron = true,
required this.onTap,
});
@override
Widget build(BuildContext context) => Material(
color: Colors.white,
borderRadius: AppRadius.lgBorder,
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: AppRadius.lgBorder,
child: Container(
padding: const EdgeInsets.all(15),
decoration: BoxDecoration(
borderRadius: AppRadius.lgBorder,
border: Border.all(color: AppColors.border, width: 1.1),
boxShadow: AppShadows.soft,
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 14),
child: Row(
children: [
Container(
width: 46,
height: 46,
width: 36,
height: 36,
decoration: BoxDecoration(
gradient: visual.gradient,
borderRadius: AppRadius.mdBorder,
color: iconColor.withValues(alpha: 0.10),
borderRadius: AppRadius.smBorder,
),
child: Icon(icon, color: Colors.white, size: 24),
child: Icon(icon, color: iconColor, size: 20),
),
const SizedBox(width: 13),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: AppTextStyles.listTitle),
const SizedBox(height: 4),
Text(
subtitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppTextStyles.listSubtitle,
title,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w800,
color: AppColors.textPrimary,
),
),
if (subtitle != null) ...[
const SizedBox(height: 3),
Text(subtitle!, style: AppTextStyles.listSubtitle),
],
],
),
),
const Icon(Icons.chevron_right_rounded, color: AppColors.textHint),
if (showChevron)
const Icon(
Icons.chevron_right_rounded,
color: AppColors.textHint,
),
],
),
),
),
);
}
class _LogoutButton extends StatelessWidget {
final VoidCallback onPressed;
const _LogoutButton({required this.onPressed});
@override
Widget build(BuildContext context) => TextButton(
onPressed: onPressed,
style: TextButton.styleFrom(
foregroundColor: AppColors.error,
padding: const EdgeInsets.symmetric(vertical: 14),
textStyle: AppTextStyles.button,
),
child: const Text('退出登录'),
);
}