- 全新"朝露"主题:深青绿主色(#2D6A4F),暖白底,完整设计Token - 引入 shadcn_ui 组件库,MaterialApp 注入 ShadTheme - 新增 4 个公共组件:AppCard、AppMenuItem、AppEmptyState、AppTabChip - 全面消除硬编码颜色,统一使用 AppTheme Token - 全局字号 +3~4pt,图标等比放大 +3px - home/medication/profile/settings/login 等核心页面重写 - 路由和功能逻辑零改动
113 lines
5.2 KiB
Dart
113 lines
5.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:shadcn_ui/shadcn_ui.dart';
|
|
import '../../core/app_theme.dart';
|
|
import '../../core/navigation_provider.dart';
|
|
import '../../providers/auth_provider.dart';
|
|
import '../../widgets/app_menu_item.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 theme = ShadTheme.of(context);
|
|
|
|
return Scaffold(
|
|
backgroundColor: theme.colorScheme.background,
|
|
body: SafeArea(child: SingleChildScrollView(
|
|
padding: const EdgeInsets.only(bottom: AppTheme.sXl),
|
|
child: Column(children: [
|
|
// 用户头部卡片
|
|
Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(AppTheme.rXl),
|
|
decoration: BoxDecoration(
|
|
color: theme.colorScheme.card,
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(AppTheme.rXl),
|
|
bottomRight: Radius.circular(AppTheme.rXl),
|
|
),
|
|
boxShadow: [AppTheme.shadowLight],
|
|
),
|
|
child: InkWell(
|
|
onTap: () => pushRoute(ref, 'healthArchive'),
|
|
borderRadius: BorderRadius.circular(AppTheme.rSm),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: AppTheme.sSm),
|
|
child: Row(children: [
|
|
Stack(children: [
|
|
CircleAvatar(
|
|
radius: 32,
|
|
backgroundColor: AppTheme.primaryLight,
|
|
backgroundImage: user?.avatarUrl != null ? NetworkImage(user!.avatarUrl!) : null,
|
|
child: user?.avatarUrl == null ? const Icon(Icons.person, size: 36, color: AppTheme.primary) : null,
|
|
),
|
|
Positioned(
|
|
right: 0, bottom: 0,
|
|
child: Container(
|
|
width: 20, height: 20,
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.primary,
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: Border.all(color: theme.colorScheme.card, width: 2),
|
|
),
|
|
child: const Icon(Icons.edit, size: 13, color: Colors.white),
|
|
),
|
|
),
|
|
]),
|
|
const SizedBox(width: AppTheme.sLg),
|
|
Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
Text(user?.name ?? '未设置昵称',
|
|
style: TextStyle(fontSize: 23, fontWeight: FontWeight.bold, color: theme.colorScheme.foreground)),
|
|
const SizedBox(height: 4),
|
|
Text(user?.phone ?? '', style: TextStyle(fontSize: 17, color: theme.colorScheme.mutedForeground)),
|
|
])),
|
|
Icon(LucideIcons.chevronRight, size: 25, color: theme.colorScheme.mutedForeground),
|
|
]),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: AppTheme.sMd),
|
|
AppMenuItem(icon: LucideIcons.folderArchive, title: '健康档案', onTap: () => pushRoute(ref, 'healthArchive')),
|
|
AppMenuItem(icon: LucideIcons.monitorSmartphone, title: '设备管理', onTap: () => pushRoute(ref, 'devices')),
|
|
AppMenuItem(icon: LucideIcons.settings, title: '设置', onTap: () => pushRoute(ref, 'settings')),
|
|
const SizedBox(height: 40),
|
|
// 退出登录
|
|
GestureDetector(
|
|
onTap: () => _logout(context, ref),
|
|
child: Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: AppTheme.rXl),
|
|
height: 50,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: theme.colorScheme.destructive.withAlpha(80)),
|
|
borderRadius: BorderRadius.circular(AppTheme.rPill),
|
|
),
|
|
child: Text('退出登录', style: TextStyle(fontSize: 19, color: theme.colorScheme.destructive, fontWeight: FontWeight.w500)),
|
|
),
|
|
),
|
|
]),
|
|
)),
|
|
);
|
|
}
|
|
|
|
Future<void> _logout(BuildContext context, WidgetRef ref) async {
|
|
final theme = ShadTheme.of(context);
|
|
final ok = await showDialog<bool>(
|
|
context: context,
|
|
builder: (ctx) => AlertDialog(
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppTheme.rXl)),
|
|
title: Text('退出登录', style: TextStyle(color: theme.colorScheme.foreground)),
|
|
content: Text('确定退出?', style: TextStyle(color: theme.colorScheme.mutedForeground)),
|
|
actions: [
|
|
TextButton(onPressed: () => Navigator.pop(ctx, false), child: Text('取消', style: TextStyle(color: theme.colorScheme.mutedForeground))),
|
|
TextButton(onPressed: () => Navigator.pop(ctx, true), child: Text('确定', style: TextStyle(color: theme.colorScheme.destructive))),
|
|
],
|
|
),
|
|
);
|
|
if (ok == true) { await ref.read(authProvider.notifier).logout(); goRoute(ref, 'login'); }
|
|
}
|
|
}
|