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 手势,支持双指缩放和旋转
104 lines
3.3 KiB
Dart
104 lines
3.3 KiB
Dart
// 编辑器工具栏 — 底部单行 6 按钮面板
|
||
//
|
||
// 精简布局:
|
||
// - 单行 6 个工具按钮(贴纸/模板/画笔/照片/文字/更多)
|
||
// - 高度 72px + 底部安全区
|
||
// - 每个按钮:Column(icon 20px + label 10px),最小 36x36
|
||
//
|
||
// 详细选项已移至独立面板:
|
||
// - 画笔选项 → BrushPanel(底部抽屉)
|
||
// - 撤销/重做 → 顶栏
|
||
// - 清除 → 顶栏
|
||
//
|
||
// 设计规范:触摸目标 ≥ 44px,圆角 22px (pill)
|
||
|
||
import 'package:flutter/material.dart';
|
||
|
||
import '../bloc/editor_bloc.dart';
|
||
|
||
/// 编辑器工具栏 — 精简版
|
||
class EditorToolbar extends StatelessWidget {
|
||
final EditorState state;
|
||
final ValueChanged<EditorEvent> onEvent;
|
||
|
||
const EditorToolbar({
|
||
super.key,
|
||
required this.state,
|
||
required this.onEvent,
|
||
});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
final colorScheme = Theme.of(context).colorScheme;
|
||
return Container(
|
||
height: 72 + MediaQuery.of(context).padding.bottom,
|
||
decoration: BoxDecoration(
|
||
color: colorScheme.surface,
|
||
border: Border(
|
||
top: BorderSide(
|
||
color: colorScheme.outlineVariant.withValues(alpha: 0.3),
|
||
),
|
||
),
|
||
),
|
||
child: Padding(
|
||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
|
||
child: Row(
|
||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||
children: [
|
||
_toolBtn(context, EditorTool.sticker, Icons.emoji_emotions_rounded, '贴纸'),
|
||
_toolBtn(context, EditorTool.template, Icons.dashboard_customize_rounded, '模板'),
|
||
_toolBtn(context, EditorTool.brush, Icons.gesture_rounded, '画笔'),
|
||
_toolBtn(context, EditorTool.photo, Icons.add_photo_alternate_rounded, '照片'),
|
||
_toolBtn(context, EditorTool.text, Icons.text_fields_rounded, '文字'),
|
||
_toolBtn(context, EditorTool.more, Icons.more_horiz_rounded, '更多'),
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
/// 工具按钮 — icon + label 垂直排列
|
||
Widget _toolBtn(
|
||
BuildContext context,
|
||
EditorTool tool,
|
||
IconData icon,
|
||
String label,
|
||
) {
|
||
final isActive = state.activeTool == tool;
|
||
final colorScheme = Theme.of(context).colorScheme;
|
||
|
||
return GestureDetector(
|
||
onTap: () => onEvent(isActive ? ToolReactivated(tool) : ToolChanged(tool)),
|
||
behavior: HitTestBehavior.opaque,
|
||
child: Container(
|
||
constraints: const BoxConstraints(minWidth: 36, minHeight: 36),
|
||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||
child: Column(
|
||
mainAxisSize: MainAxisSize.min,
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
children: [
|
||
Icon(
|
||
icon,
|
||
size: 20,
|
||
color: isActive
|
||
? colorScheme.primary
|
||
: colorScheme.onSurface.withValues(alpha: 0.5),
|
||
),
|
||
const SizedBox(height: 2),
|
||
Text(
|
||
label,
|
||
style: TextStyle(
|
||
fontSize: 10,
|
||
color: isActive
|
||
? colorScheme.primary
|
||
: colorScheme.onSurface.withValues(alpha: 0.5),
|
||
fontWeight: isActive ? FontWeight.w600 : FontWeight.normal,
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
}
|