## 后端 - 健康档案: 新增手术状态字段 + 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 目录
291 lines
8.4 KiB
Dart
291 lines
8.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../../core/app_colors.dart';
|
|
import '../../core/app_design_tokens.dart';
|
|
import '../../core/app_module_visuals.dart';
|
|
import '../../core/app_theme.dart';
|
|
import '../../core/navigation_provider.dart';
|
|
import '../../providers/auth_provider.dart';
|
|
|
|
class ProfilePage extends ConsumerWidget {
|
|
const ProfilePage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
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(
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.arrow_back_ios_new_rounded, size: 19),
|
|
onPressed: () => popRoute(ref),
|
|
),
|
|
title: const Text('个人信息'),
|
|
centerTitle: true,
|
|
),
|
|
body: SafeArea(
|
|
child: ListView(
|
|
padding: const EdgeInsets.fromLTRB(18, 12, 18, 32),
|
|
children: [
|
|
_AccountSummary(
|
|
name: name,
|
|
phone: phone,
|
|
avatarUrl: user?.avatarUrl,
|
|
),
|
|
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),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> _logout(BuildContext context, WidgetRef ref) async {
|
|
final confirmed = await showDialog<bool>(
|
|
context: context,
|
|
builder: (dialogContext) => AlertDialog(
|
|
shape: RoundedRectangleBorder(borderRadius: AppRadius.lgBorder),
|
|
title: const Text('退出登录'),
|
|
content: const Text('确定退出当前账号吗?'),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(dialogContext, false),
|
|
child: const Text('取消'),
|
|
),
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(dialogContext, true),
|
|
style: TextButton.styleFrom(foregroundColor: AppColors.errorText),
|
|
child: const Text('退出'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
if (confirmed != true || !context.mounted) return;
|
|
await ref.read(authProvider.notifier).logout();
|
|
goRoute(ref, 'login');
|
|
}
|
|
}
|
|
|
|
class _AccountSummary extends StatelessWidget {
|
|
final String name;
|
|
final String phone;
|
|
final String? avatarUrl;
|
|
|
|
const _AccountSummary({
|
|
required this.name,
|
|
required this.phone,
|
|
required this.avatarUrl,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Container(
|
|
padding: const EdgeInsets.all(18),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: AppRadius.lgBorder,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
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,
|
|
children: [
|
|
Text(
|
|
name,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: AppTextStyles.summaryTitle.copyWith(fontSize: 20),
|
|
),
|
|
const SizedBox(height: 5),
|
|
Text(phone, style: AppTextStyles.listSubtitle),
|
|
const SizedBox(height: 5),
|
|
const Text(
|
|
'头像由账号系统统一管理',
|
|
style: TextStyle(fontSize: 12, color: AppColors.textHint),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
class _AvatarFallback extends StatelessWidget {
|
|
const _AvatarFallback();
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Icon(
|
|
Icons.person_rounded,
|
|
color: AppModuleVisuals.health.color,
|
|
size: 34,
|
|
);
|
|
}
|
|
|
|
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 bool showChevron;
|
|
final VoidCallback onTap;
|
|
|
|
const _ActionRow({
|
|
required this.icon,
|
|
required this.iconColor,
|
|
required this.title,
|
|
this.subtitle,
|
|
this.showChevron = true,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Material(
|
|
color: Colors.transparent,
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
borderRadius: AppRadius.lgBorder,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 14),
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
width: 36,
|
|
height: 36,
|
|
decoration: BoxDecoration(
|
|
color: iconColor.withValues(alpha: 0.10),
|
|
borderRadius: AppRadius.smBorder,
|
|
),
|
|
child: Icon(icon, color: iconColor, size: 20),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w800,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
if (subtitle != null) ...[
|
|
const SizedBox(height: 3),
|
|
Text(subtitle!, style: AppTextStyles.listSubtitle),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
if (showChevron)
|
|
const Icon(
|
|
Icons.chevron_right_rounded,
|
|
color: AppColors.textHint,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|