9892b65a19
CI / flutter-gates (push) Successful in 3m9s
- 新增 PostComposePage(P3 发布页,push 路由 post_form):正文/类目 (general·help)/九宫格选图(组装 MediaUploader + UploadProgressOverlay, 删格按列表序重发 position)/发布 gating(正文非空 + 在场媒体全 ready) - 发布走「createPost(draft) → PATCH status=published」两步:迁移失败时草稿 已在服务端,UI 明确提示「草稿已保存」;40905 重置幂等键、42203 提示等图、 网络失败同键重放不重复建帖;40902 自动取新 version 重提一次 - 草稿:「存草稿」(manual) 与「取消 → 保留」(on_exit) 两路径 + 进页恢复最新 一条草稿(提示条/清空);「不保留」软删服务端草稿(post_deleted 触点) - 埋点:新增 post_analytics.dart(发布漏斗五事件 + 媒体三段,键集对齐字典 v3);MediaUploader 挂接 started/succeeded/failed(含 cancelled) 与 attemptSeq; pageName 枚举补 post_form - PostMediaEditGrid(同文件编辑态):3 列九宫格 + 虚线「+」格 + 删除角标 + 进度覆盖层 + 失败整格重试;页级上传汇总条 - create 页只余 AI 生成模拟(M4 原样保留),demo 发布流与 AppState.posts / publishPost / updatePost 及其持久化一并退役;首页 story「发布」与 Feed 空态 CTA 改为 push 真实发布页 - 测试 458 → 502(+44):发布页 widget 22、发布埋点 11、媒体三段 7、编辑态 九宫格 4、主壳发布闭环 1;另加桌面真链路 integration_test(env 门控) - flutter analyze 0 问题、dart format 无 diff;compose 六容器真链路实测通过 (选图上传 → 发布 → Feed 置顶 → 第二客户端可见) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
177 lines
5.8 KiB
Dart
177 lines
5.8 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, this.onLogout});
|
|
|
|
final AppState appState;
|
|
|
|
/// 真实退出登录入口;未接线时保持演示提示。
|
|
final Future<void> Function()? onLogout;
|
|
|
|
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(
|
|
// 「我的资料」头部整体仍是 demo 家具(M5 范围):三项
|
|
// 统计同源 demo 常量;AppState.posts 随 T3-17 退役后
|
|
// 本项直读 demo 列表长度,不伪装真实数据。
|
|
value: '${initialPosts.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: onLogout ?? () => 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),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|