feat(app): 设置页 UI + Mood/成就/贴纸 BLoC 接入 API + B7 测试扩展
前端改动: - 新建设置页面 (主题切换/关于/隐私政策/用户协议/儿童隐私保护) - SettingsBloc 注册到 MultiRepositoryProvider 全局可访问 - MoodBloc 修复编译错误 + 接入 /diary/stats/mood API - MoodPage 添加错误状态展示和重试按钮 - AchievementBloc + 页面改造接入 /diary/achievements API - StickerBloc + 页面改造接入 /diary/sticker-packs API - TemplateBloc + 页面改造接入 /diary/templates API - ProfilePage 设置入口改为跳转 /settings - 添加 /settings 路由 后端改动: - 扩展 mood_stats_service 测试 (连续天数算法/心情计数/边界场景) - 新增 class_service 测试 (班级码生成/唯一性/错误映射) - 新增 achievement_service 测试 (DTO 结构/序列化/map 构建) - 新增 sticker_service 测试 (DTO 序列化/错误处理) - 扩展 dto.rs 测试 (achievement/mood_stats/sticker/template/notification) - 清理 2 个 unused import warning 验证: - cargo check 0 error 0 warning - flutter analyze 0 error
This commit is contained in:
@@ -1,24 +1,13 @@
|
||||
// 设置 BLoC — 主题切换 + 应用设置管理
|
||||
//
|
||||
// ChangeNotifier 模式(同 MoodBloc),通过 ListenableBuilder 消费。
|
||||
// Phase 1: 内存态 + TODO 持久化到 SharedPreferences。
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// ===== Events =====
|
||||
|
||||
sealed class SettingsEvent {
|
||||
const SettingsEvent();
|
||||
}
|
||||
|
||||
final class SettingsThemeChanged extends SettingsEvent {
|
||||
final ThemeMode themeMode;
|
||||
const SettingsThemeChanged(this.themeMode);
|
||||
}
|
||||
|
||||
final class SettingsLoad extends SettingsEvent {
|
||||
const SettingsLoad();
|
||||
}
|
||||
|
||||
// ===== State =====
|
||||
|
||||
/// 设置页面状态
|
||||
class SettingsState {
|
||||
final ThemeMode themeMode;
|
||||
final bool isLoading;
|
||||
@@ -37,6 +26,7 @@ class SettingsState {
|
||||
|
||||
// ===== BLoC =====
|
||||
|
||||
/// 设置管理器 — 全局单例,在 NuanjiApp 中创建
|
||||
class SettingsBloc extends ChangeNotifier {
|
||||
SettingsState _state = const SettingsState();
|
||||
SettingsState get state => _state;
|
||||
@@ -45,7 +35,7 @@ class SettingsBloc extends ChangeNotifier {
|
||||
void changeTheme(ThemeMode mode) {
|
||||
_state = _state.copyWith(themeMode: mode);
|
||||
notifyListeners();
|
||||
// TODO: 持久化到 SharedPreferences/Isar
|
||||
// TODO: 持久化到 SharedPreferences
|
||||
}
|
||||
|
||||
/// 循环切换: system → light → dark → system
|
||||
|
||||
@@ -111,11 +111,7 @@ class ProfilePage extends StatelessWidget {
|
||||
icon: Icons.settings_outlined,
|
||||
iconColor: colorScheme.onSurface.withValues(alpha: 0.5),
|
||||
title: '设置',
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('设置页面开发中')),
|
||||
);
|
||||
},
|
||||
onTap: () => context.go('/settings'),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user