fix(app): 修复 4 个 Flutter 交互问题
Some checks failed
Main Merge / backend (push) Has been cancelled
Main Merge / frontend (push) Has been cancelled

1. 首页数据不刷新 — JournalRepository 添加 onJournalChanged
   Stream 变更通知,HomeBloc 订阅后自动刷新
2. 画笔再次点击不弹出面板 — 添加 ToolReactivated 事件,
   工具栏检测已激活工具时发出重新激活信号
3. 钢笔铅笔效果一样 — 调整 perfect_freehand 参数
   (pen: size 10/smooth 0.65, pencil: size 3/smooth 0.35)
4. 橡皮擦不生效 — ActiveStrokePainter 橡皮擦模式绘制
   半透明灰色反馈,笔画完成后 setState 触发 Layer 1 重绘
5. 贴纸文字无法缩放 — DraggableElement 用 Scale 手势
   替换 Pan 手势,支持双指缩放和旋转
This commit is contained in:
iven
2026-06-04 00:05:22 +08:00
parent 988ee7335a
commit 9fce34f4ef
14 changed files with 164 additions and 15 deletions

View File

@@ -107,6 +107,12 @@ class ToolChanged extends EditorEvent {
ToolChanged(this.tool);
}
/// 再次点击已激活的工具 — 重新弹出设置面板
class ToolReactivated extends EditorEvent {
final EditorTool tool;
ToolReactivated(this.tool);
}
/// 加载已有元素
class ElementsLoaded extends EditorEvent {
final List<JournalElement> elements;
@@ -227,6 +233,9 @@ class EditorState {
final bool isDirty;
final DateTime? lastSavedAt;
// 工具重新激活时间戳(用于驱动面板重新弹出)
final int toolReactivatedAt;
const EditorState({
this.strokes = const [],
this.redoStack = const [],
@@ -243,6 +252,7 @@ class EditorState {
this.title = '',
this.isDirty = false,
this.lastSavedAt,
this.toolReactivatedAt = 0,
});
EditorState copyWith({
@@ -261,6 +271,7 @@ class EditorState {
String? title,
bool? isDirty,
DateTime? lastSavedAt,
int? toolReactivatedAt,
}) =>
EditorState(
strokes: strokes ?? this.strokes,
@@ -279,6 +290,7 @@ class EditorState {
title: title ?? this.title,
isDirty: isDirty ?? this.isDirty,
lastSavedAt: lastSavedAt ?? this.lastSavedAt,
toolReactivatedAt: toolReactivatedAt ?? this.toolReactivatedAt,
);
/// 是否处于手写模式
@@ -330,6 +342,7 @@ class EditorBloc extends Bloc<EditorEvent, EditorState> {
// 工具栏事件
on<ToolChanged>(_onToolChanged);
on<ToolReactivated>(_onToolReactivated);
// 标签/心情/标题事件
on<TagAdded>(_onTagAdded);
@@ -514,6 +527,13 @@ class EditorBloc extends Bloc<EditorEvent, EditorState> {
));
}
void _onToolReactivated(ToolReactivated event, Emitter<EditorState> emit) {
// 不改变 activeTool仅递增时间戳驱动 UI 层重新弹出面板
emit(state.copyWith(
toolReactivatedAt: DateTime.now().millisecondsSinceEpoch,
));
}
// ============================================================
// 标签/心情/标题事件处理
// ============================================================