Files
AI-Health/health_app/lib/pages/profile/profile_page.dart
MingNian 18df2f3285 style: 统一患者端页面视觉并补齐入口跳转
- 调整全局颜色基调,提高灰色文字和边框对比度
- 新增企业级页面头部、统计块和卡片通用组件
- 优化用药管理、报告管理、个人信息、通知中心页面布局
- 新增多张页面插画和通用 UI 装饰素材
- 运动计划列表更紧凑,并新增运动计划详情路由
- 补齐医生端协议入口和原始报告查看入口
- 移除设置页未实现的字体大小和清除缓存入口
2026-06-25 22:13:42 +08:00

292 lines
9.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/app_colors.dart';
import '../../core/app_theme.dart';
import '../../core/navigation_provider.dart';
import '../../providers/auth_provider.dart';
import '../../widgets/enterprise_widgets.dart';
class ProfilePage extends ConsumerWidget {
const ProfilePage({super.key});
@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 ?? '';
return GradientScaffold(
appBar: AppBar(
backgroundColor: Colors.white.withValues(alpha: 0.86),
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios_new_rounded, size: 19),
onPressed: () => popRoute(ref),
),
title: const Text(
'个人信息',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w800),
),
centerTitle: true,
),
body: SafeArea(
child: SingleChildScrollView(
padding: const EdgeInsets.fromLTRB(20, 18, 20, 34),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
EnterpriseHeader(
title: name,
subtitle: phone.isNotEmpty ? phone : '未绑定手机',
icon: Icons.person_rounded,
color: const Color(0xFF38BDF8),
accent: const Color(0xFF8B5CF6),
stats: const [
EnterpriseStat(
label: '账号状态',
value: '已登录',
icon: Icons.verified_user_rounded,
),
EnterpriseStat(
label: '健康资料',
value: '可维护',
icon: Icons.folder_shared_rounded,
),
],
trailing: _AvatarBadge(avatarUrl: user?.avatarUrl),
),
const SizedBox(height: 18),
_InfoPanel(
children: [
_InfoRow(
icon: Icons.badge_rounded,
label: '姓名',
value: name,
colors: const [Color(0xFF7DD3FC), Color(0xFF38BDF8)],
),
const _SoftDivider(),
_InfoRow(
icon: Icons.phone_iphone_rounded,
label: '手机号',
value: phone.isNotEmpty ? phone : '未绑定手机',
colors: const [Color(0xFFFBCFE8), Color(0xFFF472B6)],
),
const _SoftDivider(),
_InfoRow(
icon: Icons.folder_shared_rounded,
label: '健康档案',
value: '查看和维护基础健康资料',
colors: const [Color(0xFFC4B5FD), Color(0xFF8B5CF6)],
onTap: () => pushRoute(ref, 'healthArchive'),
),
],
),
const SizedBox(height: 18),
_InfoPanel(
children: [
_InfoRow(
icon: Icons.verified_user_rounded,
label: '隐私保护',
value: '健康数据仅用于个人健康管理',
colors: const [Color(0xFFFFB4A2), Color(0xFFFB7185)],
),
],
),
const SizedBox(height: 28),
OutlinedButton.icon(
onPressed: () => _logout(context, ref),
icon: const Icon(Icons.logout_rounded, size: 19),
label: const Text('退出登录'),
style: OutlinedButton.styleFrom(
foregroundColor: AppColors.error,
side: BorderSide(
color: AppColors.error.withValues(alpha: 0.34),
),
minimumSize: const Size.fromHeight(52),
textStyle: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w800,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18),
),
),
),
],
),
),
),
);
}
Future<void> _logout(BuildContext context, WidgetRef ref) async {
final ok = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppTheme.rXl),
),
title: const Text('退出登录'),
content: const Text('确定退出当前账号?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx, false),
child: const Text('取消'),
),
TextButton(
onPressed: () => Navigator.pop(ctx, true),
child: const Text('确定', style: TextStyle(color: AppColors.error)),
),
],
),
);
if (ok == true) {
await ref.read(authProvider.notifier).logout();
goRoute(ref, 'login');
}
}
}
class _AvatarBadge extends StatelessWidget {
final String? avatarUrl;
const _AvatarBadge({required this.avatarUrl});
@override
Widget build(BuildContext context) {
return Container(
width: 50,
height: 50,
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
color: const Color(0xFFF8FAFC),
borderRadius: BorderRadius.circular(16),
border: Border.all(color: AppColors.border, width: 1.1),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(14),
child: avatarUrl != null
? Image.network(avatarUrl!, fit: BoxFit.cover)
: const ColoredBox(
color: Colors.white,
child: Icon(
Icons.person_rounded,
color: Color(0xFF38BDF8),
size: 30,
),
),
),
);
}
}
class _InfoPanel extends StatelessWidget {
final List<Widget> children;
const _InfoPanel({required this.children});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(18),
border: Border.all(color: AppColors.borderLight),
boxShadow: AppColors.cardShadowLight,
),
child: Column(children: children),
);
}
}
class _InfoRow extends StatelessWidget {
final IconData icon;
final String label;
final String value;
final List<Color> colors;
final VoidCallback? onTap;
const _InfoRow({
required this.icon,
required this.label,
required this.value,
required this.colors,
this.onTap,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(14),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 12),
child: Row(
children: [
Container(
width: 42,
height: 42,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: colors,
),
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: colors.last.withValues(alpha: 0.18),
blurRadius: 12,
offset: const Offset(0, 5),
),
],
),
child: Icon(icon, color: Colors.white, size: 22),
),
const SizedBox(width: 13),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: AppColors.textHint,
),
),
const SizedBox(height: 4),
Text(
value,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w800,
color: AppColors.textPrimary,
),
),
],
),
),
if (onTap != null)
const Icon(
Icons.arrow_forward_ios_rounded,
size: 16,
color: AppColors.textHint,
),
],
),
),
);
}
}
class _SoftDivider extends StatelessWidget {
const _SoftDivider();
@override
Widget build(BuildContext context) {
return const Divider(height: 1, color: AppColors.divider);
}
}