Files
social-app/apps/lib/features/settings/ui/screens/memory_screen.dart
T
qzl b34697660d feat: 实现 Auth 全局状态机与 401 统一处理机制
- 新增 AuthSessionInvalidated 事件处理 token 失效场景
- ApiInterceptor 新增 authFailureCallback 单飞机制
- AuthBloc 区分 manual logout 与 auto expiry 语义
- 新增 startup recovery fallback 防止启动卡死

feat: 重构 Calendar DayWeek 视图事件布局引擎

- 新增 DayEventLayoutEngine 解耦事件计算与渲染
- 新增 DayTimelineMetrics 统一时间轴常量
- 新增 DayViewScale 支持捏合缩放

feat: 新增 Settings 页面共享 UI 组件

- 新增 BackTitlePageHeader 统一页面 header
- 新增 DetailHeaderActionMenu 统一操作菜单
- 新增 DestructiveActionSheet 统一删除确认
- 新增 AppToggleSwitch 统一开关组件

feat: Chat UI Schema 支持导航操作

- 支持 navigation 类型 action 触发内部路由跳转
- 新增路径验证与参数处理

chore: 更新相关测试覆盖 auth 失效路径
2026-03-18 13:35:25 +08:00

212 lines
6.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import '../../../../core/theme/design_tokens.dart';
import '../../../../shared/widgets/app_toggle_switch.dart';
import '../../data/services/memory_service.dart';
import '../widgets/settings_page_scaffold.dart';
class MemoryScreen extends StatefulWidget {
const MemoryScreen({super.key});
@override
State<MemoryScreen> createState() => _MemoryScreenState();
}
class _MemoryScreenState extends State<MemoryScreen> {
bool _memoryEnabled = true;
final MemoryService _memoryService = MemoryService();
late List<MemoryItemModel> _memoryItems;
@override
void initState() {
super.initState();
_memoryItems = _memoryService.getMemoryItems();
}
@override
Widget build(BuildContext context) {
return SettingsPageScaffold(
title: '我的记忆',
onBack: () => context.pop(),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildToggleCard(),
if (_memoryItems.isNotEmpty) ...[
const SizedBox(height: 14),
_buildListTitle(),
const SizedBox(height: 8),
_buildMemoryList(),
],
const SizedBox(height: 20),
_buildManageButton(),
],
),
);
}
Widget _buildToggleCard() {
return Container(
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
color: AppColors.white,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: AppColors.borderSecondary),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'启用记忆',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: AppColors.slate900,
),
),
_buildToggle(_memoryEnabled, (v) {
setState(() => _memoryEnabled = v);
}),
],
),
const SizedBox(height: 10),
const Align(
alignment: Alignment.centerLeft,
child: Text(
'开启后,将持续记录并更新你的长期偏好',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.normal,
color: Color(0xFF71839F),
),
),
),
],
),
);
}
Widget _buildListTitle() {
return const Text(
'记忆条目',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: AppColors.slate500,
),
);
}
Widget _buildMemoryList() {
return Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: AppColors.white,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: AppColors.borderSecondary),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
for (int i = 0; i < _memoryItems.length; i++) ...[
_buildMemoryItem(_memoryItems[i]),
if (i < _memoryItems.length - 1) const SizedBox(height: 10),
],
],
),
);
}
Widget _buildMemoryItem(MemoryItemModel item) {
return GestureDetector(
onTap: () {},
child: Container(
height: 74,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: AppColors.surfaceTertiary,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: AppColors.borderSecondary),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: 32,
height: 32,
decoration: BoxDecoration(
color: AppColors.surfaceInfo,
borderRadius: BorderRadius.circular(10),
),
child: Icon(item.icon, size: 16, color: AppColors.blue500),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item.title,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: AppColors.slate900,
),
),
const SizedBox(height: 4),
Text(
item.subtitle,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.normal,
color: AppColors.slate500,
),
),
],
),
),
const Icon(
Icons.chevron_right,
size: 16,
color: AppColors.slate400,
),
],
),
),
);
}
Widget _buildManageButton() {
return GestureDetector(
onTap: () {},
child: Container(
height: 44,
decoration: BoxDecoration(
color: AppColors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: AppColors.borderSecondary),
),
child: const Center(
child: Text(
'管理记忆条目',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: AppColors.slate700,
),
),
),
),
);
}
Widget _buildToggle(bool value, ValueChanged<bool> onChanged) {
return AppToggleSwitch(value: value, onChanged: onChanged);
}
}