fix(app): 修复 4 个 Flutter 交互问题
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:
@@ -625,6 +625,7 @@ class _EditorStack extends StatefulWidget {
|
||||
|
||||
class _EditorStackState extends State<_EditorStack> {
|
||||
EditorTool? _lastTool;
|
||||
int _lastReactivatedAt = 0;
|
||||
late final TextEditingController _titleController;
|
||||
|
||||
@override
|
||||
@@ -675,6 +676,26 @@ class _EditorStackState extends State<_EditorStack> {
|
||||
});
|
||||
}
|
||||
_lastTool = currentTool;
|
||||
|
||||
// 工具重新激活(再次点击已选中的工具)→ 重新弹出面板
|
||||
final reactivatedAt = widget.state.toolReactivatedAt;
|
||||
if (reactivatedAt != _lastReactivatedAt) {
|
||||
_lastReactivatedAt = reactivatedAt;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
|
||||
switch (currentTool) {
|
||||
case EditorTool.brush:
|
||||
_showBrushPanel();
|
||||
case EditorTool.sticker:
|
||||
_showStickerPicker();
|
||||
case EditorTool.more:
|
||||
_showMoreSheet();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// 显示贴纸选择底部面板
|
||||
@@ -962,6 +983,19 @@ class _EditorStackState extends State<_EditorStack> {
|
||||
positionY: y,
|
||||
));
|
||||
},
|
||||
onResized: (id, w, h) {
|
||||
context.read<EditorBloc>().add(ElementResized(
|
||||
elementId: id,
|
||||
width: w,
|
||||
height: h,
|
||||
));
|
||||
},
|
||||
onRotated: (id, r) {
|
||||
context.read<EditorBloc>().add(ElementRotated(
|
||||
elementId: id,
|
||||
rotation: r,
|
||||
));
|
||||
},
|
||||
onDeleted: (id) {
|
||||
context.read<EditorBloc>().add(ElementRemoved(id));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user