- 后端: 新增 AttachmentContextBuilder 解析图片/PDF 摘要并拼入 LLM 上下文; ai_chat_endpoints 扩展附件接口; 新增 ReportAnalysisService - 前端: 新增历史会话页与 conversation_history_provider; chat 链路支持附件展示与回放 - UI: 重构 medication_checkin / notification_center / profile / health_drawer 等多页面 - 配置: api_client baseUrl 适配当前 WiFi IP
259 lines
7.4 KiB
Dart
259 lines
7.4 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';
|
|
|
|
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(
|
|
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, 16, 18, 32),
|
|
children: [
|
|
_AccountCard(
|
|
name: name,
|
|
phone: phone.isNotEmpty ? phone : '未绑定手机号',
|
|
avatarUrl: user?.avatarUrl,
|
|
),
|
|
const SizedBox(height: 14),
|
|
_ActionTile(
|
|
icon: Icons.folder_shared_outlined,
|
|
title: '健康档案',
|
|
subtitle: '维护个人资料、病史、手术和过敏信息',
|
|
color: const Color(0xFF8B5CF6),
|
|
onTap: () => pushRoute(ref, 'healthArchive'),
|
|
),
|
|
const SizedBox(height: 14),
|
|
_LogoutButton(onPressed: () => _logout(context, ref)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> _logout(BuildContext context, WidgetRef ref) async {
|
|
final ok = await showDialog<bool>(
|
|
context: context,
|
|
builder: (ctx) => AlertDialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(AppTheme.rLg),
|
|
),
|
|
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 _AccountCard extends StatelessWidget {
|
|
final String name;
|
|
final String phone;
|
|
final String? avatarUrl;
|
|
|
|
const _AccountCard({
|
|
required this.name,
|
|
required this.phone,
|
|
required this.avatarUrl,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(16),
|
|
border: Border.all(color: AppColors.border, width: 1.1),
|
|
boxShadow: [AppTheme.shadowLight],
|
|
),
|
|
child: Row(
|
|
children: [
|
|
_Avatar(avatarUrl: avatarUrl),
|
|
const SizedBox(width: 14),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
name,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w800,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
const SizedBox(height: 5),
|
|
Text(
|
|
phone,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
class _Avatar extends StatelessWidget {
|
|
final String? avatarUrl;
|
|
|
|
const _Avatar({required this.avatarUrl});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Container(
|
|
width: 58,
|
|
height: 58,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.iconBg,
|
|
borderRadius: BorderRadius.circular(18),
|
|
border: Border.all(color: AppColors.borderLight),
|
|
),
|
|
clipBehavior: Clip.antiAlias,
|
|
child: avatarUrl != null && avatarUrl!.isNotEmpty
|
|
? Image.network(avatarUrl!, fit: BoxFit.cover)
|
|
: const Icon(
|
|
Icons.person_rounded,
|
|
color: AppColors.blueMeasure,
|
|
size: 34,
|
|
),
|
|
);
|
|
}
|
|
|
|
class _ActionTile extends StatelessWidget {
|
|
final IconData icon;
|
|
final String title;
|
|
final String subtitle;
|
|
final Color color;
|
|
final VoidCallback onTap;
|
|
|
|
const _ActionTile({
|
|
required this.icon,
|
|
required this.title,
|
|
required this.subtitle,
|
|
required this.color,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Material(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(16),
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(16),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(15),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(16),
|
|
border: Border.all(color: AppColors.border, width: 1.1),
|
|
boxShadow: [AppTheme.shadowLight],
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
width: 46,
|
|
height: 46,
|
|
decoration: BoxDecoration(
|
|
color: color.withValues(alpha: 0.10),
|
|
borderRadius: BorderRadius.circular(14),
|
|
),
|
|
child: Icon(icon, color: color, size: 24),
|
|
),
|
|
const SizedBox(width: 13),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 17,
|
|
fontWeight: FontWeight.w800,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
subtitle,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const Icon(
|
|
Icons.chevron_right_rounded,
|
|
size: 22,
|
|
color: AppColors.textHint,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
class _LogoutButton extends StatelessWidget {
|
|
final VoidCallback onPressed;
|
|
|
|
const _LogoutButton({required this.onPressed});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => OutlinedButton.icon(
|
|
onPressed: onPressed,
|
|
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(16)),
|
|
),
|
|
);
|
|
}
|