af002edde3
- app_theme.dart 重写为语义 token(AppColors/AppRadius),落地 primaryStrong/error 等 AA 对比度色 - 五个页面与公共组件的旧靛蓝硬编码色值全部替换为 token,仅换色不动布局 - 新增 BrandMark/AppTextField/PrimaryButton/InlineErrorBanner/AuthScaffold 及 6 个 widget 测试 - 门禁:dart format(0 changed)/ flutter analyze(0 issues)/ flutter test(7 passed) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
171 lines
5.5 KiB
Dart
171 lines
5.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:patbond_flutter/core/theme/app_theme.dart';
|
|
import 'package:patbond_flutter/data/demo_data.dart';
|
|
import 'package:patbond_flutter/state/app_state.dart';
|
|
import 'package:patbond_flutter/widgets/common.dart';
|
|
|
|
class ProfilePage extends StatelessWidget {
|
|
const ProfilePage({required this.appState, super.key});
|
|
|
|
final AppState appState;
|
|
|
|
static const menuItems = [
|
|
(Icons.assignment_outlined, '我的预约订单', '查看进行中与历史服务'),
|
|
(Icons.bookmarks_outlined, '我的收藏与草稿', '已保存的宠物作品与攻略'),
|
|
(Icons.badge_outlined, '宠物健康卡包', '电子接种证与体检报告'),
|
|
(Icons.location_on_outlined, '地址与定位管理', '管理家庭住址与常用医院'),
|
|
(Icons.settings_outlined, '设置与关于', '隐私设置与版本信息'),
|
|
];
|
|
|
|
void showDemoMessage(BuildContext context, String name) {
|
|
ScaffoldMessenger.of(
|
|
context,
|
|
).showSnackBar(SnackBar(content: Text('「$name」功能为演示入口')));
|
|
}
|
|
|
|
Future<void> reset(BuildContext context) async {
|
|
final confirmed = await showDialog<bool>(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: const Text('恢复演示数据'),
|
|
content: const Text('宠物资料、疫苗记录以及新增帖子都会恢复为初始状态。'),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context, false),
|
|
child: const Text('取消'),
|
|
),
|
|
FilledButton(
|
|
onPressed: () => Navigator.pop(context, true),
|
|
child: const Text('确认恢复'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
if (confirmed == true) {
|
|
await appState.resetDemoData();
|
|
if (context.mounted) {
|
|
ScaffoldMessenger.of(
|
|
context,
|
|
).showSnackBar(const SnackBar(content: Text('演示数据已恢复')));
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListView(
|
|
padding: const EdgeInsets.fromLTRB(16, 16, 16, 30),
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(24),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.ink,
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
RemoteImage(
|
|
url: userAvatar,
|
|
width: 82,
|
|
height: 82,
|
|
borderRadius: BorderRadius.circular(41),
|
|
),
|
|
const SizedBox(height: 12),
|
|
const Text(
|
|
'萌宠新手(豆豆家长)',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 17,
|
|
fontWeight: FontWeight.w800,
|
|
),
|
|
),
|
|
const SizedBox(height: 5),
|
|
const Text(
|
|
'Patbond 社区创作达人',
|
|
style: TextStyle(color: AppColors.accent, fontSize: 12),
|
|
),
|
|
const SizedBox(height: 20),
|
|
const Divider(color: Colors.white24),
|
|
const SizedBox(height: 10),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
const _ProfileStat(value: '24', label: '关注我'),
|
|
const _ProfileStat(value: '1.8k', label: '获赞'),
|
|
_ProfileStat(
|
|
value: '${appState.posts.length}',
|
|
label: '我的作品',
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 18),
|
|
SectionCard(
|
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
|
child: Column(
|
|
children: menuItems.map((item) {
|
|
return ListTile(
|
|
leading: CircleAvatar(
|
|
backgroundColor: AppColors.surfaceTint,
|
|
child: Icon(item.$1, color: AppColors.primary),
|
|
),
|
|
title: Text(
|
|
item.$2,
|
|
style: const TextStyle(fontWeight: FontWeight.w700),
|
|
),
|
|
subtitle: Text(item.$3),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: () => showDemoMessage(context, item.$2),
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
OutlinedButton.icon(
|
|
style: OutlinedButton.styleFrom(
|
|
minimumSize: const Size.fromHeight(50),
|
|
),
|
|
onPressed: () => reset(context),
|
|
icon: const Icon(Icons.restart_alt),
|
|
label: const Text('恢复演示数据'),
|
|
),
|
|
const SizedBox(height: 10),
|
|
TextButton(
|
|
onPressed: () => showDemoMessage(context, '退出登录'),
|
|
child: const Text('切换账号或退出登录'),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ProfileStat extends StatelessWidget {
|
|
const _ProfileStat({required this.value, required this.label});
|
|
|
|
final String value;
|
|
final String label;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
Text(
|
|
value,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 17,
|
|
fontWeight: FontWeight.w900,
|
|
),
|
|
),
|
|
const SizedBox(height: 3),
|
|
Text(
|
|
label,
|
|
style: const TextStyle(color: Colors.white70, fontSize: 11),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|