feat: UI 清新风全面改造 — 朝露主题 + shadcn_ui + 全局字号放大

- 全新"朝露"主题:深青绿主色(#2D6A4F),暖白底,完整设计Token
- 引入 shadcn_ui 组件库,MaterialApp 注入 ShadTheme
- 新增 4 个公共组件:AppCard、AppMenuItem、AppEmptyState、AppTabChip
- 全面消除硬编码颜色,统一使用 AppTheme Token
- 全局字号 +3~4pt,图标等比放大 +3px
- home/medication/profile/settings/login 等核心页面重写
- 路由和功能逻辑零改动
This commit is contained in:
MingNian
2026-06-08 18:06:18 +08:00
parent 16d1d3d305
commit 58af5f6d5b
28 changed files with 1616 additions and 812 deletions

View File

@@ -1,7 +1,10 @@
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});
@@ -9,100 +12,101 @@ class ProfilePage extends ConsumerWidget {
@override Widget build(BuildContext context, WidgetRef ref) {
final auth = ref.watch(authProvider);
final user = auth.user;
final theme = ShadTheme.of(context);
return Scaffold(
backgroundColor: const Color(0xFFF8F9FC),
body: SafeArea(child: SingleChildScrollView(padding: const EdgeInsets.only(bottom: 20), child: Column(children: [
// 用户头部
Container(
width: double.infinity,
padding: const EdgeInsets.all(24),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(24), bottomRight: Radius.circular(24)),
),
child: InkWell(
onTap: () => pushRoute(ref, 'healthArchive'),
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(children: [
Stack(children: [
CircleAvatar(radius: 32, backgroundColor: const Color(0xFFEDEAFF),
backgroundImage: user?.avatarUrl != null ? NetworkImage(user!.avatarUrl!) : null,
child: user?.avatarUrl == null ? const Icon(Icons.person, size: 36, color: Color(0xFF6C5CE7)) : null),
Positioned(right: 0, bottom: 0,
child: Container(width: 20, height: 20,
decoration: BoxDecoration(color: const Color(0xFF6C5CE7), borderRadius: BorderRadius.circular(10), border: Border.all(color: Colors.white, width: 2)),
child: const Icon(Icons.edit, size: 10, color: Colors.white))),
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(width: 16),
Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(user?.name ?? '未设置昵称', style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Color(0xFF1A1A1A))),
const SizedBox(height: 4),
Text(user?.phone ?? '', style: TextStyle(fontSize: 14, color: Colors.grey[500])),
])),
Icon(Icons.chevron_right, size: 24, color: Colors.grey[400]),
]),
),
),
),
),
const SizedBox(height: 12),
_MenuItem(icon: Icons.folder_shared, title: '健康档案', onTap: () => pushRoute(ref, 'healthArchive')),
_MenuItem(icon: Icons.devices, title: '备管理', onTap: () => pushRoute(ref, 'devices')),
_MenuItem(icon: Icons.settings_outlined, title: '设置', onTap: () => pushRoute(ref, 'settings')),
const SizedBox(height: 40),
GestureDetector(
onTap: () async {
final ok = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
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('确定')),
],
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),
),
);
if (ok == true) { await ref.read(authProvider.notifier).logout(); goRoute(ref, 'login'); }
},
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 24),
height: 50, alignment: Alignment.center,
decoration: BoxDecoration(border: Border.all(color: const Color(0xFFE53935)), borderRadius: BorderRadius.circular(25)),
child: const Text('退出登录', style: TextStyle(fontSize: 16, color: Color(0xFFE53935), fontWeight: FontWeight.w500)),
child: Text('退出登录', style: TextStyle(fontSize: 19, color: theme.colorScheme.destructive, fontWeight: FontWeight.w500)),
),
),
),
]))),
]),
)),
);
}
}
class _MenuItem extends StatelessWidget {
final IconData icon;
final String title;
final String? trailing;
final VoidCallback? onTap;
const _MenuItem({required this.icon, required this.title, this.trailing, this.onTap});
@override Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
behavior: HitTestBehavior.opaque,
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 24, vertical: 2),
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 14),
decoration: const BoxDecoration(color: Colors.white),
child: Row(children: [
Container(width: 36, height: 36, decoration: BoxDecoration(color: const Color(0xFFEDEAFF), borderRadius: BorderRadius.circular(10)), child: Icon(icon, size: 18, color: const Color(0xFF6C5CE7))),
const SizedBox(width: 12),
Expanded(child: Text(title, style: const TextStyle(fontSize: 16, color: Color(0xFF1A1A1A)))),
if (trailing != null && trailing!.isNotEmpty) Text(trailing!, style: TextStyle(fontSize: 14, color: Colors.grey[400])),
Icon(Icons.chevron_right, size: 20, color: Colors.grey[300]),
]),
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'); }
}
}